Go to the documentation of this file.
16 #ifndef TF2_MATRIX3x3_H
17 #define TF2_MATRIX3x3_H
28 #define Matrix3x3Data Matrix3x3DoubleData
122 m_el[0].setValue(m[0],m[4],m[8]);
123 m_el[1].setValue(m[1],m[5],m[9]);
124 m_el[2].setValue(m[2],m[6],m[10]);
141 m_el[0].setValue(xx,xy,xz);
142 m_el[1].setValue(yx,yy,yz);
143 m_el[2].setValue(zx,zy,zz);
153 tf2Scalar xs = q.x() * s, ys = q.y() * s, zs = q.z() * s;
154 tf2Scalar wx = q.w() * xs, wy = q.w() * ys, wz = q.w() * zs;
155 tf2Scalar xx = q.x() * xs, xy = q.x() * ys, xz = q.x() * zs;
156 tf2Scalar yy = q.y() * ys, yz = q.y() * zs, zz = q.z() * zs;
158 xy + wz,
tf2Scalar(1.0) - (xx + zz), yz - wx,
159 xz - wy, yz + wx,
tf2Scalar(1.0) - (xx + yy));
194 setValue(cj * ch, sj * sc - cs, sj * cc + ss,
195 cj * sh, sj * ss + cc, sj * cs - sc,
196 -sj, cj * si, cj * ci);
222 return identityMatrix;
256 temp[0]=((
m_el[2].y() -
m_el[1].z()) * s);
257 temp[1]=((
m_el[0].z() -
m_el[2].x()) * s);
258 temp[2]=((
m_el[1].x() -
m_el[0].y()) * s);
263 (
m_el[1].y() <
m_el[2].z() ? 2 : 1) :
264 (
m_el[0].x() <
m_el[2].z() ? 2 : 0);
272 temp[3] = (
m_el[k][j] -
m_el[j][k]) * s;
273 temp[j] = (
m_el[j][i] +
m_el[i][j]) * s;
274 temp[k] = (
m_el[k][i] +
m_el[i][k]) * s;
276 q.setValue(temp[0],temp[1],temp[2],temp[3]);
320 euler_out.roll = delta;
321 euler_out2.roll = delta;
327 euler_out.roll = delta;
328 euler_out2.roll = delta;
334 euler_out2.pitch =
TF2SIMD_PI - euler_out.pitch;
347 if (solution_number == 1)
350 pitch = euler_out.pitch;
351 roll = euler_out.roll;
355 yaw = euler_out2.yaw;
356 pitch = euler_out2.pitch;
357 roll = euler_out2.roll;
377 m_el[1].x() * s.x(),
m_el[1].y() * s.y(),
m_el[1].z() * s.z(),
378 m_el[2].x() * s.x(),
m_el[2].y() * s.y(),
m_el[2].z() * s.z());
397 return m_el[0].x() * v.x() +
m_el[1].x() * v.y() +
m_el[2].x() * v.z();
401 return m_el[0].y() * v.x() +
m_el[1].y() * v.y() +
m_el[2].y() * v.z();
405 return m_el[0].z() * v.x() +
m_el[1].z() * v.y() +
m_el[2].z() * v.z();
462 t = (theta >= 0) ? 1 / (theta +
tf2Sqrt(1 + theta2))
463 : 1 / (theta -
tf2Sqrt(1 + theta2));
470 t = 1 / (theta * (2 +
tf2Scalar(0.5) / theta2));
477 m_el[p][p] -= t * mpq;
478 m_el[q][q] += t * mpq;
481 m_el[r][p] =
m_el[p][r] = cos * mrp - sin * mrq;
482 m_el[r][q] =
m_el[q][r] = cos * mrq + sin * mrp;
485 for (
int i = 0; i < 3; i++)
487 Vector3& row = rot[i];
490 row[p] = cos * mrp - sin * mrq;
491 row[q] = cos * mrq + sin * mrp;
536 return tf2Triple((*
this)[0], (*
this)[1], (*
this)[2]);
560 return Matrix3x3(
cofac(1, 1, 2, 2),
cofac(0, 2, 2, 1),
cofac(0, 1, 1, 2),
561 cofac(1, 2, 2, 0),
cofac(0, 0, 2, 2),
cofac(0, 2, 1, 0),
562 cofac(1, 0, 2, 1),
cofac(0, 1, 2, 0),
cofac(0, 0, 1, 1));
568 Vector3 co(
cofac(1, 1, 2, 2),
cofac(1, 2, 2, 0),
cofac(1, 0, 2, 1));
573 co.y() * s,
cofac(0, 0, 2, 2) * s,
cofac(0, 2, 1, 0) * s,
574 co.z() * s,
cofac(0, 1, 2, 0) * s,
cofac(0, 0, 1, 1) * s);
581 m_el[0].x() * m[0].x() +
m_el[1].x() * m[1].x() +
m_el[2].x() * m[2].x(),
582 m_el[0].x() * m[0].y() +
m_el[1].x() * m[1].y() +
m_el[2].x() * m[2].y(),
583 m_el[0].x() * m[0].z() +
m_el[1].x() * m[1].z() +
m_el[2].x() * m[2].z(),
584 m_el[0].y() * m[0].x() +
m_el[1].y() * m[1].x() +
m_el[2].y() * m[2].x(),
585 m_el[0].y() * m[0].y() +
m_el[1].y() * m[1].y() +
m_el[2].y() * m[2].y(),
586 m_el[0].y() * m[0].z() +
m_el[1].y() * m[1].z() +
m_el[2].y() * m[2].z(),
587 m_el[0].z() * m[0].x() +
m_el[1].z() * m[1].x() +
m_el[2].z() * m[2].x(),
588 m_el[0].z() * m[0].y() +
m_el[1].z() * m[1].y() +
m_el[2].z() * m[2].y(),
589 m_el[0].z() * m[0].z() +
m_el[1].z() * m[1].z() +
m_el[2].z() * m[2].z());
605 return Vector3(m[0].
dot(v), m[1].
dot(v), m[2].
dot(v));
643 return ( m1[0][0] == m2[0][0] && m1[1][0] == m2[1][0] && m1[2][0] == m2[2][0] &&
644 m1[0][1] == m2[0][1] && m1[1][1] == m2[1][1] && m1[2][1] == m2[2][1] &&
645 m1[0][2] == m2[0][2] && m1[1][2] == m2[1][2] && m1[2][2] == m2[2][2] );
665 for (
int i=0;i<3;i++)
671 for (
int i=0;i<3;i++)
678 for (
int i=0;i<3;i++)
684 for (
int i=0;i<3;i++)
690 for (
int i=0;i<3;i++)
695 #endif //TF2_MATRIX3x3_H
void getEulerYPR(tf2Scalar &yaw, tf2Scalar &pitch, tf2Scalar &roll, unsigned int solution_number=1) const
Get the matrix represented as euler angles around YXZ, roundtrip with setEulerYPR.
TF2SIMD_FORCE_INLINE tf2Scalar dot(const Quaternion &q1, const Quaternion &q2)
Calculate the dot product between two quaternions.
void diagonalize(Matrix3x3 &rot, tf2Scalar threshold, int maxSteps)
diagonalizes this matrix by the Jacobi method.
void setRPY(tf2Scalar roll, tf2Scalar pitch, tf2Scalar yaw)
Set the matrix using RPY about XYZ fixed axes.
TF2SIMD_FORCE_INLINE tf2Scalar tf2Asin(tf2Scalar x)
Matrix3x3 & operator*=(const Matrix3x3 &m)
Multiply by the target matrix on the right.
TF2SIMD_FORCE_INLINE tf2Scalar tf2Atan2(tf2Scalar x, tf2Scalar y)
TF2SIMD_FORCE_INLINE Vector3 getColumn(int i) const
Get a column of the matrix as a vector.
Matrix3x3()
No initializaion constructor.
void deSerializeFloat(const struct Matrix3x3FloatData &dataIn)
Matrix3x3 inverse() const
Return the inverse of the matrix.
void getRotation(Quaternion &q) const
Get the matrix represented as a quaternion.
TF2SIMD_FORCE_INLINE tf2Scalar tdotz(const Vector3 &v) const
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sin(tf2Scalar x)
TF2SIMD_FORCE_INLINE Matrix3x3 & operator=(const Matrix3x3 &other)
Assignment Operator.
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sqrt(tf2Scalar x)
static const Matrix3x3 & getIdentity()
void getOpenGLSubMatrix(tf2Scalar *m) const
Fill the values of the matrix into a 9 element array.
void setRotation(const Quaternion &q)
Set the matrix from a quaternion.
Matrix3x3 transposeTimes(const Matrix3x3 &m) const
TF2SIMD_FORCE_INLINE tf2Scalar tdotx(const Vector3 &v) const
void setValue(const tf2Scalar &xx, const tf2Scalar &xy, const tf2Scalar &xz, const tf2Scalar &yx, const tf2Scalar &yy, const tf2Scalar &yz, const tf2Scalar &zx, const tf2Scalar &zy, const tf2Scalar &zz)
Set the values of the matrix explicitly (row major)
TF2SIMD_FORCE_INLINE Matrix3x3(const Matrix3x3 &other)
Copy constructor.
void getRPY(tf2Scalar &roll, tf2Scalar &pitch, tf2Scalar &yaw, unsigned int solution_number=1) const
Get the matrix represented as roll pitch and yaw about fixed axes XYZ.
ROS_DEPRECATED void setEulerZYX(const tf2Scalar &yaw, const tf2Scalar &pitch, const tf2Scalar &roll)
Set the matrix from euler angles using YPR around ZYX respectively.
void deSerialize(const struct Matrix3x3Data &dataIn)
TF2SIMD_FORCE_INLINE bool operator==(const Matrix3x3 &m1, const Matrix3x3 &m2)
Equality operator between two matrices It will test all elements are equal.
void deSerializeDouble(const struct Matrix3x3DoubleData &dataIn)
void setEulerYPR(tf2Scalar eulerZ, tf2Scalar eulerY, tf2Scalar eulerX)
Set the matrix from euler angles YPR around ZYX axes.
TF2SIMD_FORCE_INLINE Vector3 operator*(const Matrix3x3 &m, const Vector3 &v)
Matrix3x3(const Quaternion &q)
Constructor from Quaternion.
Matrix3x3 absolute() const
Return the matrix with all values non negative.
#define TF2SIMD_FORCE_INLINE
const TF2SIMD_FORCE_INLINE Vector3 & getRow(int i) const
Get a row of the matrix as a vector.
TF2SIMD_FORCE_INLINE tf2Scalar tf2Cos(tf2Scalar x)
void setIdentity()
Set the matrix to the identity.
Matrix3x3 scaled(const Vector3 &s) const
Create a scaled copy of the matrix.
tf2Scalar determinant() const
Return the determinant of the matrix.
const TF2SIMD_FORCE_INLINE Vector3 & operator[](int i) const
Get a const reference to a row of the matrix as a vector.
Vector3DoubleData m_el[3]
TF2SIMD_FORCE_INLINE tf2Scalar tf2Triple(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
TF2SIMD_FORCE_INLINE tf2Scalar tf2Fabs(tf2Scalar x)
void setFromOpenGLSubMatrix(const tf2Scalar *m)
Set from a carray of tf2Scalars.
Matrix3x3(const tf2Scalar &xx, const tf2Scalar &xy, const tf2Scalar &xz, const tf2Scalar &yx, const tf2Scalar &yy, const tf2Scalar &yz, const tf2Scalar &zx, const tf2Scalar &zy, const tf2Scalar &zz)
Constructor with row major formatting.
void serializeFloat(struct Matrix3x3FloatData &dataOut) const
ROS_DEPRECATED void getEulerZYX(tf2Scalar &yaw, tf2Scalar &pitch, tf2Scalar &roll, unsigned int solution_number=1) const
Get the matrix represented as euler angles around ZYX.
Vector3 m_el[3]
Data storage for the matrix, each vector is a row of the matrix.
The Quaternion implements quaternion to perform linear algebra rotations in combination with Matrix3x...
Matrix3x3 timesTranspose(const Matrix3x3 &m) const
void serialize(struct Matrix3x3Data &dataOut) const
Matrix3x3 transpose() const
Return the transpose of the matrix.
double tf2Scalar
The tf2Scalar type abstracts floating point numbers, to easily switch between double and single float...
The Matrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with Q...
TF2SIMD_FORCE_INLINE Vector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
Matrix3x3 adjoint() const
Return the adjoint of the matrix.
TF2SIMD_FORCE_INLINE tf2Scalar tdoty(const Vector3 &v) const
tf2Scalar cofac(int r1, int c1, int r2, int c2) const
Calculate the matrix cofactor.
tf2Scalar length2() const
Return the length squared of the quaternion.
tf2
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Sun Feb 4 2024 03:18:11