Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
DVec3 Class Reference

#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
 
DVec3operator= (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 DVec3operator*= (double inV2)
 Multiply vector with double. More...
 
JPH_INLINE DVec3operator*= (DVec3Arg inV2)
 Multiply vector with vector. More...
 
JPH_INLINE DVec3operator/= (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 DVec3operator+= (Vec3Arg inV2)
 Add two vectors (component wise) More...
 
JPH_INLINE DVec3operator+= (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 DVec3operator-= (Vec3Arg inV2)
 Add two vectors (component wise) More...
 
JPH_INLINE DVec3operator-= (DVec3Arg inV2)
 Add two double 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 inV1, DVec3Arg inV2, DVec3Arg inControl)
 Component wise select, returns inV1 when highest bit of inControl = 0 and inV2 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...
 

Detailed Description

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

Member Typedef Documentation

◆ ArgType

◆ Type

using DVec3::Type = { double mData[4]

◆ TypeArg

using DVec3::TypeArg = const Type &

Constructor & Destructor Documentation

◆ DVec3() [1/7]

DVec3::DVec3 ( )
default

Constructor.

Intentionally not initialized for performance reasons

◆ DVec3() [2/7]

DVec3::DVec3 ( const DVec3 inRHS)
default

◆ DVec3() [3/7]

JPH_INLINE DVec3::DVec3 ( Vec3Arg  inRHS)
explicit

◆ DVec3() [4/7]

DVec3::DVec3 ( Vec4Arg  inRHS)
explicit

◆ DVec3() [5/7]

JPH_INLINE DVec3::DVec3 ( TypeArg  inRHS)
inline

◆ DVec3() [6/7]

DVec3::DVec3 ( double  inX,
double  inY,
double  inZ 
)

Create a vector from 3 components.

◆ DVec3() [7/7]

DVec3::DVec3 ( const Double3 inV)
explicit

Load 3 doubles from memory.

Member Function Documentation

◆ Abs()

DVec3 DVec3::Abs ( ) const

Return the absolute value of each of the components.

◆ CheckW()

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.

◆ Cross()

DVec3 DVec3::Cross ( DVec3Arg  inV2) const

Cross product.

◆ Dot()

double DVec3::Dot ( DVec3Arg  inV2) const

Dot product.

◆ GetSign()

DVec3 DVec3::GetSign ( ) const

Get vector that contains the sign of each element (returns 1 if positive, -1 if negative)

◆ GetTrues()

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)

◆ GetX()

JPH_INLINE double DVec3::GetX ( ) const
inline

Get individual components.

◆ GetY()

JPH_INLINE double DVec3::GetY ( ) const
inline

◆ GetZ()

JPH_INLINE double DVec3::GetZ ( ) const
inline

◆ IsClose()

bool DVec3::IsClose ( DVec3Arg  inV2,
double  inMaxDistSq = 1.0e-24 
) const

Test if two vectors are close.

◆ IsNaN()

bool DVec3::IsNaN ( ) const

Test if vector contains NaN elements.

◆ IsNearZero()

bool DVec3::IsNearZero ( double  inMaxDistSq = 1.0e-24) const

Test if vector is near zero.

◆ IsNormalized()

bool DVec3::IsNormalized ( double  inTolerance = 1.0e-12) const

Test if vector is normalized.

◆ Length()

double DVec3::Length ( ) const

Length of vector.

◆ LengthSq()

double DVec3::LengthSq ( ) const

Squared length of vector.

◆ Normalized()

DVec3 DVec3::Normalized ( ) const

Normalize vector.

◆ operator Vec3()

DVec3::operator Vec3 ( ) const
explicit

Convert to float vector 3 rounding to nearest.

◆ operator!=()

JPH_INLINE bool DVec3::operator!= ( DVec3Arg  inV2) const
inline

◆ operator*() [1/2]

DVec3 DVec3::operator* ( double  inV2) const

Multiply vector with double.

◆ operator*() [2/2]

DVec3 DVec3::operator* ( DVec3Arg  inV2) const

Multiply two double vectors (component wise)

◆ operator*=() [1/2]

DVec3 & DVec3::operator*= ( double  inV2)

Multiply vector with double.

◆ operator*=() [2/2]

DVec3 & DVec3::operator*= ( DVec3Arg  inV2)

Multiply vector with vector.

◆ operator+() [1/2]

DVec3 DVec3::operator+ ( DVec3Arg  inV2) const

Add two double vectors (component wise)

◆ operator+() [2/2]

DVec3 DVec3::operator+ ( Vec3Arg  inV2) const

Add two vectors (component wise)

◆ operator+=() [1/2]

DVec3 & DVec3::operator+= ( DVec3Arg  inV2)

Add two double vectors (component wise)

◆ operator+=() [2/2]

DVec3 & DVec3::operator+= ( Vec3Arg  inV2)

Add two vectors (component wise)

◆ operator-() [1/3]

DVec3 DVec3::operator- ( ) const

Negate.

◆ operator-() [2/3]

DVec3 DVec3::operator- ( DVec3Arg  inV2) const

Subtract two double vectors (component wise)

◆ operator-() [3/3]

DVec3 DVec3::operator- ( Vec3Arg  inV2) const

Subtract two vectors (component wise)

◆ operator-=() [1/2]

DVec3 & DVec3::operator-= ( DVec3Arg  inV2)

Add two double vectors (component wise)

◆ operator-=() [2/2]

DVec3 & DVec3::operator-= ( Vec3Arg  inV2)

Add two vectors (component wise)

◆ operator/() [1/2]

DVec3 DVec3::operator/ ( double  inV2) const

Divide vector by double.

◆ operator/() [2/2]

DVec3 DVec3::operator/ ( DVec3Arg  inV2) const

Divide (component wise)

◆ operator/=()

DVec3 & DVec3::operator/= ( double  inV2)

Divide vector by double.

◆ operator=()

DVec3 & DVec3::operator= ( const DVec3 inRHS)
default

◆ operator==()

bool DVec3::operator== ( DVec3Arg  inV2) const

Comparison.

◆ operator[]()

JPH_INLINE double DVec3::operator[] ( uint  inCoordinate) const
inline

Get double component by index.

◆ PrepareRoundToInf()

DVec3 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)

◆ PrepareRoundToZero()

DVec3 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)

