30#ifndef PXFOUNDATION_PXVEC3_H
31#define PXFOUNDATION_PXVEC3_H
37#include "foundation/PxMath.h"
114 PX_SHARED_ASSERT(index <= 2);
116 return reinterpret_cast<float*
>(
this)[index];
124 PX_SHARED_ASSERT(index <= 2);
126 return reinterpret_cast<const float*
>(
this)[index];
134 return x == v.x && y == v.y && z == v.z;
142 return x != v.x || y != v.y || z != v.z;
150 return x == 0.0f && y == 0.0f && z == 0.0f;
166 const float unitTolerance = 1e-4f;
177 return x * x + y * y + z * z;
193 return PxVec3(-x, -y, -z);
201 return PxVec3(x + v.x, y + v.y, z + v.z);
209 return PxVec3(x - v.x, y - v.y, z - v.z);
217 return PxVec3(x * f, y * f, z * f);
226 return PxVec3(x * f, y * f, z * f);
278 return x * v.x + y * v.y + z * v.z;
286 return PxVec3(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
315 if(mag < PX_NORMALIZATION_EPSILON)
328 PX_SHARED_ASSERT(mag >= PX_NORMALIZATION_EPSILON);
338 return PxVec3(x * a.x, y * a.y, z * a.z);
384PX_CUDA_CALLABLE
static PX_FORCE_INLINE PxVec3 operator*(
float f,
const PxVec3& v)
386 return PxVec3(f * v.x, f * v.y, f * v.z);
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE bool operator!=(const PxVec3 &v) const
returns true if the two vectors are not exactly equal.
Definition PxVec3.h:140
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3()
default constructor leaves data uninitialized.
Definition PxVec3.h:55
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition PxVec3.h:276
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 operator/(float f) const
scalar division
Definition PxVec3.h:223
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 cross(const PxVec3 &v) const
cross product
Definition PxVec3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getNormalized() const
Definition PxVec3.h:291
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 operator+(const PxVec3 &v) const
vector addition
Definition PxVec3.h:199
PX_CUDA_CALLABLE PX_FORCE_INLINE const float & operator[](unsigned int index) const
element access
Definition PxVec3.h:122
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 operator*(float f) const
scalar post-multiplication
Definition PxVec3.h:215
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3(float a)
Assigns scalar parameter to all elements.
Definition PxVec3.h:74
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 multiply(const PxVec3 &a) const
a[i] * b[i], for all i.
Definition PxVec3.h:336
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 & operator-=(const PxVec3 &v)
vector difference
Definition PxVec3.h:243
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 & operator+=(const PxVec3 &v)
vector addition
Definition PxVec3.h:232
PX_CUDA_CALLABLE PX_FORCE_INLINE float minElement() const
returns MIN(x, y, z);
Definition PxVec3.h:352
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 operator-() const
negation
Definition PxVec3.h:191
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3(const PxVec3 &v)
Copy ctor.
Definition PxVec3.h:92
PX_CUDA_CALLABLE PX_FORCE_INLINE float maxElement() const
returns MAX(x, y, z);
Definition PxVec3.h:368
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 abs() const
returns absolute values of components;
Definition PxVec3.h:376
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 maximum(const PxVec3 &v) const
element-wise maximum
Definition PxVec3.h:360
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 operator-(const PxVec3 &v) const
vector difference
Definition PxVec3.h:207
PX_CUDA_CALLABLE PX_FORCE_INLINE float magnitudeSquared() const
returns the squared magnitude
Definition PxVec3.h:175
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 & operator/=(float f)
scalar division
Definition PxVec3.h:264
PX_CUDA_CALLABLE PX_FORCE_INLINE bool operator==(const PxVec3 &v) const
returns true if the two vectors are exactly equal.
Definition PxVec3.h:132
PX_CUDA_CALLABLE PX_FORCE_INLINE float normalize()
normalizes the vector in place
Definition PxVec3.h:300
PX_CUDA_CALLABLE PX_FORCE_INLINE float normalizeFast()
normalizes the vector in place. Asserts if vector magnitude is under PX_NORMALIZATION_EPSILON....
Definition PxVec3.h:325
PX_CUDA_CALLABLE PX_FORCE_INLINE float magnitude() const
returns the magnitude
Definition PxVec3.h:183
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition PxVec3.h:156
PX_CUDA_CALLABLE PX_FORCE_INLINE float normalizeSafe()
normalizes the vector in place. Does nothing if vector magnitude is under PX_NORMALIZATION_EPSILON....
Definition PxVec3.h:312
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3(PxZERO r)
zero constructor.
Definition PxVec3.h:62
PX_CUDA_CALLABLE PX_FORCE_INLINE float & operator[](unsigned int index)
element access
Definition PxVec3.h:112
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 & operator*=(float f)
scalar multiplication
Definition PxVec3.h:254
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 & operator=(const PxVec3 &p)
Assignment operator.
Definition PxVec3.h:101
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 minimum(const PxVec3 &v) const
element-wise minimum
Definition PxVec3.h:344
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isZero() const
tests for exact zero vector
Definition PxVec3.h:148
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3(float nx, float ny, float nz)
Initializes from 3 scalar parameters.
Definition PxVec3.h:85
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isNormalized() const
is normalized - used by API parameter validation
Definition PxVec3.h:164
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxRecipSqrt(float a)
reciprocal square root.
Definition PxMath.h:158
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF,...
Definition PxMath.h:326
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxSqrt(float a)
Square root.
Definition PxMath.h:146
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMax(T a, T b)
The return value is the greater of the two specified values.
Definition PxMath.h:72
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88