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)
78 inline bool IsClose(
const Vector &inV2,
float inMaxDistSq = 1.0e-12f)
const
80 return (inV2 - *
this).LengthSq() <= inMaxDistSq;
90 for (
uint r = 0; r < Rows; ++r)
91 v.
mF32[r] = mF32[r] * inV2;
95 inline Vector & operator *= (
const float inV2)
97 for (
uint r = 0; r < Rows; ++r)
109 inline Vector operator / (
float inV2)
const
112 for (
uint r = 0; r < Rows; ++r)
113 v.
mF32[r] = mF32[r] / inV2;
119 for (
uint r = 0; r < Rows; ++r)
128 for (
uint r = 0; r < Rows; ++r)
135 for (
uint r = 0; r < Rows; ++r)
136 mF32[r] += inV2.
mF32[r];
144 for (
uint r = 0; r < Rows; ++r)
145 v.
mF32[r] = -mF32[r];
153 for (
uint r = 0; r < Rows; ++r)
160 for (
uint r = 0; r < Rows; ++r)
161 mF32[r] -= inV2.
mF32[r];
169 for (
uint r = 0; r < Rows; ++r)
170 dot += mF32[r] * inV2.
mF32[r];
183 return sqrt(LengthSq());
189 return abs(LengthSq() - 1.0f) <= inToleranceSq;
195 return *
this / Length();
199 friend ostream & operator << (ostream &inStream,
const Vector &inV)
202 for (
uint i = 0; i < Rows - 1; ++i)
203 inStream << inV.
mF32[i] <<
", ";
204 inStream << inV.
mF32[Rows - 1] <<
"]";
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition DVec3.inl:451
#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:193
bool IsNormalized(float inToleranceSq=1.0e-6f)
Check if vector is normalized.
Definition Vector.h:187
bool IsClose(const Vector &inV2, float inMaxDistSq=1.0e-12f) const
Test if two vectors are close to each other.
Definition Vector.h:78
float Length() const
Length of vector.
Definition Vector.h:181
uint GetRows() const
Dimensions.
Definition Vector.h:19
float mF32[Rows]
Definition Vector.h:208
Vector(const Vector &)=default
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:166
static Vector sZero()
Definition Vector.h:28
float LengthSq() const
Squared length of vector.
Definition Vector.h:175