◆ Reciprocal()

DVec3 DVec3::Reciprocal ( ) const

Reciprocal vector (1 / value) for each of the components.

◆ sAnd()

DVec3 DVec3::sAnd ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Logical and (component wise)

◆ sAxisX()

static JPH_INLINE DVec3 DVec3::sAxisX ( )
inlinestatic

Vectors with the principal axis.

◆ sAxisY()

static JPH_INLINE DVec3 DVec3::sAxisY ( )
inlinestatic

◆ sAxisZ()

static JPH_INLINE DVec3 DVec3::sAxisZ ( )
inlinestatic

◆ sClamp()

DVec3 DVec3::sClamp ( DVec3Arg  inV,
DVec3Arg  inMin,
DVec3Arg  inMax 
)
static

Clamp a vector between min and max (component wise)

◆ sEquals()

DVec3 DVec3::sEquals ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Equals (component wise)

◆ Set()

JPH_INLINE void DVec3::Set ( double  inX,
double  inY,
double  inZ 
)
inline

Set all components.

◆ SetComponent()

JPH_INLINE void DVec3::SetComponent ( uint  inCoordinate,
double  inValue 
)
inline

Set double component by index.

◆ SetX()

JPH_INLINE void DVec3::SetX ( double  inX)
inline

Set individual components.

◆ SetY()

JPH_INLINE void DVec3::SetY ( double  inY)
inline

◆ SetZ()

JPH_INLINE void DVec3::SetZ ( double  inZ)
inline

◆ sFixW()

DVec3::Type DVec3::sFixW ( TypeArg  inValue)
static

Internal helper function that ensures that the Z component is replicated to the W component to prevent divisions by zero.

◆ sFusedMultiplyAdd()

DVec3 DVec3::sFusedMultiplyAdd ( DVec3Arg  inMul1,
DVec3Arg  inMul2,
DVec3Arg  inAdd 
)
static

Calculates inMul1 * inMul2 + inAdd.

◆ sGreater()

DVec3 DVec3::sGreater ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Greater than (component wise)

◆ sGreaterOrEqual()

DVec3 DVec3::sGreaterOrEqual ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Greater than or equal (component wise)

◆ sLess()

DVec3 DVec3::sLess ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Less than (component wise)

◆ sLessOrEqual()

DVec3 DVec3::sLessOrEqual ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Less than or equal (component wise)

◆ sLoadDouble3Unsafe()

DVec3 DVec3::sLoadDouble3Unsafe ( const Double3 inV)
static

Load 3 doubles from memory (reads 64 bits extra which it doesn't use)

◆ sMax()

DVec3 DVec3::sMax ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Return the maximum of each of the components.

◆ sMin()

DVec3 DVec3::sMin ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Return the minimum value of each of the components.

◆ sNaN()

DVec3 DVec3::sNaN ( )
static

Vector with all NaN's.

◆ sOr()

DVec3 DVec3::sOr ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Logical or (component wise)

◆ Sqrt()

DVec3 DVec3::Sqrt ( ) const

Component wise square root.

◆ sReplicate()

DVec3 DVec3::sReplicate ( double  inV)
static

Replicate inV across all components.

◆ sSelect()

DVec3 DVec3::sSelect ( DVec3Arg  inV1,
DVec3Arg  inV2,
DVec3Arg  inControl 
)
static

Component wise select, returns inV1 when highest bit of inControl = 0 and inV2 when highest bit of inControl = 1.

◆ StoreDouble3()

void DVec3::StoreDouble3 ( Double3 outV) const

Store 3 doubles to memory.

◆ sXor()

DVec3 DVec3::sXor ( DVec3Arg  inV1,
DVec3Arg  inV2 
)
static

Logical xor (component wise)

◆ sZero()

DVec3 DVec3::sZero ( )
static

Vector with all zeros.

◆ TestAllTrue()

bool DVec3::TestAllTrue ( ) const

Test if all components are true (true is when highest bit of component is set)

◆ TestAnyTrue()

bool DVec3::TestAnyTrue ( ) const

Test if any of the components are true (true is when highest bit of component is set)

◆ ToVec3RoundDown()

Vec3 DVec3::ToVec3RoundDown ( ) const

Convert to float vector 3 rounding down.

◆ ToVec3RoundUp()

Vec3 DVec3::ToVec3RoundUp ( ) const

Convert to float vector 3 rounding up.

Friends And Related Function Documentation

◆ operator*

JPH_INLINE DVec3 operator* ( double  inV1,
DVec3Arg  inV2 
)
friend

Multiply vector with double.

◆ operator<<

ostream & operator<< ( ostream &  inStream,
DVec3Arg  inV 
)
friend

To String.

Member Data Documentation

◆ 

union { ... } DVec3::@9

◆ cFalse

const double DVec3::cFalse = 0.0
inlinestatic

◆ cTrue

const double DVec3::cTrue = BitCast<double>(~uint64(0))
inlinestatic

Representations of true and false for boolean operations.

◆ mF64

double DVec3::mF64[4]

◆ mValue

Type DVec3::mValue

The documentation for this class was generated from the following files: