25#define vMPPP (_mm_set_ps(+0.0f, +0.0f, +0.0f, -0.0f))
28#if defined(BT_USE_SSE)
29#define v0000 (_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f))
30#define v1000 (_mm_set_ps(0.0f, 0.0f, 0.0f, 1.0f))
31#define v0100 (_mm_set_ps(0.0f, 0.0f, 1.0f, 0.0f))
32#define v0010 (_mm_set_ps(0.0f, 1.0f, 0.0f, 0.0f))
33#elif defined(BT_USE_NEON)
40#ifdef BT_USE_DOUBLE_PRECISION
41#define btMatrix3x3Data btMatrix3x3DoubleData
43#define btMatrix3x3Data btMatrix3x3FloatData
79#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
97 m_el[0].mVec128 =
rhs.m_el[0].mVec128;
98 m_el[1].mVec128 =
rhs.m_el[1].mVec128;
99 m_el[2].mVec128 =
rhs.m_el[2].mVec128;
105 m_el[0].mVec128 =
m.m_el[0].mVec128;
106 m_el[1].mVec128 =
m.m_el[1].mVec128;
107 m_el[2].mVec128 =
m.m_el[2].mVec128;
117 m_el[0] = other.
m_el[0];
118 m_el[1] = other.
m_el[1];
119 m_el[2] = other.
m_el[2];
125 m_el[0] = other.
m_el[0];
126 m_el[1] = other.
m_el[1];
127 m_el[2] = other.
m_el[2];
144 return btVector3(m_el[0][i], m_el[1][i], m_el[2][i]);
221#if defined BT_USE_SIMD_VECTOR3 && defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)
325#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
339#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
352#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
369#if defined BT_USE_SIMD_VECTOR3 && defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)
370 __m128 v0 = m_el[0].mVec128;
371 __m128 v1 = m_el[1].mVec128;
372 __m128 v2 = m_el[2].mVec128;
388#elif defined(BT_USE_NEON)
422#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
435 temp.f[0] = m_el[2].
y() - m_el[1].
z();
436 temp.f[1] = m_el[0].
z() - m_el[2].
x();
437 temp.f[2] = m_el[1].
x() - m_el[0].
y();
444 if (m_el[0].x() < m_el[1].y())
446 if (m_el[1].y() < m_el[2].z())
461 if (m_el[0].x() < m_el[2].z())
475 x = m_el[i][i] - m_el[
j][
j] - m_el[
k][
k] +
btScalar(1.0);
477 temp.f[3] = (m_el[
k][
j] - m_el[
j][
k]);
478 temp.f[
j] = (m_el[
j][i] + m_el[i][
j]);
479 temp.f[
k] = (m_el[
k][i] + m_el[i][
k]);
500 temp[0] = ((m_el[2].
y() - m_el[1].
z()) * s);
501 temp[1] = ((m_el[0].
z() - m_el[2].
x()) * s);
502 temp[2] = ((m_el[1].
x() - m_el[0].
y()) * s);
506 int i = m_el[0].
x() < m_el[1].
y() ? (m_el[1].
y() < m_el[2].
z() ? 2 : 1) : (m_el[0].
x() < m_el[2].
z() ? 2 : 0);
514 temp[3] = (m_el[
k][
j] - m_el[
j][
k]) * s;
515 temp[
j] = (m_el[
j][i] + m_el[i][
j]) * s;
516 temp[
k] = (m_el[
k][i] + m_el[i][
k]) * s;
518 q.setValue(temp[0], temp[1], temp[2], temp[3]);
567 if (
btFabs(m_el[2].x()) >= 1)
624#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
625 return btMatrix3x3(m_el[0] * s, m_el[1] * s, m_el[2] * s);
628 m_el[0].x() * s.
x(), m_el[0].
y() * s.
y(), m_el[0].
z() * s.
z(),
629 m_el[1].
x() * s.
x(), m_el[1].
y() * s.
y(), m_el[1].
z() * s.
z(),
630 m_el[2].
x() * s.
x(), m_el[2].
y() * s.
y(), m_el[2].
z() * s.
z());
671 return m_el[0].
x() * v.
x() + m_el[1].
x() * v.
y() + m_el[2].
x() * v.
z();
675 return m_el[0].
y() * v.
x() + m_el[1].
y() * v.
y() + m_el[2].
y() * v.
z();
679 return m_el[0].
z() * v.
x() + m_el[1].
z() * v.
y() + m_el[2].
z() * v.
z();
696 btVector3 omega = (
R.getColumn(0).cross(
A.getColumn(0)) +
R.getColumn(1).cross(
A.getColumn(1)) +
R.getColumn(2).cross(
A.getColumn(2))) * (
btScalar(1.0) /
btFabs(
R.getColumn(0).dot(
A.getColumn(0)) +
R.getColumn(1).dot(
A.getColumn(1)) +
R.getColumn(2).dot(
A.getColumn(2))) +
774 m_el[p][
q] = m_el[
q][p] = 0;
775 m_el[p][p] -=
t *
mpq;
783 for (
int i = 0; i < 3; i++)
820#if defined BT_USE_SIMD_VECTOR3 && defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)
869#elif defined(BT_USE_NEON)
875 v0 =
m_el[0].mVec128;
876 v1 =
m_el[1].mVec128;
877 v2 =
m_el[2].mVec128;
910#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
911 m_el[0].mVec128 =
m_el[0].mVec128 +
m.m_el[0].mVec128;
912 m_el[1].mVec128 =
m_el[1].mVec128 +
m.m_el[1].mVec128;
913 m_el[2].mVec128 =
m_el[2].mVec128 +
m.m_el[2].mVec128;
916 m_el[0][0] +
m.m_el[0][0],
917 m_el[0][1] +
m.m_el[0][1],
918 m_el[0][2] +
m.m_el[0][2],
919 m_el[1][0] +
m.m_el[1][0],
920 m_el[1][1] +
m.m_el[1][1],
921 m_el[1][2] +
m.m_el[1][2],
922 m_el[2][0] +
m.m_el[2][0],
923 m_el[2][1] +
m.m_el[2][1],
924 m_el[2][2] +
m.m_el[2][2]);
932#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
938#elif defined(BT_USE_NEON)
945 m[0].x() *
k,
m[0].y() *
k,
m[0].z() *
k,
946 m[1].x() *
k,
m[1].y() *
k,
m[1].z() *
k,
947 m[2].x() *
k,
m[2].y() *
k,
m[2].z() *
k);
954#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
971 m1[2][2] +
m2[2][2]);
978#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
995 m1[2][2] -
m2[2][2]);
1002#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
1003 m_el[0].mVec128 =
m_el[0].mVec128 -
m.m_el[0].mVec128;
1004 m_el[1].mVec128 =
m_el[1].mVec128 -
m.m_el[1].mVec128;
1005 m_el[2].mVec128 =
m_el[2].mVec128 -
m.m_el[2].mVec128;
1008 m_el[0][0] -
m.m_el[0][0],
1009 m_el[0][1] -
m.m_el[0][1],
1010 m_el[0][2] -
m.m_el[0][2],
1011 m_el[1][0] -
m.m_el[1][0],
1012 m_el[1][1] -
m.m_el[1][1],
1013 m_el[1][2] -
m.m_el[1][2],
1014 m_el[2][0] -
m.m_el[2][0],
1015 m_el[2][1] -
m.m_el[2][1],
1016 m_el[2][2] -
m.m_el[2][2]);
1024 return btTriple((*
this)[0], (*
this)[1], (*
this)[2]);
1030#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1035#elif defined(BT_USE_NEON)
1051#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1067#elif defined(BT_USE_NEON)
1087 return btMatrix3x3(
cofac(1, 1, 2, 2),
cofac(0, 2, 2, 1),
cofac(0, 1, 1, 2),
1088 cofac(1, 2, 2, 0),
cofac(0, 0, 2, 2),
cofac(0, 2, 1, 0),
1089 cofac(1, 0, 2, 1),
cofac(0, 1, 2, 0),
cofac(0, 0, 1, 1));
1095 btVector3 co(
cofac(1, 1, 2, 2),
cofac(1, 2, 2, 0),
cofac(1, 0, 2, 1));
1101 co.y() * s,
cofac(0, 0, 2, 2) * s,
cofac(0, 2, 1, 0) * s,
1102 co.z() * s,
cofac(0, 1, 2, 0) * s,
cofac(0, 0, 1, 1) * s);
1108#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1128#elif defined BT_USE_NEON
1149 m_el[0].x() *
m[0].x() +
m_el[1].x() *
m[1].x() +
m_el[2].x() *
m[2].x(),
1150 m_el[0].x() *
m[0].y() +
m_el[1].x() *
m[1].y() +
m_el[2].x() *
m[2].y(),
1151 m_el[0].x() *
m[0].z() +
m_el[1].x() *
m[1].z() +
m_el[2].x() *
m[2].z(),
1152 m_el[0].y() *
m[0].x() +
m_el[1].y() *
m[1].x() +
m_el[2].y() *
m[2].x(),
1153 m_el[0].y() *
m[0].y() +
m_el[1].y() *
m[1].y() +
m_el[2].y() *
m[2].y(),
1154 m_el[0].y() *
m[0].z() +
m_el[1].y() *
m[1].z() +
m_el[2].y() *
m[2].z(),
1155 m_el[0].z() *
m[0].x() +
m_el[1].z() *
m[1].x() +
m_el[2].z() *
m[2].x(),
1156 m_el[0].z() *
m[0].y() +
m_el[1].z() *
m[1].y() +
m_el[2].z() *
m[2].y(),
1157 m_el[0].z() *
m[0].z() +
m_el[1].z() *
m[1].z() +
m_el[2].z() *
m[2].z());
1164#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1185#elif defined BT_USE_NEON
1217#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) || defined(BT_USE_NEON)
1218 return v.
dot3(
m[0],
m[1],
m[2]);
1227#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1241#elif defined(BT_USE_NEON)
1267#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1313#elif defined(BT_USE_NEON)
1368#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
1380 return (0x7 == (
m & 0x7));
1383 return (
m1[0][0] ==
m2[0][0] &&
m1[1][0] ==
m2[1][0] &&
m1[2][0] ==
m2[2][0] &&
1384 m1[0][1] ==
m2[0][1] &&
m1[1][1] ==
m2[1][1] &&
m1[2][1] ==
m2[2][1] &&
1385 m1[0][2] ==
m2[0][2] &&
m1[1][2] ==
m2[1][2] &&
m1[2][2] ==
m2[2][2]);
1403 for (
int i = 0; i < 3; i++)
1409 for (
int i = 0; i < 3; i++)
1415 for (
int i = 0; i < 3; i++)
1421 for (
int i = 0; i < 3; i++)
1427 for (
int i = 0; i < 3; i++)
btMatrix3x3 operator*(const btMatrix3x3 &m, const btScalar &k)
bool operator==(const btMatrix3x3 &m1, const btMatrix3x3 &m2)
Equality operator between two matrices It will test all elements are equal.
btMatrix3x3 operator+(const btMatrix3x3 &m1, const btMatrix3x3 &m2)
btMatrix3x3 operator-(const btMatrix3x3 &m1, const btMatrix3x3 &m2)
const T & btMax(const T &a, const T &b)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
btReducedVector & operator-=(btReducedVector &v1, const btReducedVector &v2)
btReducedVector & operator+=(btReducedVector &v1, const btReducedVector &v2)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
btScalar btSqrt(btScalar y)
btScalar btAtan2(btScalar x, btScalar y)
btScalar btSin(btScalar x)
btScalar btFabs(btScalar x)
#define SIMD_FORCE_INLINE
btScalar btCos(btScalar x)
btScalar btAsin(btScalar x)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
btScalar btTriple(const btVector3 &v1, const btVector3 &v2, const btVector3 &v3)
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
void setEulerZYX(btScalar eulerX, btScalar eulerY, btScalar eulerZ)
Set the matrix from euler angles YPR around ZYX axes.
btMatrix3x3 adjoint() const
Return the adjoint of the matrix.
btMatrix3x3 inverse() const
Return the inverse of the matrix.
void getEulerYPR(btScalar &yaw, btScalar &pitch, btScalar &roll) const
Get the matrix represented as euler angles around YXZ, roundtrip with setEulerYPR.
void setFromOpenGLSubMatrix(const btScalar *m)
Set from the rotational part of a 4x4 OpenGL matrix.
btVector3 solve33(const btVector3 &b) const
Solve A * x = b, where b is a column vector.
btMatrix3x3 transpose() const
Return the transpose of the matrix.
void setEulerYPR(const btScalar &yaw, const btScalar &pitch, const btScalar &roll)
Set the matrix from euler angles using YPR around YXZ respectively.
void diagonalize(btMatrix3x3 &rot, btScalar threshold, int maxSteps)
diagonalizes this matrix by the Jacobi method.
btMatrix3x3 & operator-=(const btMatrix3x3 &m)
Substractss by the target matrix on the right.
void getRotation(btQuaternion &q) const
Get the matrix represented as a quaternion.
btMatrix3x3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2)
btMatrix3x3(const btScalar &xx, const btScalar &xy, const btScalar &xz, const btScalar &yx, const btScalar &yy, const btScalar &yz, const btScalar &zx, const btScalar &zy, const btScalar &zz)
Constructor with row major formatting.
void deSerializeFloat(const struct btMatrix3x3FloatData &dataIn)
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
btMatrix3x3 & operator=(const btMatrix3x3 &other)
Assignment Operator.
btMatrix3x3(const btMatrix3x3 &other)
Copy constructor.
void getEulerZYX(btScalar &yaw, btScalar &pitch, btScalar &roll, unsigned int solution_number=1) const
Get the matrix represented as euler angles around ZYX.
static const btMatrix3x3 & getIdentity()
btScalar tdotz(const btVector3 &v) const
void setIdentity()
Set the matrix to the identity.
btMatrix3x3 & operator+=(const btMatrix3x3 &m)
Adds by the target matrix on the right.
btVector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
btScalar tdotx(const btVector3 &v) const
void getOpenGLSubMatrix(btScalar *m) const
Fill the rotational part of an OpenGL matrix and clear the shear/perspective.
btScalar determinant() const
Return the determinant of the matrix.
const btVector3 & operator[](int i) const
Get a const reference to a row of the matrix as a vector.
btMatrix3x3 transposeTimes(const btMatrix3x3 &m) const
void deSerializeDouble(const struct btMatrix3x3DoubleData &dataIn)
void serialize(struct btMatrix3x3Data &dataOut) const
void extractRotation(btQuaternion &q, btScalar tolerance=1.0e-9, int maxIter=100)
extractRotation is from "A robust method to extract the rotational part of deformations" See http://d...
void setZero()
Set the matrix to the identity.
btScalar tdoty(const btVector3 &v) const
btVector3 m_el[3]
Data storage for the matrix, each vector is a row of the matrix.
void serializeFloat(struct btMatrix3x3FloatData &dataOut) const
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
btMatrix3x3 & operator*=(const btMatrix3x3 &m)
Multiply by the target matrix on the right.
void deSerialize(const struct btMatrix3x3Data &dataIn)
void setValue(const btScalar &xx, const btScalar &xy, const btScalar &xz, const btScalar &yx, const btScalar &yy, const btScalar &yz, const btScalar &zx, const btScalar &zy, const btScalar &zz)
Set the values of the matrix explicitly (row major)
btMatrix3x3()
No initializaion constructor.
void setRotation(const btQuaternion &q)
Set the matrix from a quaternion.
const btVector3 & getRow(int i) const
Get a row of the matrix as a vector.
btScalar cofac(int r1, int c1, int r2, int c2) const
Calculate the matrix cofactor.
btMatrix3x3(const btQuaternion &q)
Constructor from Quaternion.
btMatrix3x3 timesTranspose(const btMatrix3x3 &m) const
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
btQuaternion & normalize()
Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
btVector3 can be used to represent 3D points and vectors.
const btScalar & z() const
Return the z value.
btScalar norm() const
Return the norm (length) of the vector.
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
const btScalar & x() const
Return the x value.
const btScalar & y() const
Return the y value.
btVector3DoubleData m_el[3]
btVector3FloatData m_el[3]