Oolite 1.91.0.7658-250404-b1488af
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
OOVector.m File Reference
#include "OOMaths.h"
+ Include dependency graph for OOVector.m:

Go to the source code of this file.

Functions

Vector OORandomUnitVector (void)
 
Vector OOVectorRandomSpatial (OOScalar maxLength)
 
Vector OOVectorRandomRadial (OOScalar maxLength)
 
Vector OORandomPositionInBoundingBox (BoundingBox bb)
 

Variables

const Vector kZeroVector = { 0.0f, 0.0f, 0.0f }
 
const Vector kBasisXVector = { 1.0f, 0.0f, 0.0f }
 
const Vector kBasisYVector = { 0.0f, 1.0f, 0.0f }
 
const Vector kBasisZVector = { 0.0f, 0.0f, 1.0f }
 
const Vector2D kZeroVector2D = { 0.0f, 0.0f }
 
const Vector2D kBasisXVector2D = { 1.0f, 0.0f }
 
const Vector2D kBasisYVector2D = { 0.0f, 1.0f }
 
const BoundingBox kZeroBoundingBox = {{ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }}
 

Function Documentation

◆ OORandomPositionInBoundingBox()

Vector OORandomPositionInBoundingBox ( BoundingBox bb)

Definition at line 121 of file OOVector.m.

122{
123 Vector result;
124 result.x = bb.min.x + randf() * (bb.max.x - bb.min.x);
125 result.y = bb.min.y + randf() * (bb.max.y - bb.min.y);
126 result.z = bb.min.z + randf() * (bb.max.z - bb.min.z);
127 return result;
128}
float y
float x
float randf(void)

References randf().

Referenced by ShipEntity::becomeExplosion, and ShipEntity::releaseCargoPodsDebris.

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

◆ OORandomUnitVector()

Vector OORandomUnitVector ( void )

Definition at line 83 of file OOVector.m.

84{
85 Vector v;
86 float m;
87
88 do
89 {
90 v = make_vector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
91 m = magnitude2(v);
92 }
93 while (m > 0.25f || m == 0.0f); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
94
95 return vector_normal(v);
96}

References randf().

Referenced by OOParticleSystem::initWithPosition:velocity:count:minSpeed:maxSpeed:duration:baseColor:, and OOVectorRandomRadial().

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

◆ OOVectorRandomRadial()

Vector OOVectorRandomRadial ( OOScalar maxLength)

Definition at line 115 of file OOVector.m.

116{
117 return vector_multiply_scalar(OORandomUnitVector(), randf() * maxLength);
118}
Vector OORandomUnitVector(void)
Definition OOVector.m:83

References OORandomUnitVector(), and randf().

Referenced by HeadUpDisplay(Private)::drawScanner:.

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

◆ OOVectorRandomSpatial()

Vector OOVectorRandomSpatial ( OOScalar maxLength)

Definition at line 99 of file OOVector.m.

100{
101 Vector v;
102 float m;
103
104 do
105 {
106 v = make_vector(randf() - 0.5f, randf() - 0.5f, randf() - 0.5f);
107 m = magnitude2(v);
108 }
109 while (m > 0.25f); // We're confining to a sphere of radius 0.5 using the sqared magnitude; 0.5 squared is 0.25.
110
111 return vector_multiply_scalar(v, maxLength * 2.0f); // 2.0 is to compensate for the 0.5-radius sphere.
112}

References randf().

Referenced by ShipEntity(PureAI)::setDestinationToJinkPosition.

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

Variable Documentation

◆ kBasisXVector

◆ kBasisXVector2D

const Vector2D kBasisXVector2D = { 1.0f, 0.0f }

Definition at line 34 of file OOVector.m.

34{ 1.0f, 0.0f };

◆ kBasisYVector

◆ kBasisYVector2D

const Vector2D kBasisYVector2D = { 0.0f, 1.0f }

Definition at line 35 of file OOVector.m.

35{ 0.0f, 1.0f };

◆ kBasisZVector

◆ kZeroBoundingBox

const BoundingBox kZeroBoundingBox = {{ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }}

Definition at line 38 of file OOVector.m.

38{{ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }};

Referenced by OODrawable::boundingBox, and OOMesh::init.

◆ kZeroVector

const Vector kZeroVector = { 0.0f, 0.0f, 0.0f }

Definition at line 28 of file OOVector.m.

28{ 0.0f, 0.0f, 0.0f };

Referenced by ShipEntity::behaviour_attack_broadside:, ShipEntity::behaviour_attack_fly_from_target:, ShipEntity::behaviour_attack_target:, ShipEntity::behaviour_running_defense:, OOMesh(Private)::calculateVertexNormalsAndTangentsWithFaceRefs:, OOMesh(Private)::calculateVertexTangentsWithFaceRefs:, OOMesh(Private)::checkNormalsAndAdjustWinding, ShipEntity::collideWithShip:, HeadUpDisplay(Private)::drawDirectionCue:, OOECMBlastEntity::drawImmediate:translucent:, Universe::drawUniverse, PlayerEntity::engageAutopilotToStation:, ShipEntity::fireMissileWithIdentifier:andTarget:, Universe::firstEntityTargetedByPlayerPrecisely, PlayerEntity::getDestroyedBy:damageType:, OOMesh(Private)::getNormal:andTangent:forVertex:inSmoothGroup:, ShipEntity::getWeaponOffsetFrom:withKey:inMode:, HeadUpDisplay::hudRotateViewpointForVirtualDepth, OOMesh::init, OOSoundSource::init, Octree::isHitByLine:v0:, PlayerEntity::leaveDock:, PlayerEntity::leaveWitchspace, ShipEntity::missileTrackPrimaryTarget:, OODebugDrawBasisAtOrigin(), OODebugDrawColoredVectorAtOrigin(), OODebugDrawNormalAtOrigin(), OODebugDrawVectorAtOrigin(), PlayerEntity(OOPrivate)::performInFlightUpdates:, PlayerShipSetCustomView(), StationEntity::portUpVectorForShip:, ShipEntity::positionOffsetForAlignment:, ShipEntity::positionOffsetForShipInRotationToAlignment, Octree::randomPoint, ShipEntity(Private)::refreshEscortPositions, OOExhaustPlumeEntity::resetPlume, PlayerEntity::setCustomViewDataFromDictionary:withScaling:, PlayerEntity::setDefaultViewOffsets, ShipEntity::setEvasiveJink:, PlayerEntity::setUpAndConfirmOK:saveGame:, OOVisualEffectEntity::setUpVisualEffectFromDictionary:, SystemSetPopulator(), ShipEntity::trackDestination:delta_t:, ShipEntity::trackPrimaryTarget:delta_t:, ShipEntity::trackSideTarget:delta_t:, ShipEntity::update:, OOShipRegistry(OODataLoader)::validateNewStyleFlasherDeclaration:forShip:fatalError:, OOShipRegistry(OODataLoader)::validateNewStyleStandardSubentityDeclaration:forShip:fatalError:, Verify_Vector(), PlayerEntity::viewpointOffset, PlayerEntity::weaponViewOffset, and ShipEntity::witchspaceLeavingEffects.

◆ kZeroVector2D

const Vector2D kZeroVector2D = { 0.0f, 0.0f }

Definition at line 33 of file OOVector.m.

33{ 0.0f, 0.0f };