30#ifndef PXFOUNDATION_PXVEC4_H
31#define PXFOUNDATION_PXVEC4_H
35#include "foundation/PxMath.h"
36#include "foundation/PxVec3.h"
37#include "foundation/PxSharedAssert.h"
86 PX_CUDA_CALLABLE
PX_INLINE PxVec4(
float nx,
float ny,
float nz,
float nw) : x(nx), y(ny), z(nz), w(nw)
105 explicit PX_CUDA_CALLABLE
PX_INLINE PxVec4(
const float v[]) : x(v[0]), y(v[1]), z(v[2]), w(v[3])
135 PX_SHARED_ASSERT(index <= 3);
137 return reinterpret_cast<float*
>(
this)[index];
145 PX_SHARED_ASSERT(index <= 3);
147 return reinterpret_cast<const float*
>(
this)[index];
155 return x == v.x && y == v.y && z == v.z && w == v.w;
163 return x != v.x || y != v.y || z != v.z || w != v.w;
171 return x == 0 && y == 0 && z == 0 && w == 0;
187 const float unitTolerance = 1e-4f;
198 return x * x + y * y + z * z + w * w;
214 return PxVec4(-x, -y, -z, -w);
222 return PxVec4(x + v.x, y + v.y, z + v.z, w + v.w);
230 return PxVec4(x - v.x, y - v.y, z - v.z, w - v.w);
239 return PxVec4(x * f, y * f, z * f, w * f);
248 return PxVec4(x * f, y * f, z * f, w * f);
304 return x * v.x + y * v.y + z * v.z + w * v.w;
331 return PxVec4(x * a.x, y * a.y, z * a.z, w * a.w);
360 x = y = z = w = 0.0f;
366PX_CUDA_CALLABLE
static PX_INLINE PxVec4 operator*(
float f,
const PxVec4& v)
368 return PxVec4(f * v.x, f * v.y, f * v.z, f * v.w);
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec4(PxZERO r)
zero constructor.
Definition PxVec4.h:62
PX_CUDA_CALLABLE PX_INLINE PxVec4 & operator/=(float f)
scalar division
Definition PxVec4.h:289
PX_CUDA_CALLABLE PX_INLINE PxVec4 & operator+=(const PxVec4 &v)
vector addition
Definition PxVec4.h:254
PX_CUDA_CALLABLE PX_INLINE PxVec4 operator+(const PxVec4 &v) const
vector addition
Definition PxVec4.h:220
PX_CUDA_CALLABLE PX_INLINE PxVec4 operator-(const PxVec4 &v) const
vector difference
Definition PxVec4.h:228
PX_CUDA_CALLABLE PX_INLINE PxVec4(const PxVec4 &v)
Copy ctor.
Definition PxVec4.h:112
PX_CUDA_CALLABLE PX_INLINE float magnitudeSquared() const
returns the squared magnitude
Definition PxVec4.h:196
PX_CUDA_CALLABLE PX_INLINE bool operator!=(const PxVec4 &v) const
returns true if the two vectors are not exactly equal.
Definition PxVec4.h:161
PX_CUDA_CALLABLE PX_INLINE bool isNormalized() const
is normalized - used by API parameter validation
Definition PxVec4.h:185
PX_CUDA_CALLABLE PX_INLINE float magnitude() const
returns the magnitude
Definition PxVec4.h:204
PX_CUDA_CALLABLE PX_INLINE PxVec4 & operator=(const PxVec4 &p)
Assignment operator.
Definition PxVec4.h:121
PX_CUDA_CALLABLE PX_INLINE PxVec4(const PxVec3 &v, float nw)
Initializes from 3 scalar parameters.
Definition PxVec4.h:96
PX_CUDA_CALLABLE PX_INLINE PxVec4 maximum(const PxVec4 &v) const
element-wise maximum
Definition PxVec4.h:345
PX_CUDA_CALLABLE PX_INLINE bool operator==(const PxVec4 &v) const
returns true if the two vectors are exactly equal.
Definition PxVec4.h:153
PX_CUDA_CALLABLE PX_INLINE PxVec4 & operator-=(const PxVec4 &v)
vector difference
Definition PxVec4.h:266
PX_CUDA_CALLABLE PX_INLINE PxVec4 minimum(const PxVec4 &v) const
element-wise minimum
Definition PxVec4.h:337
PX_CUDA_CALLABLE PX_INLINE bool isZero() const
tests for exact zero vector
Definition PxVec4.h:169
PX_CUDA_CALLABLE PX_INLINE float & operator[](unsigned int index)
element access
Definition PxVec4.h:133
PX_CUDA_CALLABLE PX_INLINE float dot(const PxVec4 &v) const
returns the scalar product of this and other.
Definition PxVec4.h:302
PX_CUDA_CALLABLE PX_INLINE PxVec4 & operator*=(float f)
scalar multiplication
Definition PxVec4.h:278
PX_CUDA_CALLABLE PX_INLINE PxVec4(const float v[])
Initializes from an array of scalar parameters.
Definition PxVec4.h:105
PX_CUDA_CALLABLE PX_INLINE PxVec4()
default constructor leaves data uninitialized.
Definition PxVec4.h:55
PX_CUDA_CALLABLE PX_INLINE PxVec4(float nx, float ny, float nz, float nw)
Initializes from 3 scalar parameters.
Definition PxVec4.h:86
PX_CUDA_CALLABLE PX_INLINE PxVec4 operator*(float f) const
scalar post-multiplication
Definition PxVec4.h:237
PX_CUDA_CALLABLE PX_INLINE void setZero()
set vector elements to zero
Definition PxVec4.h:358
PX_CUDA_CALLABLE PX_INLINE PxVec4(float a)
Assigns scalar parameter to all elements.
Definition PxVec4.h:74
PX_CUDA_CALLABLE PX_INLINE PxVec4 operator/(float f) const
scalar division
Definition PxVec4.h:245
PX_CUDA_CALLABLE PX_INLINE PxVec4 operator-() const
negation
Definition PxVec4.h:212
PX_CUDA_CALLABLE PX_INLINE PxVec4 getNormalized() const
Definition PxVec4.h:309
PX_CUDA_CALLABLE PX_INLINE PxVec4 multiply(const PxVec4 &a) const
a[i] * b[i], for all i.
Definition PxVec4.h:329
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 PxVec4.h:177
PX_CUDA_CALLABLE PX_INLINE const float & operator[](unsigned int index) const
element access
Definition PxVec4.h:143
PX_CUDA_CALLABLE PX_INLINE float normalize()
normalizes the vector in place
Definition PxVec4.h:318
#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