26#define vMPPP (_mm_set_ps (+0.0f, +0.0f, +0.0f, -0.0f))
29#if defined(BT_USE_SSE)
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)
39#ifdef BT_USE_DOUBLE_PRECISION
40#define btMatrix3x3Data btMatrix3x3DoubleData
42#define btMatrix3x3Data btMatrix3x3FloatData
78#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
96 m_el[0].mVec128 =
rhs.m_el[0].mVec128;
97 m_el[1].mVec128 =
rhs.m_el[1].mVec128;
98 m_el[2].mVec128 =
rhs.m_el[2].mVec128;
104 m_el[0].mVec128 =
m.m_el[0].mVec128;
105 m_el[1].mVec128 =
m.m_el[1].mVec128;
106 m_el[2].mVec128 =
m.m_el[2].mVec128;
116 m_el[0] = other.
m_el[0];
117 m_el[1] = other.
m_el[1];
118 m_el[2] = other.
m_el[2];
124 m_el[0] = other.
m_el[0];
125 m_el[1] = other.
m_el[1];
126 m_el[2] = other.
m_el[2];
136 return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]);
215 #if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
319#if (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined(BT_USE_NEON)
332#if (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined(BT_USE_NEON)
349#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
350 __m128 v0 = m_el[0].mVec128;
351 __m128 v1 = m_el[1].mVec128;
352 __m128 v2 = m_el[2].mVec128;
368#elif defined(BT_USE_NEON)
402#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
415 temp.f[0]=m_el[2].
y() - m_el[1].
z();
416 temp.f[1]=m_el[0].
z() - m_el[2].
x();
417 temp.f[2]=m_el[1].
x() - m_el[0].
y();
424 if(m_el[0].x() < m_el[1].y())
426 if( m_el[1].y() < m_el[2].z() )
427 { i = 2;
j = 0;
k = 1; }
429 { i = 1;
j = 2;
k = 0; }
433 if( m_el[0].x() < m_el[2].z())
434 { i = 2;
j = 0;
k = 1; }
436 { i = 0;
j = 1;
k = 2; }
439 x = m_el[i][i] - m_el[
j][
j] - m_el[
k][
k] +
btScalar(1.0);
441 temp.f[3] = (m_el[
k][
j] - m_el[
j][
k]);
442 temp.f[
j] = (m_el[
j][i] + m_el[i][
j]);
443 temp.f[
k] = (m_el[
k][i] + m_el[i][
k]);
464 temp[0]=((m_el[2].
y() - m_el[1].
z()) *
s);
465 temp[1]=((m_el[0].
z() - m_el[2].
x()) *
s);
466 temp[2]=((m_el[1].
x() - m_el[0].
y()) *
s);
470 int i = m_el[0].
x() < m_el[1].
y() ?
471 (m_el[1].
y() < m_el[2].
z() ? 2 : 1) :
472 (m_el[0].
x() < m_el[2].
z() ? 2 : 0);
481 temp[
j] = (m_el[
j][i] + m_el[i][
j]) *
s;
482 temp[
k] = (m_el[
k][i] + m_el[i][
k]) *
s;
535 if (
btFabs(m_el[2].x()) >= 1)
592#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
596 m_el[0].x() *
s.
x(), m_el[0].
y() *
s.y(), m_el[0].
z() *
s.z(),
597 m_el[1].
x() *
s.x(), m_el[1].
y() *
s.y(), m_el[1].
z() *
s.z(),
598 m_el[2].
x() *
s.x(), m_el[2].
y() *
s.y(), m_el[2].
z() *
s.z());
639 return m_el[0].
x() * v.
x() + m_el[1].
x() * v.
y() + m_el[2].
x() * v.
z();
643 return m_el[0].
y() * v.
x() + m_el[1].
y() * v.
y() + m_el[2].
y() * v.
z();
647 return m_el[0].
z() * v.
x() + m_el[1].
z() * v.
y() + m_el[2].
z() * v.
z();
660 btVector3 omega = (
R.getColumn(0).cross(
A.getColumn(0)) +
R.getColumn(1).cross(
A.getColumn(1))
661 +
R.getColumn(2).cross(
A.getColumn(2))
663 (1).dot(
A.getColumn(1)) +
R.getColumn(2).dot(
A.getColumn(2))) +
726#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
775#elif defined(BT_USE_NEON)
781 v0 =
m_el[0].mVec128;
782 v1 =
m_el[1].mVec128;
783 v2 =
m_el[2].mVec128;
816#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
817 m_el[0].mVec128 =
m_el[0].mVec128 +
m.m_el[0].mVec128;
818 m_el[1].mVec128 =
m_el[1].mVec128 +
m.m_el[1].mVec128;
819 m_el[2].mVec128 =
m_el[2].mVec128 +
m.m_el[2].mVec128;
822 m_el[0][0]+
m.m_el[0][0],
823 m_el[0][1]+
m.m_el[0][1],
824 m_el[0][2]+
m.m_el[0][2],
825 m_el[1][0]+
m.m_el[1][0],
826 m_el[1][1]+
m.m_el[1][1],
827 m_el[1][2]+
m.m_el[1][2],
828 m_el[2][0]+
m.m_el[2][0],
829 m_el[2][1]+
m.m_el[2][1],
830 m_el[2][2]+
m.m_el[2][2]);
838#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
844#elif defined(BT_USE_NEON)
851 m[0].x()*
k,
m[0].y()*
k,
m[0].z()*
k,
852 m[1].x()*
k,
m[1].y()*
k,
m[1].z()*
k,
853 m[2].x()*
k,
m[2].y()*
k,
m[2].z()*
k);
860#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
884#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
909#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
910 m_el[0].mVec128 =
m_el[0].mVec128 -
m.m_el[0].mVec128;
911 m_el[1].mVec128 =
m_el[1].mVec128 -
m.m_el[1].mVec128;
912 m_el[2].mVec128 =
m_el[2].mVec128 -
m.m_el[2].mVec128;
915 m_el[0][0]-
m.m_el[0][0],
916 m_el[0][1]-
m.m_el[0][1],
917 m_el[0][2]-
m.m_el[0][2],
918 m_el[1][0]-
m.m_el[1][0],
919 m_el[1][1]-
m.m_el[1][1],
920 m_el[1][2]-
m.m_el[1][2],
921 m_el[2][0]-
m.m_el[2][0],
922 m_el[2][1]-
m.m_el[2][1],
923 m_el[2][2]-
m.m_el[2][2]);
932 return btTriple((*
this)[0], (*
this)[1], (*
this)[2]);
939#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
944#elif defined(BT_USE_NEON)
960#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
977#elif defined(BT_USE_NEON)
997 return btMatrix3x3(
cofac(1, 1, 2, 2),
cofac(0, 2, 2, 1),
cofac(0, 1, 1, 2),
998 cofac(1, 2, 2, 0),
cofac(0, 0, 2, 2),
cofac(0, 2, 1, 0),
999 cofac(1, 0, 2, 1),
cofac(0, 1, 2, 0),
cofac(0, 0, 1, 1));
1005 btVector3 co(
cofac(1, 1, 2, 2),
cofac(1, 2, 2, 0),
cofac(1, 0, 2, 1));
1018#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
1038#elif defined BT_USE_NEON
1059 m_el[0].x() *
m[0].x() +
m_el[1].x() *
m[1].x() +
m_el[2].x() *
m[2].x(),
1060 m_el[0].x() *
m[0].y() +
m_el[1].x() *
m[1].y() +
m_el[2].x() *
m[2].y(),
1061 m_el[0].x() *
m[0].z() +
m_el[1].x() *
m[1].z() +
m_el[2].x() *
m[2].z(),
1062 m_el[0].y() *
m[0].x() +
m_el[1].y() *
m[1].x() +
m_el[2].y() *
m[2].x(),
1063 m_el[0].y() *
m[0].y() +
m_el[1].y() *
m[1].y() +
m_el[2].y() *
m[2].y(),
1064 m_el[0].y() *
m[0].z() +
m_el[1].y() *
m[1].z() +
m_el[2].y() *
m[2].z(),
1065 m_el[0].z() *
m[0].x() +
m_el[1].z() *
m[1].x() +
m_el[2].z() *
m[2].x(),
1066 m_el[0].z() *
m[0].y() +
m_el[1].z() *
m[1].y() +
m_el[2].z() *
m[2].y(),
1067 m_el[0].z() *
m[0].z() +
m_el[1].z() *
m[1].z() +
m_el[2].z() *
m[2].z());
1074#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
1095#elif defined BT_USE_NEON
1127#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON)
1128 return v.
dot3(
m[0],
m[1],
m[2]);
1138#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
1152#elif defined(BT_USE_NEON)
1178#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
1224#elif defined(BT_USE_NEON)
1279#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
1291 return (0x7 == (
m & 0x7));
1295 (
m1[0][0] ==
m2[0][0] &&
m1[1][0] ==
m2[1][0] &&
m1[2][0] ==
m2[2][0] &&
1296 m1[0][1] ==
m2[0][1] &&
m1[1][1] ==
m2[1][1] &&
m1[2][1] ==
m2[2][1] &&
1297 m1[0][2] ==
m2[0][2] &&
m1[1][2] ==
m2[1][2] &&
m1[2][2] ==
m2[2][2] );
1318 for (
int i=0;i<3;i++)
1324 for (
int i=0;i<3;i++)
1331 for (
int i=0;i<3;i++)
1337 for (
int i=0;i<3;i++)
1343 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.
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.
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 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...
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 diagonalize(btMatrix3x3 &rot, btScalar tolerance=1.0e-9, int maxIter=100)
diagonalizes this matrix
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...
static const btQuaternion & getIdentity()
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]