![]() |
Jolt Physics
A multi core friendly Game Physics Engine
|
#include <DVec3.h>
Public Types | |
using | Type = { double mData[4] |
using | TypeArg = const Type & |
using | ArgType = DVec3Arg |
Public Member Functions | |
DVec3 ()=default | |
Constructor. More... | |
DVec3 (const DVec3 &inRHS)=default | |
DVec3 & | operator= (const DVec3 &inRHS)=default |
JPH_INLINE | DVec3 (Vec3Arg inRHS) |
JPH_INLINE | DVec3 (Vec4Arg inRHS) |
JPH_INLINE | DVec3 (TypeArg inRHS) |
JPH_INLINE | DVec3 (double inX, double inY, double inZ) |
Create a vector from 3 components. More... | |
JPH_INLINE | DVec3 (const Double3 &inV) |
Load 3 doubles from memory. More... | |
JPH_INLINE void | StoreDouble3 (Double3 *outV) const |
Store 3 doubles to memory. More... | |
JPH_INLINE | operator Vec3 () const |
Convert to float vector 3 rounding to nearest. More... | |
JPH_INLINE DVec3 | PrepareRoundToZero () const |
Prepare to convert to float vector 3 rounding towards zero (returns DVec3 that can be converted to a Vec3 to get the rounding) More... | |
JPH_INLINE DVec3 | PrepareRoundToInf () const |
Prepare to convert to float vector 3 rounding towards positive/negative inf (returns DVec3 that can be converted to a Vec3 to get the rounding) More... | |
JPH_INLINE Vec3 | ToVec3RoundDown () const |
Convert to float vector 3 rounding down. More... | |
JPH_INLINE Vec3 | ToVec3RoundUp () const |
Convert to float vector 3 rounding up. More... | |
JPH_INLINE int | GetTrues () const |
Store if X is true in bit 0, Y in bit 1, Z in bit 2 and W in bit 3 (true is when highest bit of component is set) More... | |
JPH_INLINE bool | TestAnyTrue () const |
Test if any of the components are true (true is when highest bit of component is set) More... | |
JPH_INLINE bool | TestAllTrue () const |
Test if all components are true (true is when highest bit of component is set) More... | |
JPH_INLINE double | GetX () const |
Get individual components. More... | |
JPH_INLINE double | GetY () const |
JPH_INLINE double | GetZ () const |
JPH_INLINE void | SetX (double inX) |
Set individual components. More... | |
JPH_INLINE void | SetY (double inY) |
JPH_INLINE void | SetZ (double inZ) |
JPH_INLINE void | Set (double inX, double inY, double inZ) |
Set all components. More... | |
JPH_INLINE double | operator[] (uint inCoordinate) const |
Get double component by index. More... | |
JPH_INLINE void | SetComponent (uint inCoordinate, double inValue) |
Set double component by index. More... | |
JPH_INLINE bool | operator== (DVec3Arg inV2) const |
Comparison. More... | |
JPH_INLINE bool | operator!= (DVec3Arg inV2) const |
JPH_INLINE bool | IsClose (DVec3Arg inV2, double inMaxDistSq=1.0e-24) const |
Test if two vectors are close. More... | |
JPH_INLINE bool | IsNearZero (double inMaxDistSq=1.0e-24) const |
Test if vector is near zero. More... | |
JPH_INLINE bool | IsNormalized (double inTolerance=1.0e-12) const |
Test if vector is normalized. More... | |
JPH_INLINE bool | IsNaN () const |
Test if vector contains NaN elements. More... | |
JPH_INLINE DVec3 | operator* (DVec3Arg inV2) const |
Multiply two double vectors (component wise) More... | |
JPH_INLINE DVec3 | operator* (double inV2) const |
Multiply vector with double. More... | |
JPH_INLINE DVec3 | operator/ (double inV2) const |
Divide vector by double. More... | |
JPH_INLINE DVec3 & | operator*= (double inV2) |
Multiply vector with double. More... | |
JPH_INLINE DVec3 & | operator*= (DVec3Arg inV2) |
Multiply vector with vector. More... | |
JPH_INLINE DVec3 & | operator/= (double inV2) |
Divide vector by double. More... | |
JPH_INLINE DVec3 | operator+ (Vec3Arg inV2) const |
Add two vectors (component wise) More... | |
JPH_INLINE DVec3 | operator+ (DVec3Arg inV2) const |
Add two double vectors (component wise) More... | |
JPH_INLINE DVec3 & | operator+= (Vec3Arg inV2) |
Add two vectors (component wise) More... | |
JPH_INLINE DVec3 & | operator+= (DVec3Arg inV2) |
Add two double vectors (component wise) More... | |
JPH_INLINE DVec3 | operator- () const |
Negate. More... | |
JPH_INLINE DVec3 | operator- (Vec3Arg inV2) const |
Subtract two vectors (component wise) More... | |
JPH_INLINE DVec3 | operator- (DVec3Arg inV2) const |
Subtract two double vectors (component wise) More... | |
JPH_INLINE DVec3 & | operator-= (Vec3Arg inV2) |
Subtract two vectors (component wise) More... | |
JPH_INLINE DVec3 & | operator-= (DVec3Arg inV2) |
Subtract two vectors (component wise) More... | |
JPH_INLINE DVec3 | operator/ (DVec3Arg inV2) const |
Divide (component wise) More... | |
JPH_INLINE DVec3 | Abs () const |
Return the absolute value of each of the components. More... | |
JPH_INLINE DVec3 | Reciprocal () const |
Reciprocal vector (1 / value) for each of the components. More... | |
JPH_INLINE DVec3 | Cross (DVec3Arg inV2) const |
Cross product. More... | |
JPH_INLINE double | Dot (DVec3Arg inV2) const |
Dot product. More... | |
JPH_INLINE double | LengthSq () const |
Squared length of vector. More... | |
JPH_INLINE double | Length () const |
Length of vector. More... | |
JPH_INLINE DVec3 | Normalized () const |
Normalize vector. More... | |
JPH_INLINE DVec3 | Sqrt () const |
Component wise square root. More... | |
JPH_INLINE DVec3 | GetSign () const |
Get vector that contains the sign of each element (returns 1 if positive, -1 if negative) More... | |
JPH_INLINE void | CheckW () const |
Internal helper function that checks that W is equal to Z, so e.g. dividing by it should not generate div by 0. More... | |
Static Public Member Functions | |
static JPH_INLINE DVec3 | sZero () |
Vector with all zeros. More... | |
static JPH_INLINE DVec3 | sAxisX () |
Vectors with the principal axis. More... | |
static JPH_INLINE DVec3 | sAxisY () |
static JPH_INLINE DVec3 | sAxisZ () |
static JPH_INLINE DVec3 | sReplicate (double inV) |
Replicate inV across all components. More... | |
static JPH_INLINE DVec3 | sNaN () |
Vector with all NaN's. More... | |
static JPH_INLINE DVec3 | sLoadDouble3Unsafe (const Double3 &inV) |
Load 3 doubles from memory (reads 64 bits extra which it doesn't use) More... | |
static JPH_INLINE DVec3 | sMin (DVec3Arg inV1, DVec3Arg inV2) |
Return the minimum value of each of the components. More... | |
static JPH_INLINE DVec3 | sMax (DVec3Arg inV1, DVec3Arg inV2) |
Return the maximum of each of the components. More... | |
static JPH_INLINE DVec3 | sClamp (DVec3Arg inV, DVec3Arg inMin, DVec3Arg inMax) |
Clamp a vector between min and max (component wise) More... | |
static JPH_INLINE DVec3 | sEquals (DVec3Arg inV1, DVec3Arg inV2) |
Equals (component wise) More... | |
static JPH_INLINE DVec3 | sLess (DVec3Arg inV1, DVec3Arg inV2) |
Less than (component wise) More... | |
static JPH_INLINE DVec3 | sLessOrEqual (DVec3Arg inV1, DVec3Arg inV2) |
Less than or equal (component wise) More... | |
static JPH_INLINE DVec3 | sGreater (DVec3Arg inV1, DVec3Arg inV2) |
Greater than (component wise) More... | |
static JPH_INLINE DVec3 | sGreaterOrEqual (DVec3Arg inV1, DVec3Arg inV2) |
Greater than or equal (component wise) More... | |
static JPH_INLINE DVec3 | sFusedMultiplyAdd (DVec3Arg inMul1, DVec3Arg inMul2, DVec3Arg inAdd) |
Calculates inMul1 * inMul2 + inAdd. More... | |
static JPH_INLINE DVec3 | sSelect (DVec3Arg inNotSet, DVec3Arg inSet, DVec3Arg inControl) |
Component wise select, returns inNotSet when highest bit of inControl = 0 and inSet when highest bit of inControl = 1. More... | |
static JPH_INLINE DVec3 | sOr (DVec3Arg inV1, DVec3Arg inV2) |
Logical or (component wise) More... | |
static JPH_INLINE DVec3 | sXor (DVec3Arg inV1, DVec3Arg inV2) |
Logical xor (component wise) More... | |
static JPH_INLINE DVec3 | sAnd (DVec3Arg inV1, DVec3Arg inV2) |
Logical and (component wise) More... | |
static JPH_INLINE Type | sFixW (TypeArg inValue) |
Internal helper function that ensures that the Z component is replicated to the W component to prevent divisions by zero. More... | |
Public Attributes | |
union { | |
Type mValue | |
double mF64 [4] | |
}; | |
Static Public Attributes | |
static const double | cTrue = BitCast<double>(~uint64(0)) |
Representations of true and false for boolean operations. More... | |
static const double | cFalse = 0.0 |
Friends | |
JPH_INLINE DVec3 | operator* (double inV1, DVec3Arg inV2) |
Multiply vector with double. More... | |
ostream & | operator<< (ostream &inStream, DVec3Arg inV) |
To String. More... | |
3 component vector of doubles (stored as 4 vectors). Note that we keep the 4th component the same as the 3rd component to avoid divisions by zero when JPH_FLOATING_POINT_EXCEPTIONS_ENABLED defined
using DVec3::ArgType = DVec3Arg |
using DVec3::Type = { double mData[4] |
using DVec3::TypeArg = const Type & |
|
default |
Constructor.
Intentionally not initialized for performance reasons
|
default |
|
explicit |
|
explicit |
|
inline |
DVec3::DVec3 | ( | double | inX, |
double | inY, | ||
double | inZ | ||
) |
Create a vector from 3 components.
|
explicit |
Load 3 doubles from memory.
DVec3 DVec3::Abs | ( | ) | const |
Return the absolute value of each of the components.
void DVec3::CheckW | ( | ) | const |
Internal helper function that checks that W is equal to Z, so e.g. dividing by it should not generate div by 0.
double DVec3::Dot | ( | DVec3Arg | inV2 | ) | const |
Dot product.
DVec3 DVec3::GetSign | ( | ) | const |
Get vector that contains the sign of each element (returns 1 if positive, -1 if negative)
int DVec3::GetTrues | ( | ) | const |
Store if X is true in bit 0, Y in bit 1, Z in bit 2 and W in bit 3 (true is when highest bit of component is set)
|
inline |
Get individual components.
|
inline |
|
inline |
bool DVec3::IsClose | ( | DVec3Arg | inV2, |
double | inMaxDistSq = 1.0e-24 |
||
) | const |
Test if two vectors are close.
bool DVec3::IsNaN | ( | ) | const |
Test if vector contains NaN elements.
bool DVec3::IsNearZero | ( | double | inMaxDistSq = 1.0e-24 | ) | const |
Test if vector is near zero.
bool DVec3::IsNormalized | ( | double | inTolerance = 1.0e-12 | ) | const |
Test if vector is normalized.
double DVec3::Length | ( | ) | const |
Length of vector.
double DVec3::LengthSq | ( | ) | const |
Squared length of vector.
DVec3 DVec3::Normalized | ( | ) | const |
Normalize vector.
|
explicit |
Convert to float vector 3 rounding to nearest.
|
inline |
DVec3 DVec3::operator* | ( | double | inV2 | ) | const |
Multiply vector with double.
DVec3 & DVec3::operator*= | ( | double | inV2 | ) |
Multiply vector with double.
DVec3 DVec3::operator- | ( | ) | const |
Negate.
DVec3 DVec3::operator/ | ( | double | inV2 | ) | const |
Divide vector by double.
DVec3 & DVec3::operator/= | ( | double | inV2 | ) |
Divide vector by double.
bool DVec3::operator== | ( | DVec3Arg | inV2 | ) | const |
Comparison.
|
inline |
Get double component by index.
DVec3 DVec3::PrepareRoundToInf | ( | ) | const |
DVec3 DVec3::PrepareRoundToZero | ( | ) | const |
DVec3 DVec3::Reciprocal | ( | ) | const |
Reciprocal vector (1 / value) for each of the components.
|
inlinestatic |
Vectors with the principal axis.
|
inlinestatic |
|
inlinestatic |
Clamp a vector between min and max (component wise)
|
inline |
Set all components.
|
inline |
Set double component by index.
|
inline |
Set individual components.
|
inline |
|
inline |
|
static |
Internal helper function that ensures that the Z component is replicated to the W component to prevent divisions by zero.
Calculates inMul1 * inMul2 + inAdd.
Greater than or equal (component wise)
Less than or equal (component wise)
Load 3 doubles from memory (reads 64 bits extra which it doesn't use)
Return the maximum of each of the components.
Return the minimum value of each of the components.
DVec3 DVec3::Sqrt | ( | ) | const |
Component wise square root.
|
static |
Replicate inV across all components.
Component wise select, returns inNotSet when highest bit of inControl = 0 and inSet when highest bit of inControl = 1.
void DVec3::StoreDouble3 | ( | Double3 * | outV | ) | const |
Store 3 doubles to memory.
bool DVec3::TestAllTrue | ( | ) | const |
Test if all components are true (true is when highest bit of component is set)
bool DVec3::TestAnyTrue | ( | ) | const |
Test if any of the components are true (true is when highest bit of component is set)
Vec3 DVec3::ToVec3RoundDown | ( | ) | const |
Convert to float vector 3 rounding down.
Vec3 DVec3::ToVec3RoundUp | ( | ) | const |
Convert to float vector 3 rounding up.
|
friend |
To String.
union { ... } DVec3::@11 |
|
inlinestatic |
Representations of true and false for boolean operations.
double DVec3::mF64[4] |
Type DVec3::mValue |