Oolite
Loading...
Searching...
No Matches
OOHPVector.h File Reference
#include "OOFastArithmetic.h"
#include "OOVector.h"
Include dependency graph for OOHPVector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HPVector
struct  HPVector2D

Macros

#define HPvector_between(a, b)
#define GLVertexOOHPVector(v)
#define GLTranslateOOHPVector(v)

Typedefs

typedef struct HPVector HPVector
typedef struct HPVector2D HPVector2D

Functions

OOINLINE HPVector make_HPvector (OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
OOINLINE HPVector2D MakeHPVector2D (OOHPScalar vx, OOHPScalar vy) INLINE_CONST_FUNC
OOINLINE HPVector vectorToHPVector (Vector v) INLINE_CONST_FUNC
OOINLINE Vector HPVectorToVector (HPVector v) INLINE_CONST_FUNC
HPVector OORandomUnitHPVector (void)
HPVector OOHPVectorRandomSpatial (OOHPScalar maxLength)
HPVector OOHPVectorRandomRadial (OOHPScalar maxLength)
HPVector OORandomPositionInCylinder (HPVector centre1, OOHPScalar exclusion1, HPVector centre2, OOHPScalar exclusion2, OOHPScalar radius)
HPVector OORandomPositionInShell (HPVector centre, OOHPScalar inner, OOHPScalar outer)
HPVector OOProjectHPVectorToPlane (HPVector point, HPVector plane, HPVector normal)
OOINLINE void HPscale_vector (HPVector *outHPVector, OOHPScalar factor) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE HPVector HPvector_multiply_scalar (HPVector v, OOHPScalar s) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add (HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_subtract (HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_flip (HPVector v) INLINE_CONST_FUNC
OOINLINE HPVector OOHPVectorInterpolate (HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
OOINLINE HPVector OOHPVectorTowards (HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
OOINLINE bool HPvector_equal (HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude2 (HPVector vec) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPmagnitude (HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal (HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_fallback (HPVector vec, HPVector fallback) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_xbasis (HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_ybasis (HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_zbasis (HPVector vec) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance2 (HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance (HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdot_product (HPVector first, HPVector second) INLINE_CONST_FUNC
OOINLINE HPVector HPcross_product (HPVector first, HPVector second) INLINE_CONST_FUNC
OOINLINE HPVector HPtrue_cross_product (HPVector first, HPVector second) CONST_FUNC
OOINLINE OOHPScalar HPtriple_product (HPVector first, HPVector second, HPVector third) INLINE_CONST_FUNC
OOINLINE HPVector HPnormal_to_surface (HPVector v1, HPVector v2, HPVector v3) CONST_FUNC

Variables

const HPVector kZeroHPVector
const HPVector kBasisXHPVector
const HPVector kBasisYHPVector
const HPVector kBasisZHPVector
const HPVector2D kZeroHPVector2D
const HPVector2D kBasisXHPVector2D
const HPVector2D kBasisYHPVector2D

Macro Definition Documentation

◆ GLTranslateOOHPVector

#define GLTranslateOOHPVector ( v)
Value:
do { \
HPVector v_ = v; \
OOGL(glTranslatef(v_.x, v_.y, v_.z)); \
} while (0)
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

Definition at line 141 of file OOHPVector.h.

141#define GLTranslateOOHPVector(v) \
142 do { \
143 HPVector v_ = v; \
144 OOGL(glTranslatef(v_.x, v_.y, v_.z)); \
145 } while (0)

◆ GLVertexOOHPVector

#define GLVertexOOHPVector ( v)
Value:
do { \
HPVector v_ = v; \
glVertex3f(v_.x, v_.y, v_.z); \
} while (0)

Definition at line 136 of file OOHPVector.h.

136#define GLVertexOOHPVector(v) \
137 do { \
138 HPVector v_ = v; \
139 glVertex3f(v_.x, v_.y, v_.z); \
140 } while (0)

◆ HPvector_between

Typedef Documentation

◆ HPVector

typedef struct HPVector HPVector

◆ HPVector2D

typedef struct HPVector2D HPVector2D

Function Documentation

◆ HPcross_product()

OOINLINE HPVector HPcross_product ( HPVector first,
HPVector second )

Definition at line 312 of file OOHPVector.h.

313{
314 return HPvector_normal(HPtrue_cross_product(first, second));
315}
OOINLINE HPVector HPvector_normal(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:288
OOINLINE HPVector HPtrue_cross_product(HPVector first, HPVector second) CONST_FUNC
Definition OOHPVector.h:303

References HPtrue_cross_product(), HPvector_normal(), and OOINLINE.

Referenced by DockEntity(OOPrivate)::addShipToShipsOnApproach:, Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, DockEntity::dockingInstructionsForShip:, Universe::getSunSkimEndPositionForShip:, HPnormal_to_surface(), Universe::legacyPositionFrom:asCoordinateSystem:, and Universe::locationByCode:withSun:andPlanet:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPdistance()

OOINLINE OOHPScalar HPdistance ( HPVector v1,
HPVector v2 )

Definition at line 298 of file OOHPVector.h.

299{
300 return HPmagnitude(HPvector_subtract(v1, v2));
301}
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:260

References HPmagnitude(), HPvector_subtract(), and OOINLINE.

Referenced by Universe::addShipAt:withRole:withinRadius:, ShipEntity::behaviour_land_on_planet:, ShipEntity(PureAI)::checkCourseToDestination, ShipEntity::currentAimTolerance, OOSunEntity::drawDirectVisionSunGlare, StationEntity::dumpSelfState, HeadUpDisplay::hudDrawWaypoint, Universe::legacyPositionFrom:asCoordinateSystem:, Universe::locationByCode:withSun:andPlanet:, OORandomPositionInCylinder(), ShipEntity::rangeToDestination, WormholeEntity::suckInShip:, VectorDistanceTo(), and VectorDistanceTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPdistance2()

OOINLINE OOHPScalar HPdistance2 ( HPVector v1,
HPVector v2 )

Definition at line 293 of file OOHPVector.h.

294{
295 return HPmagnitude2(HPvector_subtract(v1, v2));
296}
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:255

References HPmagnitude2(), HPvector_subtract(), and OOINLINE.

Referenced by Universe::addShips:withRole:atPosition:withCoordinateSystem:, DockEntity(OOPrivate)::addShipToShipsOnApproach:, ShipEntity::AuthorityPredicate, ShipEntity::becomeExplosion, ShipEntity::broadcastMessage:withUnpilotedOverride:, ShipEntity::checkCloseCollisionWith:, ShipEntity(PureAI)::checkForMotherStation, ShipEntity::checkScanner, ShipEntity::checkScannerIgnoringUnpowered, DockEntity::clearDockingCorridor, CompareEntitiesByDistance(), Universe::countEntitiesMatchingPredicate:parameter:inRange:ofEntity:, PlayerEntity::doBookkeeping:, DockEntity::dockingCorridorIsEmpty, OOSunEntity::drawDirectVisionSunGlare, ShipEntity(AI)::enterTargetWormhole, Universe::EntityInRange, CollisionRegion::findCollisions, ShipEntity(PureAI)::getWitchspaceEntryCoordinates, WormholeEntity::initWormholeTo:fromShip:, Universe::loadStationMarkets:, Universe::locationByCode:withSun:andPlanet:, Universe::nearestEntityMatchingPredicate:parameter:relativeToEntity:, OORandomPositionInCylinder(), OORandomPositionInShell(), ShipEntity::realAlertCondition, ShipEntity(PureAI)::recallStoredTarget, ShipEntity(AI)::requestDockingCoordinates, ShipEntity::sendExpandedMessage:toShip:, ShipEntity::sendMessage:toShip:withUnpilotedOverride:, ShipEntity::setProximityAlert:, ShipEntity::setTargetToNearestStationIncludingHostiles:, ShipEntity(PureAI)::setTargetToRandomStation, CollisionRegion::shadowAtPointOcclusionToValue, ShipFindNearestStation(), ShipFindNearestStation(), Universe::stationWithRole:andPosition:, ShipEntity(PureAI)::thargonCheckMother, Entity::update:, ShipEntity::update:, VectorSquaredDistanceTo(), and VectorSquaredDistanceTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPdot_product()

OOINLINE OOHPScalar HPdot_product ( HPVector first,
HPVector second )

Definition at line 317 of file OOHPVector.h.

318{
319 return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
320}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by ShipEntity::behaviour_fly_thru_navpoints:, DockEntity::dockingCorridorIsEmpty, DockEntity::dockingInstructionsForShip:, Universe::getSafeVectorFromEntity:toDistance:fromPoint:, Universe::hazardOnRouteFromEntity:toDistance:fromPoint:, HPtriple_product(), Universe::isVectorClearFromEntity:toDistance:fromPoint:, OOProjectHPVectorToPlane(), VectorAngleTo(), VectorAngleTo(), VectorDot(), and VectorDot().

Here is the caller graph for this function:

◆ HPmagnitude()

OOINLINE OOHPScalar HPmagnitude ( HPVector vec)

Definition at line 260 of file OOHPVector.h.

261{
262 return sqrt(HPmagnitude2(vec));
263}

References HPmagnitude2(), and OOINLINE.

Referenced by OOVisualEffectEntity(Private)::addSubEntity:, ShipEntity(Private)::addSubentityToCollisionRadius:, ShipEntity::behaviour_fly_thru_navpoints:, Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, DockEntity::dockingInstructionsForShip:, Universe::getSafeVectorFromEntity:toDistance:fromPoint:, Universe::hazardOnRouteFromEntity:toDistance:fromPoint:, HPdistance(), Universe::locationByCode:withSun:andPlanet:, OOExhaustPlumeEntity::update:, OOSunEntity::updateCameraRelativePosition, VectorMagnitude(), and VectorMagnitude().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPmagnitude2()

◆ HPnormal_to_surface()

OOINLINE HPVector HPnormal_to_surface ( HPVector v1,
HPVector v2,
HPVector v3 )

Definition at line 327 of file OOHPVector.h.

328{
329 HPVector d0, d1;
330 d0 = HPvector_subtract(v2, v1);
331 d1 = HPvector_subtract(v3, v2);
332 return HPcross_product(d0, d1);
333}
OOINLINE HPVector HPcross_product(HPVector first, HPVector second) INLINE_CONST_FUNC
Definition OOHPVector.h:312

References HPcross_product(), HPvector_subtract(), and OOINLINE.

Here is the call graph for this function:

◆ HPscale_vector()

OOINLINE void HPscale_vector ( HPVector * outHPVector,
OOHPScalar factor )

Definition at line 184 of file OOHPVector.h.

185{
186 /*
187 Clang static analyzer: reports an unintialized value here when called
188 from -[HeadUpDisplay rescaleByFactor:]. This is blatantly wrong, as
189 the array the vector comes from is fully initialized in the range being
190 looped over.
191 -- Ahruman 2012-09-14
192 */
193 vec->x *= factor;
194 vec->y *= factor;
195 vec->z *= factor;
196}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

◆ HPtriple_product()

OOINLINE OOHPScalar HPtriple_product ( HPVector first,
HPVector second,
HPVector third )

Definition at line 322 of file OOHPVector.h.

323{
324 return HPdot_product(first, HPtrue_cross_product(second, third));
325}
OOINLINE OOHPScalar HPdot_product(HPVector first, HPVector second) INLINE_CONST_FUNC
Definition OOHPVector.h:317

References HPdot_product(), HPtrue_cross_product(), and OOINLINE.

Referenced by VectorTripleProduct(), and VectorTripleProduct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPtrue_cross_product()

OOINLINE HPVector HPtrue_cross_product ( HPVector first,
HPVector second )

Definition at line 303 of file OOHPVector.h.

304{
305 HPVector result;
306 result.x = (first.y * second.z) - (first.z * second.y);
307 result.y = (first.z * second.x) - (first.x * second.z);
308 result.z = (first.x * second.y) - (first.y * second.x);
309 return result;
310}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by HPcross_product(), HPtriple_product(), VectorCross(), and VectorCross().

Here is the caller graph for this function:

◆ HPvector_add()

OOINLINE HPVector HPvector_add ( HPVector a,
HPVector b )

Definition at line 213 of file OOHPVector.h.

214{
215 HPVector r;
216 r.x = a.x + b.x;
217 r.y = a.y + b.y;
218 r.z = a.z + b.z;
219 return r;
220}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by Entity::absolutePositionForSubentityOffset:, ShipEntity::absoluteTractorPosition, Universe::addShipAt:withRole:withinRadius:, Entity::applyVelocity:, StationEntity::beaconPosition, ShipEntity::becomeExplosion, PlayerEntity::breakPatternPosition, ShipEntity::calculateTargetPosition, ShipEntity::calculateTrackingCurve, ShipEntity::collideWithShip:, ShipEntity(Private)::coordinatesForEscortPosition:, WormholeEntity::disgorgeShips, OOParticleSystem::drawImmediate:translucent:, OOLightParticleEntity::drawSubEntityImmediate:translucent:, ShipEntity::dumpItem:, ShipEntity::fireDirectLaserShotAt:, ShipEntity::fireLaserShotInDirection:weaponIdentifier:, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireSubentityLaserShot:, ShipEntity::fireTurretCannon:, Universe::firstEntityTargetedByPlayer, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, ShipEntity(PureAI)::getWitchspaceEntryCoordinates, PlayerEntity::leaveWitchspace, Universe::locationByCode:withSun:andPlanet:, Entity::moveForward:, OORandomPositionInCylinder(), OORandomPositionInShell(), Universe::populateNormalSpace, OOExhaustPlumeEntity(Private)::saveToLastFrame, ShipEntity(PureAI)::setCourseToPlanet, ShipEntity(PureAI)::setDestinationToCurrentLocation, ShipEntity(PureAI)::setDestinationToJinkPosition, DockEntity::setDimensionsAndCorridor:ddc:launching:, ShipEntity(PureAI)::setTakeOffFromPlanet, Universe::spawnShipWithRole:near:, ShipEntity::throwSparks, OOExhaustPlumeEntity::update:, ShipEntity::update:, ShipEntity::updateTrackingCurve, VectorAdd(), and VectorAdd().

Here is the caller graph for this function:

◆ HPvector_equal()

OOINLINE bool HPvector_equal ( HPVector a,
HPVector b )

Definition at line 250 of file OOHPVector.h.

251{
252 return a.x == b.x && a.y == b.y && a.z == b.z;
253}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by quaternion_rotation_betweenHP(), ShipEntity(LoadRestore)::savedShipDictionaryWithContext:, ShipEntity(PureAI)::setSunSkimStartCoordinates, Universe::spawnShip:, Entity::update:, and PlayerEntity(OOPrivate)::updateMovementFlags.

Here is the caller graph for this function:

◆ HPvector_flip()

OOINLINE HPVector HPvector_flip ( HPVector v)

Definition at line 245 of file OOHPVector.h.

246{
248}
const HPVector kZeroHPVector
Definition OOHPVector.m:27

References HPvector_subtract(), kZeroHPVector, and OOINLINE.

Referenced by Universe::spawnShip:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPvector_multiply_scalar()

OOINLINE HPVector HPvector_multiply_scalar ( HPVector v,
OOHPScalar s )

Definition at line 198 of file OOHPVector.h.

199{
200 /*
201 Clang static analyzer: reports a garbage value here when called from
202 -[OOMesh rescaleByFactor:], apparently on baseless assumption that
203 OOMesh._vertices points to only one vertex.
204 -- Ahruman 2012-09-14
205 */
206 HPVector r;
207 r.x = v.x * s;
208 r.y = v.y * s;
209 r.z = v.z * s;
210 return r;
211}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by Universe::addShipsToRoute:withRole:quantity:routeFraction:asGroup:, Entity::applyVelocity:, ShipEntity::calculateTargetPosition, ShipEntity::calculateTrackingCurve, HPvector_normal_or_fallback(), PlayerEntity::leaveWitchspace, Universe::locationByCode:withSun:andPlanet:, Entity::moveForward:, OOHPVectorRandomRadial(), OOHPVectorRandomSpatial(), OOProjectHPVectorToPlane(), ShipEntity(PureAI)::setCourseToPlanet, DockEntity::setDimensionsAndCorridor:ddc:launching:, ShipEntity(PureAI)::setTakeOffFromPlanet, ShipEntity::setUpOneStandardSubentity:asTurret:, Universe::setUpSpace, DockEntity::shipIsInDockingCorridor:, OOSunEntity::updateCameraRelativePosition, VectorMultiply(), VectorMultiply(), VectorStaticRandomDirection(), and VectorStaticRandomDirection().

Here is the caller graph for this function:

◆ HPvector_normal()

OOINLINE HPVector HPvector_normal ( HPVector vec)

Definition at line 288 of file OOHPVector.h.

289{
291}
OOINLINE HPVector HPvector_normal_or_fallback(HPVector vec, HPVector fallback) INLINE_CONST_FUNC
Definition OOHPVector.h:265

References HPvector_normal_or_fallback(), kZeroHPVector, and OOINLINE.

Referenced by Universe::addLaserHitEffectsAt:against:damage:color:, Universe::addShips:withRole:atPosition:withCoordinateSystem:, Universe::addShipsToRoute:withRole:quantity:routeFraction:asGroup:, ShipEntity::behaviour_fly_thru_navpoints:, DockEntity::dockingCorridorIsEmpty, DockEntity::dockingInstructionsForShip:, Universe::getSafeVectorFromEntity:toDistance:fromPoint:, Universe::getSunSkimEndPositionForShip:, Universe::getSunSkimStartPositionForShip:, Universe::hazardOnRouteFromEntity:toDistance:fromPoint:, HPcross_product(), Universe::isVectorClearFromEntity:toDistance:fromPoint:, PlayerEntity::leaveWitchspace, OORandomUnitHPVector(), ShipEntity(PureAI)::setCourseToPlanet, ShipEntity(PureAI)::setPlanetPatrolCoordinates, ShipEntity(PureAI)::setSunSkimExitCoordinates, ShipEntity(PureAI)::setTakeOffFromPlanet, DockEntity::shipIsInDockingCorridor:, Universe::spawnShip:, VectorAngleTo(), VectorAngleTo(), VectorDirection(), and VectorDirection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPvector_normal_or_fallback()

OOINLINE HPVector HPvector_normal_or_fallback ( HPVector vec,
HPVector fallback )

Definition at line 265 of file OOHPVector.h.

266{
267 OOHPScalar mag2 = HPmagnitude2(vec);
268 if (EXPECT_NOT(mag2 == 0.0))
269 return fallback;
270 return HPvector_multiply_scalar(vec, 1.0 / sqrt(mag2));
271}
#define EXPECT_NOT(x)
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
Definition OOHPVector.h:198
double OOHPScalar
Definition OOMaths.h:51

References EXPECT_NOT, HPmagnitude2(), HPvector_multiply_scalar(), and OOINLINE.

Referenced by HPvector_normal(), HPvector_normal_or_xbasis(), HPvector_normal_or_ybasis(), HPvector_normal_or_zbasis(), and ShipEntity(PureAI)::setDestinationToDockingAbort.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPvector_normal_or_xbasis()

OOINLINE HPVector HPvector_normal_or_xbasis ( HPVector vec)

Definition at line 273 of file OOHPVector.h.

274{
276}
const HPVector kBasisXHPVector
Definition OOHPVector.h:49

References HPvector_normal_or_fallback(), kBasisXHPVector, and OOINLINE.

Referenced by Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, and Universe::legacyPositionFrom:asCoordinateSystem:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPvector_normal_or_ybasis()

OOINLINE HPVector HPvector_normal_or_ybasis ( HPVector vec)

Definition at line 278 of file OOHPVector.h.

279{
281}
const HPVector kBasisYHPVector
Definition OOHPVector.h:50

References HPvector_normal_or_fallback(), kBasisYHPVector, and OOINLINE.

Here is the call graph for this function:

◆ HPvector_normal_or_zbasis()

OOINLINE HPVector HPvector_normal_or_zbasis ( HPVector vec)

Definition at line 283 of file OOHPVector.h.

284{
286}
const HPVector kBasisZHPVector
Definition OOHPVector.h:51

References HPvector_normal_or_fallback(), kBasisZHPVector, and OOINLINE.

Referenced by ShipEntity::collideWithShip:, Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, and Universe::legacyPositionFrom:asCoordinateSystem:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HPvector_subtract()

OOINLINE HPVector HPvector_subtract ( HPVector a,
HPVector b )

Definition at line 236 of file OOHPVector.h.

237{
238 HPVector r;
239 r.x = a.x - b.x;
240 r.y = a.y - b.y;
241 r.z = a.z - b.z;
242 return r;
243}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by DockEntity::abortAllDockings, DockEntity::abortDockingForShip:, Universe::addLaserHitEffectsAt:against:damage:color:, Universe::addShipsToRoute:withRole:quantity:routeFraction:asGroup:, ShipEntity::approachAspectToPrimaryTarget, ShipEntity::ballTrackLeadingTarget:atTarget:, ShipEntity::behaviour_track_as_turret:, ShipEntity::canStillTrackPrimaryTarget, ShipEntity::checkForAegis, ShipEntity::collideWithShip:, Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, DockEntity::dockingInstructionsForShip:, OOLightParticleEntity::drawSubEntityImmediate:translucent:, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireSubentityLaserShot:, Universe::firstEntityTargetedByPlayer, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, HPdistance(), HPdistance2(), HPnormal_to_surface(), HPvector_flip(), HeadUpDisplay::hudDrawReticleOnTarget, HeadUpDisplay::hudDrawWaypoint, ShipEntity::launchCascadeMine, PlayerEntity::launchEscapeCapsule, PlayerEntity::leaveWitchspace, Universe::legacyPositionFrom:asCoordinateSystem:, Universe::locationByCode:withSun:andPlanet:, PlayerEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::onTarget:withWeapon:, OOMatrixForBillboard(), OOProjectHPVectorToPlane(), DockEntity::pruneAndCountShipsOnApproach, ShipEntity::rangeToSecondaryTarget:, Entity::relativePosition, ShipEntity(PureAI)::setPlanetPatrolCoordinates, ShipEntity(PureAI)::setSunSkimExitCoordinates, ShipEntity(PureAI)::setTakeOffFromPlanet, Universe::setUpSpace, CollisionRegion::shadowAtPointOcclusionToValue, DockEntity::shipIsInDockingCorridor:, Universe::spawnShip:, ShipEntity::SurfaceDistanceSqaredV, PlayerEntity::takeEnergyDamage:from:becauseOf:weaponIdentifier:, PlayerEntity::takeScrapeDamage:from:, ShipEntity::throwSparks, ShipEntity::trackDestination:retreat:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, OOExhaustPlumeEntity::update:, Entity::updateCameraRelativePosition, OOSunEntity::updateCameraRelativePosition, VectorSubtract(), VectorSubtract(), and Entity::vectorTo:.

Here is the caller graph for this function:

◆ HPVectorToVector()

OOINLINE Vector HPVectorToVector ( HPVector v)

Definition at line 175 of file OOHPVector.h.

176{
177 Vector result;
178 result.x = (OOScalar)v.x;
179 result.y = (OOScalar)v.y;
180 result.z = (OOScalar)v.z;
181 return result;
182}
GLfloat OOScalar
Definition OOMaths.h:49
OOScalar x
Definition OOVector.h:32

References OOINLINE, HPVector::x, Vector::x, HPVector::y, Vector::y, HPVector::z, and Vector::z.

Referenced by Universe::addLaserHitEffectsAt:against:damage:color:, ShipEntity::approachAspectToPrimaryTarget, ShipEntity::ballTrackLeadingTarget:atTarget:, ShipEntity::canScoop:, ShipEntity::checkCloseCollisionWith:, ShipEntity::collideWithShip:, ShipEntity::doesHitLine:v1:, PlayerEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:hitEntity:, ShipEntity::doesHitLine:v1:withPosition:i:j:k:, ShipEntity::doOctreesCollide, OOLightParticleEntity::drawSubEntityImmediate:translucent:, OOVisualEffectEntity(Private)::drawSubEntityImmediate:translucent:, ShipEntity::drawSubEntityImmediate:translucent:, PlayerEntity::drawTransformationMatrix, ShipEntity::fireSubentityLaserShot:, Universe::firstEntityTargetedByPlayer, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, HeadUpDisplay::hudDrawReticleOnTarget, HeadUpDisplay::hudDrawWaypoint, JSValueToVector(), JSValueToVector(), PlayerEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::lookingAtSunWithThresholdAngleCos:, ShipEntity::onTarget:withWeapon:, OOMatrixForBillboard(), QuaternionRotate(), QuaternionRotate(), ShipEntity::rangeToSecondaryTarget:, Entity::relativePosition, OOJSPopulatorDefinition::runCallback:, ShipEntity(PureAI)::setPlanetPatrolCoordinates, ShipEntity::setProximityAlert:, CollisionRegion::shadowAtPointOcclusionToValue, Universe::spawnShip:, PlayerEntity::takeEnergyDamage:from:becauseOf:weaponIdentifier:, PlayerEntity::takeScrapeDamage:from:, ShipEntity::throwSparks, ShipEntity::trackDestination:retreat:, ShipEntity::trackPrimaryTarget:retreat:, ShipEntity::trackSideTarget:leftside:, Entity::update:, ShipEntity::update:, Entity::updateCameraRelativePosition, OOSunEntity::updateCameraRelativePosition, VectorRotationTo(), VectorRotationTo(), and Entity::vectorTo:.

Here is the caller graph for this function:

◆ make_HPvector()

OOINLINE HPVector make_HPvector ( OOHPScalar vx,
OOHPScalar vy,
OOHPScalar vz )

Definition at line 149 of file OOHPVector.h.

150{
151 HPVector result;
152 result.x = vx;
153 result.y = vy;
154 result.z = vz;
155 return result;
156}

References OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by Universe::addShips:withRole:atPosition:withCoordinateSystem:, Universe::addShips:withRole:intoBoundingBox:, PlayerEntity(Scripting)::addShipsAt:, PlayerEntity(Scripting)::addShipsAtPrecisely:, PlayerEntity(Scripting)::addShipsWithinRadius:, DockEntity(OOPrivate)::addShipToShipsOnApproach:, ShipEntity::behaviour_fly_thru_navpoints:, Universe::coordinatesFromCoordinateSystemString:, DockEntity::dockingCorridorIsEmpty, DockEntity::dockingInstructionsForShip:, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, Universe::getSafeVectorFromEntity:toDistance:fromPoint:, Universe::getSunSkimEndPositionForShip:, Universe::hazardOnRouteFromEntity:toDistance:fromPoint:, Universe::isVectorClearFromEntity:toDistance:fromPoint:, JSObjectGetVector(), JSObjectGetVector(), Universe::legacyPositionFrom:asCoordinateSystem:, OOHPVectorInterpolate(), OOHPVectorMultiplyMatrix(), OOHPVectorRandomSpatial(), OOHPVectorTowards(), OORandomUnitHPVector(), Universe::populateNormalSpace, ShipEntity(PureAI)::setCoordinates:, ShipEntity(PureAI)::setDestinationToDockingAbort, ShipEntity(PureAI)::setDestinationWithinTarget, ShipEntity(PureAI)::setPlanetPatrolCoordinates, ShipEntity(PureAI)::setRacepointsFromTarget, OOExhaustPlumeEntity::update:, VectorFromArgumentListNoErrorInternal(), and VectorFromArgumentListNoErrorInternal().

Here is the caller graph for this function:

◆ MakeHPVector2D()

OOINLINE HPVector2D MakeHPVector2D ( OOHPScalar vx,
OOHPScalar vy )

Definition at line 158 of file OOHPVector.h.

159{
160 HPVector2D result;
161 result.x = vx;
162 result.y = vy;
163 return result;
164}
OOHPScalar y
Definition OOHPVector.h:43
OOHPScalar x
Definition OOHPVector.h:42

References OOINLINE, HPVector2D::x, and HPVector2D::y.

◆ OOHPVectorInterpolate()

OOINLINE HPVector OOHPVectorInterpolate ( HPVector a,
HPVector b,
OOHPScalar where )

Definition at line 222 of file OOHPVector.h.

223{
224 return make_HPvector(OOLerpd(a.x, b.x, where),
225 OOLerpd(a.y, b.y, where),
226 OOLerpd(a.z, b.z, where));
227}
OOINLINE double OOLerpd(double v0, double v1, double fraction) INLINE_CONST_FUNC
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
Definition OOHPVector.h:149

References make_HPvector(), OOINLINE, OOLerpd(), HPVector::x, HPVector::y, and HPVector::z.

Referenced by Universe::addShipWithRole:nearRouteOneAt:, ShipEntity::avoidCollision, Universe(OOPrivate)::fractionalPositionFrom:to:withFraction:, OORandomPositionInCylinder(), VectorStaticInterpolate(), and VectorStaticInterpolate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOHPVectorRandomRadial()

HPVector OOHPVectorRandomRadial ( OOHPScalar maxLength)

Definition at line 88 of file OOHPVector.m.

89{
91}
HPVector OORandomUnitHPVector(void)
Definition OOHPVector.m:62
float randf(void)

References HPvector_multiply_scalar(), OORandomUnitHPVector(), and randf().

Referenced by Universe::spawnShip:, VectorStaticRandomDirectionAndLength(), and VectorStaticRandomDirectionAndLength().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOHPVectorRandomSpatial()

HPVector OOHPVectorRandomSpatial ( OOHPScalar maxLength)

Definition at line 75 of file OOHPVector.m.

76{
77 HPVector v;
78 OOHPScalar m;
79
80 do {
81 v = make_HPvector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
82 m = HPmagnitude2(v);
83 } while (m > 0.25); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
84
85 return HPvector_multiply_scalar(v, maxLength * 2.0); // 2.0 is to compensate for the 0.5-radius sphere.
86}

References HPmagnitude2(), HPvector_multiply_scalar(), make_HPvector(), and randf().

Referenced by Universe::addShipAt:withRole:withinRadius:, Universe::locationByCode:withSun:andPlanet:, OORandomPositionInCylinder(), OORandomPositionInShell(), ShipEntity(PureAI)::setDestinationToCurrentLocation, ShipEntity::updateTrackingCurve, VectorStaticRandom(), and VectorStaticRandom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOHPVectorTowards()

OOINLINE HPVector OOHPVectorTowards ( HPVector a,
HPVector b,
OOHPScalar where )

Definition at line 229 of file OOHPVector.h.

230{
231 return make_HPvector(a.x + b.x * where,
232 a.y + b.y * where,
233 a.z + b.z * where);
234}

References make_HPvector(), OOINLINE, HPVector::x, HPVector::y, and HPVector::z.

Referenced by DockEntity::dockingInstructionsForShip:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOProjectHPVectorToPlane()

HPVector OOProjectHPVectorToPlane ( HPVector point,
HPVector plane,
HPVector normal )

Definition at line 126 of file OOHPVector.m.

127{
128 return HPvector_subtract(point, HPvector_multiply_scalar(normal, HPdot_product(HPvector_subtract(point, plane), normal)));
129}

References HPdot_product(), HPvector_multiply_scalar(), and HPvector_subtract().

Referenced by Universe::locationByCode:withSun:andPlanet:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OORandomPositionInCylinder()

HPVector OORandomPositionInCylinder ( HPVector centre1,
OOHPScalar exclusion1,
HPVector centre2,
OOHPScalar exclusion2,
OOHPScalar radius )

Definition at line 102 of file OOHPVector.m.

103{
104 OOHPScalar exc12 = exclusion1 * exclusion1;
105 OOHPScalar exc22 = exclusion2 * exclusion2;
106 if (HPdistance(centre1, centre2) < (exclusion1 + exclusion2) * 1.2) {
107 OOLog(@"position.cylinder.error", @"Trying to generate cylinder position in range %f long with exclusions %f and %f", HPdistance(centre1, centre2), exclusion1, exclusion2);
108 }
109 HPVector result;
110 do {
111 result = HPvector_add(OOHPVectorInterpolate(centre1, centre2, randf()), OOHPVectorRandomSpatial(radius));
112 } while (HPdistance2(result, centre1) < exc12 || HPdistance2(result, centre2) < exc22);
113 return result;
114}
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:293
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:213
OOINLINE OOHPScalar HPdistance(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:298
OOINLINE HPVector OOHPVectorInterpolate(HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
Definition OOHPVector.h:222
HPVector OOHPVectorRandomSpatial(OOHPScalar maxLength)
Definition OOHPVector.m:75
#define OOLog(class, format,...)
Definition OOLogging.h:84

References HPdistance(), HPdistance2(), HPvector_add(), OOHPVectorInterpolate(), OOHPVectorRandomSpatial(), OOLog, and randf().

Referenced by Universe::locationByCode:withSun:andPlanet:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OORandomPositionInShell()

HPVector OORandomPositionInShell ( HPVector centre,
OOHPScalar inner,
OOHPScalar outer )

Definition at line 116 of file OOHPVector.m.

117{
118 HPVector result;
119 OOHPScalar inner2 = inner * inner;
120 do {
121 result = HPvector_add(centre, OOHPVectorRandomSpatial(outer));
122 } while (HPdistance2(result, centre) < inner2);
123 return result;
124}

References HPdistance2(), HPvector_add(), and OOHPVectorRandomSpatial().

Referenced by Universe::locationByCode:withSun:andPlanet:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OORandomUnitHPVector()

HPVector OORandomUnitHPVector ( void )

Definition at line 62 of file OOHPVector.m.

63{
64 HPVector v;
65 OOHPScalar m;
66
67 do {
68 v = make_HPvector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
69 m = HPmagnitude2(v);
70 } while (m > 0.25 || m == 0.0); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
71
72 return HPvector_normal(v);
73}

References HPmagnitude2(), HPvector_normal(), make_HPvector(), and randf().

Referenced by OOHPVectorRandomRadial(), VectorStaticRandomDirection(), and VectorStaticRandomDirection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vectorToHPVector()

OOINLINE HPVector vectorToHPVector ( Vector v)

Definition at line 166 of file OOHPVector.h.

167{
168 HPVector result;
169 result.x = (OOHPScalar)v.x;
170 result.y = (OOHPScalar)v.y;
171 result.z = (OOHPScalar)v.z;
172 return result;
173}
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References OOINLINE, HPVector::x, Vector::x, HPVector::y, Vector::y, HPVector::z, and Vector::z.

Referenced by ShipEntity::absoluteTractorPosition, Entity::applyVelocity:, StationEntity::beaconPosition, ShipEntity::becomeExplosion, PlayerEntity::breakPatternPosition, ShipEntity::collideWithShip:, ShipEntity(Private)::coordinatesForEscortPosition:, WormholeEntity::disgorgeShips, OOParticleSystem::drawImmediate:translucent:, ShipEntity::dumpItem:, ShipEntity::fireDirectLaserShotAt:, ShipEntity::fireLaserShotInDirection:weaponIdentifier:, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireSubentityLaserShot:, ShipEntity::fireTurretCannon:, Universe::firstEntityTargetedByPlayer, Universe::firstShipHitByLaserFromShip:inDirection:offset:gettingRangeFound:, ShipEntity(PureAI)::getWitchspaceEntryCoordinates, HPvector_forward_from_quaternion(), JSVectorSetVector(), JSVectorSetVector(), JSVectorWithVector(), JSVectorWithVector(), ShipEntity::launchCascadeMine, PlayerEntity::launchEscapeCapsule, PlayerEntity::leaveWitchspace, ScanHPVectorFromString(), ShipEntity(PureAI)::setDestinationToJinkPosition, Universe::setUpSpace, Universe::spawnShipWithRole:near:, ShipEntity::throwSparks, OOExhaustPlumeEntity::update:, ShipEntity::update:, and VectorToJSValue().

Here is the caller graph for this function:

Variable Documentation

◆ kBasisXHPVector

const HPVector kBasisXHPVector

Definition at line 49 of file OOHPVector.h.

Referenced by HPvector_normal_or_xbasis().

◆ kBasisXHPVector2D

const HPVector2D kBasisXHPVector2D

Definition at line 54 of file OOHPVector.h.

◆ kBasisYHPVector

const HPVector kBasisYHPVector

Definition at line 50 of file OOHPVector.h.

Referenced by HPvector_normal_or_ybasis().

◆ kBasisYHPVector2D

const HPVector2D kBasisYHPVector2D

Definition at line 55 of file OOHPVector.h.

◆ kBasisZHPVector

const HPVector kBasisZHPVector

◆ kZeroHPVector

◆ kZeroHPVector2D

const HPVector2D kZeroHPVector2D
extern

Definition at line 32 of file OOHPVector.m.

32{ 0.0, 0.0 };