30#ifndef PXFOUNDATION_PXMAT33_H
31#define PXFOUNDATION_PXMAT33_H
36#include "foundation/PxVec3.h"
37#include "foundation/PxQuat.h"
100 : column0(1.0f, 0.0f, 0.0f), column1(0.0f, 1.0f, 0.0f), column2(0.0f, 0.0f, 1.0f)
113 : column0(col0), column1(col1), column2(col2)
119 : column0(r, 0.0f, 0.0f), column1(0.0f, r, 0.0f), column2(0.0f, 0.0f, r)
125 : column0(values[0], values[1], values[2])
126 , column1(values[3], values[4], values[5])
127 , column2(values[6], values[7], values[8])
139 const float x2 = x + x;
140 const float y2 = y + y;
141 const float z2 = z + z;
143 const float xx = x2 * x;
144 const float yy = y2 * y;
145 const float zz = z2 * z;
147 const float xy = x2 * y;
148 const float xz = x2 * z;
149 const float xw = x2 * w;
151 const float yz = y2 * z;
152 const float yw = y2 * w;
153 const float zw = z2 * w;
155 column0 =
PxVec3(1.0f - yy - zz, xy + zw, xz - yw);
156 column1 =
PxVec3(xy - zw, 1.0f - xx - zz, yz + xw);
157 column2 =
PxVec3(xz + yw, yz - xw, 1.0f - xx - yy);
162 : column0(other.column0), column1(other.column1), column2(other.column2)
169 column0 = other.column0;
170 column1 = other.column1;
171 column2 = other.column2;
186 return column0 == m.column0 && column1 == m.column1 && column2 == m.column2;
192 const PxVec3 v0(column0.x, column1.x, column2.x);
193 const PxVec3 v1(column0.y, column1.y, column2.y);
194 const PxVec3 v2(column0.z, column1.z, column2.z);
207 const float invDet = 1.0f / det;
209 inverse.column0.x = invDet * (column1.y * column2.z - column2.y * column1.z);
210 inverse.column0.y = invDet * -(column0.y * column2.z - column2.y * column0.z);
211 inverse.column0.z = invDet * (column0.y * column1.z - column0.z * column1.y);
213 inverse.column1.x = invDet * -(column1.x * column2.z - column1.z * column2.x);
214 inverse.column1.y = invDet * (column0.x * column2.z - column0.z * column2.x);
215 inverse.column1.z = invDet * -(column0.x * column1.z - column0.z * column1.x);
217 inverse.column2.x = invDet * (column1.x * column2.y - column1.y * column2.x);
218 inverse.column2.y = invDet * -(column0.x * column2.y - column0.y * column2.x);
219 inverse.column2.z = invDet * (column0.x * column1.y - column1.x * column0.y);
232 return column0.
dot(column1.
cross(column2));
238 return PxMat33(-column0, -column1, -column2);
244 return PxMat33(column0 + other.column0, column1 + other.column1, column2 + other.column2);
250 return PxMat33(column0 - other.column0, column1 - other.column1, column2 - other.column2);
256 return PxMat33(column0 * scalar, column1 * scalar, column2 * scalar);
280 column0 += other.column0;
281 column1 += other.column1;
282 column2 += other.column2;
289 column0 -= other.column0;
290 column1 -= other.column1;
291 column2 -= other.column2;
307 *
this = *
this * other;
314 return (*
this)[col][row];
320 return (*
this)[col][row];
328 return column0 * other.x + column1 * other.y + column2 * other.z;
334 return PxVec3(column0.
dot(other), column1.
dot(other), column2.
dot(other));
344 return (&column0)[num];
346 PX_CUDA_CALLABLE
PX_FORCE_INLINE const PxVec3& operator[](
unsigned int num)
const
348 return (&column0)[num];
353 PxVec3 column0, column1, column2;
361 if(m.column0.x > m.column1.y)
363 float t = 1 + m.column0.x - m.column1.y - m.column2.z;
364 *
this =
PxQuat(t, m.column0.y + m.column1.x, m.column2.x + m.column0.z, m.column1.z - m.column2.y) *
369 float t = 1 - m.column0.x + m.column1.y - m.column2.z;
370 *
this =
PxQuat(m.column0.y + m.column1.x, t, m.column1.z + m.column2.y, m.column2.x - m.column0.z) *
376 if(m.column0.x < -m.column1.y)
378 float t = 1 - m.column0.x - m.column1.y + m.column2.z;
379 *
this =
PxQuat(m.column2.x + m.column0.z, m.column1.z + m.column2.y, t, m.column0.y - m.column1.x) *
384 float t = 1 + m.column0.x + m.column1.y + m.column2.z;
385 *
this =
PxQuat(m.column1.z - m.column2.y, m.column2.x - m.column0.z, m.column0.y - m.column1.x, t) *
3x3 matrix class
Definition PxMat33.h:91
PX_CUDA_CALLABLE static PX_INLINE const PxMat33 createDiagonal(const PxVec3 &d)
Construct from diagonal, off-diagonals are zero.
Definition PxMat33.h:176
PX_CUDA_CALLABLE PX_INLINE const PxVec3 operator*(const PxVec3 &vec) const
Matrix vector multiplication (returns 'this->transform(vec)')
Definition PxMat33.h:262
PX_CUDA_CALLABLE PX_INLINE PxMat33(float r)
constructor from a scalar, which generates a multiple of the identity matrix
Definition PxMat33.h:118
PX_CUDA_CALLABLE PX_INLINE PxMat33 & operator+=(const PxMat33 &other)
Equals-add.
Definition PxMat33.h:278
PX_CUDA_CALLABLE PX_INLINE PxMat33(PxIDENTITY r)
identity constructor
Definition PxMat33.h:99
PX_CUDA_CALLABLE PX_INLINE const PxVec3 transformTranspose(const PxVec3 &other) const
Transform vector by matrix transpose, v' = M^t*v.
Definition PxMat33.h:332
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33()
Default constructor.
Definition PxMat33.h:94
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 & operator=(const PxMat33 &other)
Assignment operator.
Definition PxMat33.h:167
PX_CUDA_CALLABLE PX_INLINE const PxMat33 operator+(const PxMat33 &other) const
Add.
Definition PxMat33.h:242
PX_CUDA_CALLABLE PX_INLINE float getDeterminant() const
Get determinant.
Definition PxMat33.h:230
PX_CUDA_CALLABLE PX_FORCE_INLINE float operator()(unsigned int row, unsigned int col) const
Element access, mathematical way!
Definition PxMat33.h:312
PX_CUDA_CALLABLE PX_INLINE PxMat33 & operator-=(const PxMat33 &other)
Equals-sub.
Definition PxMat33.h:287
PX_CUDA_CALLABLE PX_INLINE PxMat33(const PxMat33 &other)
Copy constructor.
Definition PxMat33.h:161
PX_CUDA_CALLABLE PX_INLINE PxMat33 & operator*=(const PxMat33 &other)
Equals matrix multiplication.
Definition PxMat33.h:305
PX_CUDA_CALLABLE PX_INLINE const PxMat33 operator*(float scalar) const
Scalar multiplication.
Definition PxMat33.h:254
PX_CUDA_CALLABLE PX_INLINE PxMat33(float values[])
Construct from float[9].
Definition PxMat33.h:124
PX_CUDA_CALLABLE PX_INLINE const PxMat33 operator-() const
Unary minus.
Definition PxMat33.h:236
PX_CUDA_CALLABLE PX_INLINE const PxMat33 operator-(const PxMat33 &other) const
Subtract.
Definition PxMat33.h:248
PX_CUDA_CALLABLE PX_INLINE PxMat33 & operator*=(float scalar)
Equals scalar multiplication.
Definition PxMat33.h:296
PX_CUDA_CALLABLE PxMat33(const PxVec3 &col0, const PxVec3 &col1, const PxVec3 &col2)
Construct from three base vectors.
Definition PxMat33.h:112
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxMat33 getTranspose() const
Get transposed matrix.
Definition PxMat33.h:190
PX_CUDA_CALLABLE PX_INLINE bool operator==(const PxMat33 &m) const
returns true if the two matrices are exactly equal
Definition PxMat33.h:184
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33(const PxQuat &q)
Construct from a quaternion.
Definition PxMat33.h:132
PX_CUDA_CALLABLE PX_FORCE_INLINE float & operator()(unsigned int row, unsigned int col)
Element access, mathematical way!
Definition PxMat33.h:318
PX_CUDA_CALLABLE PX_INLINE const PxMat33 getInverse() const
Get the real inverse.
Definition PxMat33.h:200
PX_CUDA_CALLABLE PX_INLINE PxMat33(PxZERO r)
zero constructor
Definition PxMat33.h:106
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxMat33 operator*(const PxMat33 &other) const
Matrix multiplication.
Definition PxMat33.h:270
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 transform(const PxVec3 &other) const
Transform vector by matrix, equal to v' = M*v.
Definition PxMat33.h:326
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
float x
Definition PxQuat.h:395
PX_CUDA_CALLABLE PX_FORCE_INLINE PxQuat()
Default constructor, does not do any initialization.
Definition PxQuat.h:55
3 Element vector class.
Definition PxVec3.h:50
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 cross(const PxVec3 &v) const
cross product
Definition PxVec3.h:284
#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