24 for (
uint r = 0; r < Rows; ++r)
31 template <
class OtherVector>
34 for (
uint r = 0; r < inNumRows; ++r)
35 mF32[inDestRow + r] = inV[inSourceRow + r];
39 inline float operator [] (
uint inCoordinate)
const
42 return mF32[inCoordinate];
45 inline float & operator [] (
uint inCoordinate)
48 return mF32[inCoordinate];
52 inline bool operator == (
const Vector &inV2)
const
54 for (
uint r = 0; r < Rows; ++r)
55 if (mF32[r] != inV2.
mF32[r])
60 inline bool operator != (
const Vector &inV2)
const
62 for (
uint r = 0; r < Rows; ++r)
63 if (mF32[r] != inV2.
mF32[r])
71 for (
uint r = 0; r < Rows; ++r)
80 return (inV2 - *
this).LengthSq() <= inMaxDistSq;
86 for (
uint r = 0; r < Rows; ++r)
87 mF32[r] = inV2.
mF32[r];
95 for (
uint r = 0; r < Rows; ++r)
96 v.
mF32[r] = mF32[r] * inV2;
100 inline Vector & operator *= (
const float inV2)
102 for (
uint r = 0; r < Rows; ++r)
114 inline Vector operator / (
float inV2)
const
117 for (
uint r = 0; r < Rows; ++r)
118 v.
mF32[r] = mF32[r] / inV2;
124 for (
uint r = 0; r < Rows; ++r)
133 for (
uint r = 0; r < Rows; ++r)
140 for (
uint r = 0; r < Rows; ++r)
141 mF32[r] += inV2.
mF32[r];
149 for (
uint r = 0; r < Rows; ++r)
150 v.
mF32[r] = -mF32[r];
158 for (
uint r = 0; r < Rows; ++r)
165 for (
uint r = 0; r < Rows; ++r)
166 mF32[r] -= inV2.
mF32[r];
174 for (
uint r = 0; r < Rows; ++r)
175 dot += mF32[r] * inV2.
mF32[r];
188 return sqrt(LengthSq());
194 return abs(LengthSq() - 1.0f) <= inToleranceSq;
200 return *
this / Length();
204 friend ostream & operator << (ostream &inStream,
const Vector &inV)
207 for (
uint i = 0; i < Rows - 1; ++i)
208 inStream << inV.
mF32[i] <<
", ";
209 inStream << inV.
mF32[Rows - 1] <<
"]";
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition: DVec3.inl:447
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
Templatized vector class.
Definition: Vector.h:12
void SetZero()
Vector with all zeros.
Definition: Vector.h:22
Vector Normalized() const
Normalize vector.
Definition: Vector.h:198
bool IsNormalized(float inToleranceSq=1.0e-6f)
Check if vector is normalized.
Definition: Vector.h:192
float Length() const
Length of vector.
Definition: Vector.h:186
uint GetRows() const
Dimensions.
Definition: Vector.h:19
float mF32[Rows]
Definition: Vector.h:213
bool IsZero() const
Test if vector consists of all zeros.
Definition: Vector.h:69
void CopyPart(const OtherVector &inV, uint inSourceRow, uint inNumRows, uint inDestRow)
Copy a (part) of another vector into this vector.
Definition: Vector.h:32
Vector()=default
Constructor.
float Dot(const Vector &inV2) const
Dot product.
Definition: Vector.h:171
static Vector sZero()
Definition: Vector.h:28
Vector(const Vector &inRHS)
Definition: Vector.h:16
bool IsClose(const Vector &inV2, float inMaxDistSq=1.0e-12f)
Test if two vectors are close to each other.
Definition: Vector.h:78
float LengthSq() const
Squared length of vector.
Definition: Vector.h:180