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

#include <Vec4.h>

Public Types

using Type = { float mData[4]
 

Public Member Functions

 Vec4 ()=default
 Constructor. More...
 
 Vec4 (const Vec4 &inRHS)=default
 
Vec4operator= (const Vec4 &inRHS)=default
 
JPH_INLINE Vec4 (Vec3Arg inRHS)
 WARNING: W component undefined! More...
 
JPH_INLINE Vec4 (Vec3Arg inRHS, float inW)
 
JPH_INLINE Vec4 (Type inRHS)
 
JPH_INLINE Vec4 (float inX, float inY, float inZ, float inW)
 Create a vector from 4 components. More...
 
JPH_INLINE float GetX () const
 Get individual components. More...
 
JPH_INLINE float GetY () const
 
JPH_INLINE float GetZ () const
 
JPH_INLINE float GetW () const
 
JPH_INLINE void SetX (float inX)
 Set individual components. More...
 
JPH_INLINE void SetY (float inY)
 
JPH_INLINE void SetZ (float inZ)
 
JPH_INLINE void SetW (float inW)
 
JPH_INLINE void Set (float inX, float inY, float inZ, float inW)
 Set all components. More...
 
JPH_INLINE float operator[] (uint inCoordinate) const
 Get float component by index. More...
 
JPH_INLINE float & operator[] (uint inCoordinate)
 
JPH_INLINE bool operator== (Vec4Arg inV2) const
 Comparison. More...
 
JPH_INLINE bool operator!= (Vec4Arg inV2) const
 
JPH_INLINE bool IsClose (Vec4Arg inV2, float inMaxDistSq=1.0e-12f) const
 Test if two vectors are close. More...
 
JPH_INLINE bool IsNormalized (float inTolerance=1.0e-6f) const
 Test if vector is normalized. More...
 
JPH_INLINE bool IsNaN () const
 Test if vector contains NaN elements. More...
 
JPH_INLINE Vec4 operator* (Vec4Arg inV2) const
 Multiply two float vectors (component wise) More...
 
JPH_INLINE Vec4 operator* (float inV2) const
 Multiply vector with float. More...
 
JPH_INLINE Vec4 operator/ (float inV2) const
 Divide vector by float. More...
 
JPH_INLINE Vec4operator*= (float inV2)
 Multiply vector with float. More...
 
JPH_INLINE Vec4operator*= (Vec4Arg inV2)
 Multiply vector with vector. More...
 
JPH_INLINE Vec4operator/= (float inV2)
 Divide vector by float. More...
 
JPH_INLINE Vec4 operator+ (Vec4Arg inV2) const
 Add two float vectors (component wise) More...
 
JPH_INLINE Vec4operator+= (Vec4Arg inV2)
 Add two float vectors (component wise) More...
 
JPH_INLINE Vec4 operator- () const
 Negate. More...
 
JPH_INLINE Vec4 operator- (Vec4Arg inV2) const
 Subtract two float vectors (component wise) More...
 
JPH_INLINE Vec4operator-= (Vec4Arg inV2)
 Add two float vectors (component wise) More...
 
JPH_INLINE Vec4 operator/ (Vec4Arg inV2) const
 Divide (component wise) More...
 
template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
JPH_INLINE Vec4 Swizzle () const
 Swizzle the elements in inV. More...
 
JPH_INLINE Vec4 SplatX () const
 Replicate the X component to all components. More...
 
JPH_INLINE Vec4 SplatY () const
 Replicate the Y component to all components. More...
 
JPH_INLINE Vec4 SplatZ () const
 Replicate the Z component to all components. More...
 
JPH_INLINE Vec4 SplatW () const
 Replicate the W component to all components. More...
 
JPH_INLINE Vec4 Abs () const
 Return the absolute value of each of the components. More...
 
JPH_INLINE Vec4 Reciprocal () const
 Reciprocal vector (1 / value) for each of the components. More...
 
JPH_INLINE Vec4 DotV (Vec4Arg inV2) const
 Dot product, returns the dot product in X, Y and Z components. More...
 
JPH_INLINE float Dot (Vec4Arg inV2) const
 Dot product. More...
 
JPH_INLINE float LengthSq () const
 Squared length of vector. More...
 
JPH_INLINE float Length () const
 Length of vector. More...
 
JPH_INLINE Vec4 Normalized () const
 Normalize vector. More...
 
JPH_INLINE void StoreFloat4 (Float4 *outV) const
 Store 4 floats to memory. More...
 
JPH_INLINE UVec4 ToInt () const
 Convert each component from a float to an int. More...
 
JPH_INLINE UVec4 ReinterpretAsInt () const
 Reinterpret Vec4 as a UVec4 (doesn't change the bits) More...
 
JPH_INLINE int GetSignBits () const
 Store if X is negative in bit 0, Y in bit 1, Z in bit 2 and W in bit 3. More...
 
JPH_INLINE float ReduceMin () const
 Get the minimum of X, Y, Z and W. More...
 
JPH_INLINE float ReduceMax () const
 Get the maximum of X, Y, Z and W. More...
 
JPH_INLINE Vec4 Sqrt () const
 Component wise square root. More...
 
JPH_INLINE Vec4 GetSign () const
 Get vector that contains the sign of each element (returns 1.0f if positive, -1.0f if negative) More...
 
void SinCos (Vec4 &outSin, Vec4 &outCos) const
 Calculate the sine and cosine for each element of this vector (input in radians) More...
 
Vec4 Tan () const
 Calculate the tangent for each element of this vector (input in radians) More...
 
Vec4 ASin () const
 
Vec4 ACos () const
 
Vec4 ATan () const
 Calculate the arc tangent for each element of this vector (returns value in the range [-PI / 2, PI / 2]) More...
 
template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
Vec4 Swizzle () const
 
template<const int Scale>
Vec4 sGatherFloat4 (const float *inBase, UVec4Arg inOffsets)
 

Static Public Member Functions

static JPH_INLINE Vec4 sZero ()
 Vector with all zeros. More...
 
static JPH_INLINE Vec4 sNaN ()
 Vector with all NaN's. More...
 
static JPH_INLINE Vec4 sReplicate (float inV)
 Replicate inV across all components. More...
 
static JPH_INLINE Vec4 sLoadFloat4 (const Float4 *inV)
 Load 4 floats from memory. More...
 
static JPH_INLINE Vec4 sLoadFloat4Aligned (const Float4 *inV)
 Load 4 floats from memory, 16 bytes aligned. More...
 
template<const int Scale>
static JPH_INLINE Vec4 sGatherFloat4 (const float *inBase, UVec4Arg inOffsets)
 Gather 4 floats from memory at inBase + inOffsets[i] * Scale. More...
 
static JPH_INLINE Vec4 sMin (Vec4Arg inV1, Vec4Arg inV2)
 Return the minimum value of each of the components. More...
 
static JPH_INLINE Vec4 sMax (Vec4Arg inV1, Vec4Arg inV2)
 Return the maximum of each of the components. More...
 
static JPH_INLINE UVec4 sEquals (Vec4Arg inV1, Vec4Arg inV2)
 Equals (component wise) More...
 
static JPH_INLINE UVec4 sLess (Vec4Arg inV1, Vec4Arg inV2)
 Less than (component wise) More...
 
static JPH_INLINE UVec4 sLessOrEqual (Vec4Arg inV1, Vec4Arg inV2)
 Less than or equal (component wise) More...
 
static JPH_INLINE UVec4 sGreater (Vec4Arg inV1, Vec4Arg inV2)
 Greater than (component wise) More...
 
static JPH_INLINE UVec4 sGreaterOrEqual (Vec4Arg inV1, Vec4Arg inV2)
 Greater than or equal (component wise) More...
 
static JPH_INLINE Vec4 sFusedMultiplyAdd (Vec4Arg inMul1, Vec4Arg inMul2, Vec4Arg inAdd)
 Calculates inMul1 * inMul2 + inAdd. More...
 
static JPH_INLINE Vec4 sSelect (Vec4Arg inV1, Vec4Arg inV2, UVec4Arg inControl)
 Component wise select, returns inV1 when highest bit of inControl = 0 and inV2 when highest bit of inControl = 1. More...
 
static JPH_INLINE Vec4 sOr (Vec4Arg inV1, Vec4Arg inV2)
 Logical or (component wise) More...
 
static JPH_INLINE Vec4 sXor (Vec4Arg inV1, Vec4Arg inV2)
 Logical xor (component wise) More...
 
static JPH_INLINE Vec4 sAnd (Vec4Arg inV1, Vec4Arg inV2)
 Logical and (component wise) More...
 
static JPH_INLINE void sSort4 (Vec4 &ioValue, UVec4 &ioIndex)
 
static JPH_INLINE void sSort4Reverse (Vec4 &ioValue, UVec4 &ioIndex)
 
static Vec4 sATan2 (Vec4Arg inY, Vec4Arg inX)
 Calculate the arc tangent of y / x using the signs of the arguments to determine the correct quadrant (returns value in the range [-PI, PI]) More...
 

Public Attributes

union {
   Type   mValue
 
   float   mF32 [4]
 
}; 
 

Friends

JPH_INLINE Vec4 operator* (float inV1, Vec4Arg inV2)
 Multiply vector with float. More...
 
ostream & operator<< (ostream &inStream, Vec4Arg inV)
 To String. More...
 

Member Typedef Documentation

◆ Type

using Vec4::Type = { float mData[4]

Constructor & Destructor Documentation

◆ Vec4() [1/6]

Vec4::Vec4 ( )
default

Constructor.

Intentionally not initialized for performance reasons

◆ Vec4() [2/6]

Vec4::Vec4 ( const Vec4 inRHS)
default

◆ Vec4() [3/6]

JPH_NAMESPACE_BEGIN Vec4::Vec4 ( Vec3Arg  inRHS)
explicit

WARNING: W component undefined!

◆ Vec4() [4/6]

Vec4::Vec4 ( Vec3Arg  inRHS,
float  inW 
)

◆ Vec4() [5/6]

JPH_INLINE Vec4::Vec4 ( Type  inRHS)
inline

◆ Vec4() [6/6]

Vec4::Vec4 ( float  inX,
float  inY,
float  inZ,
float  inW 
)

Create a vector from 4 components.

Member Function Documentation

◆ Abs()

Vec4 Vec4::Abs ( ) const

Return the absolute value of each of the components.

◆ ACos()

Vec4 Vec4::ACos ( ) const
inline

Calculate the arc cosine for each element of this vector (returns value in the range [0, PI]) Note that all input values will be clamped to the range [-1, 1] and this function will not return NaNs like std::acos

◆ ASin()

Vec4 Vec4::ASin ( ) const
inline

Calculate the arc sine for each element of this vector (returns value in the range [-PI / 2, PI / 2]) Note that all input values will be clamped to the range [-1, 1] and this function will not return NaNs like std::asin

◆ ATan()

Vec4 Vec4::ATan ( ) const
inline

Calculate the arc tangent for each element of this vector (returns value in the range [-PI / 2, PI / 2])

◆ Dot()

float Vec4::Dot ( Vec4Arg  inV2) const

Dot product.

◆ DotV()

Vec4 Vec4::DotV ( Vec4Arg  inV2) const

Dot product, returns the dot product in X, Y and Z components.

◆ GetSign()

Vec4 Vec4::GetSign ( ) const

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

◆ GetSignBits()

int Vec4::GetSignBits ( ) const

Store if X is negative in bit 0, Y in bit 1, Z in bit 2 and W in bit 3.

◆ GetW()

JPH_INLINE float Vec4::GetW ( ) const
inline

◆ GetX()

JPH_INLINE float Vec4::GetX ( ) const
inline

Get individual components.

◆ GetY()

JPH_INLINE float Vec4::GetY ( ) const
inline

◆ GetZ()

JPH_INLINE float Vec4::GetZ ( ) const
inline

◆ IsClose()

bool Vec4::IsClose ( Vec4Arg  inV2,
float  inMaxDistSq = 1.0e-12f 
) const

Test if two vectors are close.

◆ IsNaN()

bool Vec4::IsNaN ( ) const

Test if vector contains NaN elements.

◆ IsNormalized()

bool Vec4::IsNormalized ( float  inTolerance = 1.0e-6f) const

Test if vector is normalized.

◆ Length()

float Vec4::Length ( ) const

Length of vector.

◆ LengthSq()

float Vec4::LengthSq ( ) const

Squared length of vector.

◆ Normalized()

Vec4 Vec4::Normalized ( ) const

Normalize vector.

◆ operator!=()

JPH_INLINE bool Vec4::operator!= ( Vec4Arg  inV2) const
inline

◆ operator*() [1/2]

Vec4 Vec4::operator* ( float  inV2) const

Multiply vector with float.

◆ operator*() [2/2]

Vec4 Vec4::operator* ( Vec4Arg  inV2) const

Multiply two float vectors (component wise)

◆ operator*=() [1/2]

Vec4 & Vec4::operator*= ( float  inV2)

Multiply vector with float.

◆ operator*=() [2/2]

Vec4 & Vec4::operator*= ( Vec4Arg  inV2)

Multiply vector with vector.

◆ operator+()

Vec4 Vec4::operator+ ( Vec4Arg  inV2) const

Add two float vectors (component wise)

◆ operator+=()

Vec4 & Vec4::operator+= ( Vec4Arg  inV2)

Add two float vectors (component wise)

◆ operator-() [1/2]

Vec4 Vec4::operator- ( ) const

Negate.

◆ operator-() [2/2]

Vec4 Vec4::operator- ( Vec4Arg  inV2) const

Subtract two float vectors (component wise)

◆ operator-=()

Vec4 & Vec4::operator-= ( Vec4Arg  inV2)

Add two float vectors (component wise)

◆ operator/() [1/2]

Vec4 Vec4::operator/ ( float  inV2) const

Divide vector by float.

◆ operator/() [2/2]

Vec4 Vec4::operator/ ( Vec4Arg  inV2) const

Divide (component wise)

◆ operator/=()

Vec4 & Vec4::operator/= ( float  inV2)

Divide vector by float.

◆ operator=()

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

◆ operator==()

bool Vec4::operator== ( Vec4Arg  inV2) const

Comparison.

◆ operator[]() [1/2]

JPH_INLINE float & Vec4::operator[] ( uint  inCoordinate)
inline

◆ operator[]() [2/2]

JPH_INLINE float Vec4::operator[] ( uint  inCoordinate) const
inline

Get float component by index.

◆ Reciprocal()

Vec4 Vec4::Reciprocal ( ) const

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

◆ ReduceMax()

float Vec4::ReduceMax ( ) const

Get the maximum of X, Y, Z and W.

◆ ReduceMin()

float Vec4::ReduceMin ( ) const

Get the minimum of X, Y, Z and W.

◆ ReinterpretAsInt()

UVec4 Vec4::ReinterpretAsInt ( ) const

Reinterpret Vec4 as a UVec4 (doesn't change the bits)

◆ sAnd()

Vec4 Vec4::sAnd ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Logical and (component wise)

◆ sATan2()

Vec4 Vec4::sATan2 ( Vec4Arg  inY,
Vec4Arg  inX 
)
inlinestatic

Calculate the arc tangent of y / x using the signs of the arguments to determine the correct quadrant (returns value in the range [-PI, PI])

◆ sEquals()

UVec4 Vec4::sEquals ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Equals (component wise)

◆ Set()

JPH_INLINE void Vec4::Set ( float  inX,
float  inY,
float  inZ,
float  inW 
)
inline

Set all components.

◆ SetW()

JPH_INLINE void Vec4::SetW ( float  inW)
inline

◆ SetX()

JPH_INLINE void Vec4::SetX ( float  inX)
inline

Set individual components.

◆ SetY()

JPH_INLINE void Vec4::SetY ( float  inY)
inline

◆ SetZ()

JPH_INLINE void Vec4::SetZ ( float  inZ)
inline

◆ sFusedMultiplyAdd()

Vec4 Vec4::sFusedMultiplyAdd ( Vec4Arg  inMul1,
Vec4Arg  inMul2,
Vec4Arg  inAdd 
)
static

Calculates inMul1 * inMul2 + inAdd.

◆ sGatherFloat4() [1/2]

template<const int Scale>
static JPH_INLINE Vec4 Vec4::sGatherFloat4 ( const float *  inBase,
UVec4Arg  inOffsets 
)
static

Gather 4 floats from memory at inBase + inOffsets[i] * Scale.

◆ sGatherFloat4() [2/2]

template<const int Scale>
Vec4 Vec4::sGatherFloat4 ( const float *  inBase,
UVec4Arg  inOffsets 
)

◆ sGreater()

UVec4 Vec4::sGreater ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Greater than (component wise)

◆ sGreaterOrEqual()

UVec4 Vec4::sGreaterOrEqual ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Greater than or equal (component wise)

◆ SinCos()

void Vec4::SinCos ( Vec4 outSin,
Vec4 outCos 
) const
inline

Calculate the sine and cosine for each element of this vector (input in radians)

◆ sLess()

UVec4 Vec4::sLess ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Less than (component wise)

◆ sLessOrEqual()

UVec4 Vec4::sLessOrEqual ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Less than or equal (component wise)

◆ sLoadFloat4()

Vec4 Vec4::sLoadFloat4 ( const Float4 inV)
static

Load 4 floats from memory.

◆ sLoadFloat4Aligned()

Vec4 Vec4::sLoadFloat4Aligned ( const Float4 inV)
static

Load 4 floats from memory, 16 bytes aligned.

◆ sMax()

Vec4 Vec4::sMax ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Return the maximum of each of the components.

◆ sMin()

Vec4 Vec4::sMin ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Return the minimum value of each of the components.

◆ sNaN()

Vec4 Vec4::sNaN ( )
static

Vector with all NaN's.

◆ sOr()

Vec4 Vec4::sOr ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Logical or (component wise)

◆ SplatW()

Vec4 Vec4::SplatW ( ) const

Replicate the W component to all components.

◆ SplatX()

Vec4 Vec4::SplatX ( ) const

Replicate the X component to all components.

◆ SplatY()

Vec4 Vec4::SplatY ( ) const

Replicate the Y component to all components.

◆ SplatZ()

Vec4 Vec4::SplatZ ( ) const

Replicate the Z component to all components.

◆ Sqrt()

Vec4 Vec4::Sqrt ( ) const

Component wise square root.

◆ sReplicate()

Vec4 Vec4::sReplicate ( float  inV)
static

Replicate inV across all components.

◆ sSelect()

Vec4 Vec4::sSelect ( Vec4Arg  inV1,
Vec4Arg  inV2,
UVec4Arg  inControl 
)
static

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

◆ sSort4()

void Vec4::sSort4 ( Vec4 ioValue,
UVec4 ioIndex 
)
static

Sort the four elements of ioValue and sort ioIndex at the same time. Based on a sorting network: http://en.wikipedia.org/wiki/Sorting_network

◆ sSort4Reverse()

void Vec4::sSort4Reverse ( Vec4 ioValue,
UVec4 ioIndex 
)
static

Reverse sort the four elements of ioValue (highest first) and sort ioIndex at the same time. Based on a sorting network: http://en.wikipedia.org/wiki/Sorting_network

◆ StoreFloat4()

void Vec4::StoreFloat4 ( Float4 outV) const

Store 4 floats to memory.

◆ Swizzle() [1/2]

template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
JPH_INLINE Vec4 Vec4::Swizzle ( ) const

Swizzle the elements in inV.

◆ Swizzle() [2/2]

template<uint32 SwizzleX, uint32 SwizzleY, uint32 SwizzleZ, uint32 SwizzleW>
Vec4 Vec4::Swizzle ( ) const

◆ sXor()

Vec4 Vec4::sXor ( Vec4Arg  inV1,
Vec4Arg  inV2 
)
static

Logical xor (component wise)

◆ sZero()

Vec4 Vec4::sZero ( )
static

Vector with all zeros.

◆ Tan()

Vec4 Vec4::Tan ( ) const
inline

Calculate the tangent for each element of this vector (input in radians)

◆ ToInt()

UVec4 Vec4::ToInt ( ) const

Convert each component from a float to an int.

Friends And Related Function Documentation

◆ operator*

JPH_INLINE Vec4 operator* ( float  inV1,
Vec4Arg  inV2 
)
friend

Multiply vector with float.

◆ operator<<

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

To String.

Member Data Documentation

◆ 

union { ... } Vec4::@19

◆ mF32

float Vec4::mF32[4]

◆ mValue

Type Vec4::mValue

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