30#ifndef PXFOUNDATION_PXMAT44_H
31#define PXFOUNDATION_PXMAT44_H
36#include "foundation/PxQuat.h"
37#include "foundation/PxVec4.h"
38#include "foundation/PxMat33.h"
39#include "foundation/PxTransform.h"
64 : column0(1.0f, 0.0f, 0.0f, 0.0f)
65 , column1(0.0f, 1.0f, 0.0f, 0.0f)
66 , column2(0.0f, 0.0f, 1.0f, 0.0f)
67 , column3(0.0f, 0.0f, 0.0f, 1.0f)
80 : column0(col0), column1(col1), column2(col2), column3(col3)
86 : column0(r, 0.0f, 0.0f, 0.0f)
87 , column1(0.0f, r, 0.0f, 0.0f)
88 , column2(0.0f, 0.0f, r, 0.0f)
89 , column3(0.0f, 0.0f, 0.0f, r)
95 : column0(col0, 0), column1(col1, 0), column2(col2, 0), column3(col3, 1.0f)
101 : column0(values[0], values[1], values[2], values[3])
102 , column1(values[4], values[5], values[6], values[7])
103 , column2(values[8], values[9], values[10], values[11])
104 , column3(values[12], values[13], values[14], values[15])
116 const float x2 = x + x;
117 const float y2 = y + y;
118 const float z2 = z + z;
120 const float xx = x2 * x;
121 const float yy = y2 * y;
122 const float zz = z2 * z;
124 const float xy = x2 * y;
125 const float xz = x2 * z;
126 const float xw = x2 * w;
128 const float yz = y2 * z;
129 const float yw = y2 * w;
130 const float zw = z2 * w;
132 column0 =
PxVec4(1.0f - yy - zz, xy + zw, xz - yw, 0.0f);
133 column1 =
PxVec4(xy - zw, 1.0f - xx - zz, yz + xw, 0.0f);
134 column2 =
PxVec4(xz + yw, yz - xw, 1.0f - xx - yy, 0.0f);
135 column3 =
PxVec4(0.0f, 0.0f, 0.0f, 1.0f);
140 : column0(diagonal.x, 0.0f, 0.0f, 0.0f)
141 , column1(0.0f, diagonal.y, 0.0f, 0.0f)
142 , column2(0.0f, 0.0f, diagonal.z, 0.0f)
143 , column3(0.0f, 0.0f, 0.0f, diagonal.w)
149 : column0(axes.column0, 0.0f), column1(axes.column1, 0.0f), column2(axes.column2, 0.0f), column3(position, 1.0f)
163 return column0 == m.column0 && column1 == m.column1 && column2 == m.column2 && column3 == m.column3;
168 : column0(other.column0), column1(other.column1), column2(other.column2), column3(other.column3)
175 column0 = other.column0;
176 column1 = other.column1;
177 column2 = other.column2;
178 column3 = other.column3;
186 PxVec4(column0.x, column1.x, column2.x, column3.x),
PxVec4(column0.y, column1.y, column2.y, column3.y),
187 PxVec4(column0.z, column1.z, column2.z, column3.z),
PxVec4(column0.w, column1.w, column2.w, column3.w));
193 return PxMat44(-column0, -column1, -column2, -column3);
199 return PxMat44(column0 + other.column0, column1 + other.column1, column2 + other.column2,
200 column3 + other.column3);
206 return PxMat44(column0 - other.column0, column1 - other.column1, column2 - other.column2,
207 column3 - other.column3);
213 return PxMat44(column0 * scalar, column1 * scalar, column2 * scalar, column3 * scalar);
232 column0 += other.column0;
233 column1 += other.column1;
234 column2 += other.column2;
235 column3 += other.column3;
242 column0 -= other.column0;
243 column1 -= other.column1;
244 column2 -= other.column2;
245 column3 -= other.column3;
262 *
this = *
this * other;
269 return (*
this)[col][row];
275 return (*
this)[col][row];
281 return column0 * other.x + column1 * other.y + column2 * other.z + column3 * other.w;
293 return column0 * other.x + column1 * other.y + column2 * other.z;
304 PX_SHARED_ASSERT(num >= 0 && num < 3);
305 return (&column0)[num].getXYZ();
308 PX_CUDA_CALLABLE
PX_INLINE const PxVec3 getPosition()
const
310 return column3.getXYZ();
313 PX_CUDA_CALLABLE
PX_INLINE void setPosition(
const PxVec3& position)
315 column3.x = position.x;
316 column3.y = position.y;
317 column3.z = position.z;
327 return (&column0)[num];
329 PX_CUDA_CALLABLE
PX_FORCE_INLINE const PxVec4& operator[](
unsigned int num)
const
331 return (&column0)[num];
334 PX_CUDA_CALLABLE
PX_INLINE void scale(
const PxVec4& p)
344 PxVec3 r0(column0.x, column1.x, column2.x), r1(column0.y, column1.y, column2.y),
345 r2(column0.z, column1.z, column2.z);
347 return PxMat44(r0, r1, r2, -(r0 * column3.x + r1 * column3.y + r2 * column3.z));
350 PX_CUDA_CALLABLE
PX_INLINE bool isFinite()
const
357 PxVec4 column0, column1, column2, column3;
361PX_CUDA_CALLABLE
PX_FORCE_INLINE PxTransform::PxTransform(
const PxMat44& m)
363 PxVec3 column0 = PxVec3(m.column0.x, m.column0.y, m.column0.z);
364 PxVec3 column1 = PxVec3(m.column1.x, m.column1.y, m.column1.z);
365 PxVec3 column2 = PxVec3(m.column2.x, m.column2.y, m.column2.z);
367 q = PxQuat(PxMat33(column0, column1, column2));
368 p = PxVec3(m.column3.x, m.column3.y, m.column3.z);
3x3 matrix class
Definition PxMat33.h:91
4x4 matrix class
Definition PxMat44.h:55
PX_CUDA_CALLABLE PX_INLINE PxMat44 & operator+=(const PxMat44 &other)
Equals-add.
Definition PxMat44.h:230
PX_CUDA_CALLABLE PX_INLINE PxMat44(float values[])
Construct from float[16].
Definition PxMat44.h:100
PX_CUDA_CALLABLE PX_FORCE_INLINE float operator()(unsigned int row, unsigned int col) const
Element access, mathematical way!
Definition PxMat44.h:267
PX_CUDA_CALLABLE PX_INLINE const PxMat44 operator-(const PxMat44 &other) const
Subtract.
Definition PxMat44.h:204
PX_CUDA_CALLABLE PX_INLINE PxMat44(const PxMat44 &other)
Copy constructor.
Definition PxMat44.h:167
PX_CUDA_CALLABLE PX_INLINE const PxVec3 transform(const PxVec3 &other) const
Transform vector by matrix, equal to v' = M*v.
Definition PxMat44.h:285
PX_CUDA_CALLABLE PX_INLINE PxMat44 & operator*=(float scalar)
Equals scalar multiplication.
Definition PxMat44.h:250
PX_CUDA_CALLABLE PxMat44(const PxMat33 &axes, const PxVec3 &position)
Construct from Mat33 and a translation.
Definition PxMat44.h:148
PX_CUDA_CALLABLE PX_INLINE const PxVec3 rotate(const PxVec3 &other) const
Rotate vector by matrix, equal to v' = M*v.
Definition PxMat44.h:297
PX_CUDA_CALLABLE PxMat44(const PxVec3 &col0, const PxVec3 &col1, const PxVec3 &col2, const PxVec3 &col3)
Construct from three base vectors and a translation.
Definition PxMat44.h:94
PX_CUDA_CALLABLE PxMat44(const PxVec4 &col0, const PxVec4 &col1, const PxVec4 &col2, const PxVec4 &col3)
Construct from four 4-vectors.
Definition PxMat44.h:79
PX_CUDA_CALLABLE PX_INLINE PxMat44 & operator=(const PxMat44 &other)
Assignment operator.
Definition PxMat44.h:173
PX_CUDA_CALLABLE PX_INLINE PxMat44 & operator-=(const PxMat44 &other)
Equals-sub.
Definition PxMat44.h:240
PX_CUDA_CALLABLE PX_INLINE const PxMat44 getTranspose() const
Get transposed matrix.
Definition PxMat44.h:183
PX_CUDA_CALLABLE PX_INLINE PxMat44()
Default constructor.
Definition PxMat44.h:58
PX_CUDA_CALLABLE PX_INLINE const PxMat44 operator-() const
Unary minus.
Definition PxMat44.h:191
PX_CUDA_CALLABLE PX_INLINE const PxMat44 operator*(const PxMat44 &other) const
Matrix multiplication.
Definition PxMat44.h:219
PX_CUDA_CALLABLE PX_INLINE PxMat44(const PxQuat &q)
Construct from a quaternion.
Definition PxMat44.h:109
PX_CUDA_CALLABLE PX_INLINE const PxVec4 rotate(const PxVec4 &other) const
Rotate vector by matrix, equal to v' = M*v.
Definition PxMat44.h:291
PX_CUDA_CALLABLE PX_INLINE PxMat44 & operator*=(const PxMat44 &other)
Equals matrix multiplication.
Definition PxMat44.h:260
PX_CUDA_CALLABLE PX_INLINE const PxVec4 transform(const PxVec4 &other) const
Transform vector by matrix, equal to v' = M*v.
Definition PxMat44.h:279
PX_CUDA_CALLABLE PX_INLINE PxMat44(float r)
constructor that generates a multiple of the identity matrix
Definition PxMat44.h:85
PX_CUDA_CALLABLE PX_INLINE const PxMat44 operator+(const PxMat44 &other) const
Add.
Definition PxMat44.h:197
PX_CUDA_CALLABLE PX_FORCE_INLINE float & operator()(unsigned int row, unsigned int col)
Element access, mathematical way!
Definition PxMat44.h:273
PX_CUDA_CALLABLE PX_INLINE PxMat44(PxIDENTITY r)
identity constructor
Definition PxMat44.h:63
PX_CUDA_CALLABLE PX_INLINE const PxMat44 operator*(float scalar) const
Scalar multiplication.
Definition PxMat44.h:211
PX_CUDA_CALLABLE PX_INLINE PxMat44(const PxVec4 &diagonal)
Construct from a diagonal vector.
Definition PxMat44.h:139
PX_CUDA_CALLABLE PX_INLINE PxMat44(PxZERO r)
zero constructor
Definition PxMat44.h:73
PX_CUDA_CALLABLE PX_INLINE bool operator==(const PxMat44 &m) const
returns true if the two matrices are exactly equal
Definition PxMat44.h:161
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
3 Element vector class.
Definition PxVec3.h:50
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
#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