Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
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().

+ Here is the call 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 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().

+ Here is the call 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().

+ Here is the call graph for this function:

Variable Documentation

◆ kBasisXVector

const Vector kBasisXVector = { 1.0f, 0.0f, 0.0f }

Definition at line 29 of file OOVector.m.

29{ 1.0f, 0.0f, 0.0f };

Referenced by OOMatrixForBillboard(), and Verify_Vector().

◆ kBasisXVector2D

const Vector2D kBasisXVector2D = { 1.0f, 0.0f }

Definition at line 34 of file OOVector.m.

34{ 1.0f, 0.0f };

◆ kBasisYVector

const Vector kBasisYVector = { 0.0f, 1.0f, 0.0f }

Definition at line 30 of file OOVector.m.

30{ 0.0f, 1.0f, 0.0f };

Referenced by HeadUpDisplay::hudRotateViewpointForVirtualDepth.

◆ kBasisYVector2D

const Vector2D kBasisYVector2D = { 0.0f, 1.0f }

Definition at line 35 of file OOVector.m.

35{ 0.0f, 1.0f };

◆ kBasisZVector

const Vector kBasisZVector = { 0.0f, 0.0f, 1.0f }

Definition at line 31 of file OOVector.m.

31{ 0.0f, 0.0f, 1.0f };

Referenced by OOMatrixForBillboard(), and quaternion_rotation_between().

◆ 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 }};

◆ kZeroVector

◆ kZeroVector2D

const Vector2D kZeroVector2D = { 0.0f, 0.0f }

Definition at line 33 of file OOVector.m.

33{ 0.0f, 0.0f };