35#include "foundation/PxVec3.h"
36#include "foundation/PxQuat.h"
100 column0(Type(1.0), Type(0.0), Type(0.0)),
101 column1(Type(0.0), Type(1.0), Type(0.0)),
102 column2(Type(0.0), Type(0.0), Type(1.0))
124 column0(r, Type(0.0), Type(0.0)),
125 column1(Type(0.0), r, Type(0.0)),
126 column2(Type(0.0), Type(0.0), r)
132 column0(values[0], values[1], values[2]),
133 column1(values[3], values[4], values[5]),
134 column2(values[6], values[7], values[8])
147 const Type x2 = x + x;
148 const Type y2 = y + y;
149 const Type z2 = z + z;
151 const Type xx = x2 * x;
152 const Type yy = y2 * y;
153 const Type zz = z2 * z;
155 const Type xy = x2 * y;
156 const Type xz = x2 * z;
157 const Type xw = x2 * w;
159 const Type yz = y2 * z;
160 const Type yw = y2 * w;
161 const Type zw = z2 * w;
163 column0 =
PxVec3T<Type>(Type(1.0) - yy - zz, xy + zw, xz - yw);
164 column1 =
PxVec3T<Type>(xy - zw, Type(1.0) - xx - zz, yz + xw);
165 column2 =
PxVec3T<Type>(xz + yw, yz - xw, Type(1.0) - xx - yy);
170 column0(other.column0),
171 column1(other.column1),
172 column2(other.column2)
179 column0 = other.column0;
180 column1 = other.column1;
181 column2 = other.column2;
196 return PxMat33T(a * b.x, a * b.y, a * b.z);
204 return column0 == m.column0 && column1 == m.column1 && column2 == m.column2;
225 const Type invDet = Type(1.0) / det;
227 inverse.column0.x = invDet * (column1.y * column2.z - column2.y * column1.z);
228 inverse.column0.y = invDet * -(column0.y * column2.z - column2.y * column0.z);
229 inverse.column0.z = invDet * (column0.y * column1.z - column0.z * column1.y);
231 inverse.column1.x = invDet * -(column1.x * column2.z - column1.z * column2.x);
232 inverse.column1.y = invDet * (column0.x * column2.z - column0.z * column2.x);
233 inverse.column1.z = invDet * -(column0.x * column1.z - column0.z * column1.x);
235 inverse.column2.x = invDet * (column1.x * column2.y - column1.y * column2.x);
236 inverse.column2.y = invDet * -(column0.x * column2.y - column0.y * column2.x);
237 inverse.column2.z = invDet * (column0.x * column1.y - column1.x * column0.y);
250 return column0.dot(column1.cross(column2));
256 return PxMat33T(-column0, -column1, -column2);
262 return PxMat33T(column0 + other.column0, column1 + other.column1, column2 + other.column2);
268 return PxMat33T(column0 - other.column0, column1 - other.column1, column2 - other.column2);
274 return PxMat33T(column0 * scalar, column1 * scalar, column2 * scalar);
277 template<
class Type2>
301 column0 += other.column0;
302 column1 += other.column1;
303 column2 += other.column2;
310 column0 -= other.column0;
311 column1 -= other.column1;
312 column2 -= other.column2;
328 *
this = *
this * other;
335 return (*
this)[col][row];
341 return (*
this)[col][row];
349 return column0 * other.x + column1 * other.y + column2 * other.z;
355 return PxVec3T<Type>(column0.dot(other), column1.dot(other), column2.dot(other));
365 return (&column0)[num];
368 PX_CUDA_CALLABLE
PX_FORCE_INLINE const PxVec3T<Type>& operator[](PxU32 num)
const
370 return (&column0)[num];
375 PxVec3T<Type> column0, column1, column2;
379PX_CUDA_CALLABLE
PX_INLINE PxMat33T<Type> operator*(Type scalar,
const PxMat33T<Type>& m)
381 return PxMat33T<Type>(scalar * m.column0, scalar * m.column1, scalar * m.column2);
388 if(m.column2.z < Type(0))
390 if(m.column0.x > m.column1.y)
392 const Type t = Type(1.0) + m.column0.x - m.column1.y - m.column2.z;
393 *
this =
PxQuatT<Type>(t, m.column0.y + m.column1.x, m.column2.x + m.column0.z, m.column1.z - m.column2.y) * (Type(0.5) /
PxSqrt(t));
397 const Type t = Type(1.0) - m.column0.x + m.column1.y - m.column2.z;
398 *
this =
PxQuatT<Type>(m.column0.y + m.column1.x, t, m.column1.z + m.column2.y, m.column2.x - m.column0.z) * (Type(0.5) /
PxSqrt(t));
403 if(m.column0.x < -m.column1.y)
405 const Type t = Type(1.0) - m.column0.x - m.column1.y + m.column2.z;
406 *
this =
PxQuatT<Type>(m.column2.x + m.column0.z, m.column1.z + m.column2.y, t, m.column0.y - m.column1.x) * (Type(0.5) /
PxSqrt(t));
410 const Type t = Type(1.0) + m.column0.x + m.column1.y + m.column2.z;
411 *
this =
PxQuatT<Type>(m.column1.z - m.column2.y, m.column2.x - m.column0.z, m.column0.y - m.column1.x, t) * (Type(0.5) /
PxSqrt(t));
3x3 matrix class
Definition PxMat33.h:91
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3T< Type > transform(const PxVec3T< Type > &other) const
Transform vector by matrix, equal to v' = M*v.
Definition PxMat33.h:347
PX_CUDA_CALLABLE PX_INLINE const PxVec3T< Type > transformTranspose(const PxVec3T< Type > &other) const
Transform vector by matrix transpose, v' = M^t*v.
Definition PxMat33.h:353
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33T & operator=(const PxMat33T &other)
Assignment operator.
Definition PxMat33.h:177
PX_CUDA_CALLABLE PX_INLINE PxMat33T(Type values[])
Construct from Type[9].
Definition PxMat33.h:131
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxMat33T getTranspose() const
Get transposed matrix.
Definition PxMat33.h:208
PX_CUDA_CALLABLE PX_INLINE const PxMat33T getInverse() const
Get the real inverse.
Definition PxMat33.h:218
PX_CUDA_CALLABLE PX_INLINE PxMat33T(Type r)
constructor from a scalar, which generates a multiple of the identity matrix
Definition PxMat33.h:123
PX_CUDA_CALLABLE static PX_INLINE const PxMat33T outer(const PxVec3T< Type > &a, const PxVec3T< Type > &b)
Computes the outer product of two vectors.
Definition PxMat33.h:194
PX_CUDA_CALLABLE PX_INLINE PxMat33T & operator*=(const PxMat33T &other)
Equals matrix multiplication.
Definition PxMat33.h:326
PX_CUDA_CALLABLE PxMat33T(const PxVec3T< Type > &col0, const PxVec3T< Type > &col1, const PxVec3T< Type > &col2)
Construct from three base vectors.
Definition PxMat33.h:115
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33T()
Default constructor.
Definition PxMat33.h:94
PX_CUDA_CALLABLE PX_INLINE PxMat33T(const PxMat33T &other)
Copy constructor.
Definition PxMat33.h:169
PX_CUDA_CALLABLE PX_INLINE PxMat33T & operator+=(const PxMat33T &other)
Equals-add.
Definition PxMat33.h:299
PX_CUDA_CALLABLE PX_INLINE const PxVec3T< Type > operator*(const PxVec3T< Type > &vec) const
Matrix vector multiplication (returns 'this->transform(vec)')
Definition PxMat33.h:281
PX_CUDA_CALLABLE PX_INLINE PxMat33T & operator*=(Type scalar)
Equals scalar multiplication.
Definition PxMat33.h:317
PX_CUDA_CALLABLE PX_INLINE bool operator==(const PxMat33T &m) const
returns true if the two matrices are exactly equal
Definition PxMat33.h:202
PX_CUDA_CALLABLE PX_INLINE const PxMat33T operator-() const
Unary minus.
Definition PxMat33.h:254
PX_CUDA_CALLABLE PX_INLINE const PxMat33T operator+(const PxMat33T &other) const
Add.
Definition PxMat33.h:260
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxMat33T operator*(const PxMat33T &other) const
Matrix multiplication.
Definition PxMat33.h:289
PX_CUDA_CALLABLE static PX_INLINE const PxMat33T createDiagonal(const PxVec3T< Type > &d)
Construct from diagonal, off-diagonals are zero.
Definition PxMat33.h:186
PX_CUDA_CALLABLE PX_INLINE Type getDeterminant() const
Get determinant.
Definition PxMat33.h:248
PX_CUDA_CALLABLE PX_INLINE const PxMat33T operator-(const PxMat33T &other) const
Subtract.
Definition PxMat33.h:266
PX_CUDA_CALLABLE PX_INLINE const PxMat33T operator*(Type scalar) const
Scalar multiplication.
Definition PxMat33.h:272
PX_CUDA_CALLABLE PX_FORCE_INLINE Type operator()(PxU32 row, PxU32 col) const
Element access, mathematical way!
Definition PxMat33.h:333
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33T(const PxQuatT< Type > &q)
Construct from a quaternion.
Definition PxMat33.h:139
PX_CUDA_CALLABLE PX_INLINE PxMat33T & operator-=(const PxMat33T &other)
Equals-sub.
Definition PxMat33.h:308
PX_CUDA_CALLABLE PX_INLINE PxMat33T(PxZERO)
zero constructor
Definition PxMat33.h:107
PX_CUDA_CALLABLE PX_INLINE PxMat33T(PxIDENTITY)
identity constructor
Definition PxMat33.h:99
PX_CUDA_CALLABLE PX_FORCE_INLINE Type & operator()(PxU32 row, PxU32 col)
Element access, mathematical way!
Definition PxMat33.h:339
3x3 matrix class
Definition PxMat33.h:91
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:49
PX_CUDA_CALLABLE PX_FORCE_INLINE PxQuatT()
Default constructor, does not do any initialization.
Definition PxQuat.h:55
Type x
Definition PxQuat.h:394
3 Element vector class.
Definition PxVec3.h:50
#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
PxIDENTITY
Definition Px.h:99
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxSqrt(float a)
Square root.
Definition PxMath.h:146