45 #include <visp3/core/vpMath.h> 46 #include <visp3/core/vpMatrix.h> 49 #include <visp3/core/vpRotationMatrix.h> 52 #include <visp3/core/vpException.h> 56 #include <visp3/core/vpDebug.h> 57 const double vpRotationMatrix::threshold = 1e-6;
66 for (
unsigned int i = 0; i < 3; i++) {
67 for (
unsigned int j = 0; j < 3; j++) {
87 for (
unsigned int i = 0; i < 3; i++) {
88 for (
unsigned int j = 0; j < 3; j++) {
119 for (
unsigned int i = 0; i < 3; i++) {
120 for (
unsigned int j = 0; j < 3; j++) {
121 (*this)[i][j] = M[i][j];
127 "from a matrix that is not a " 141 for (
unsigned int i = 0; i < 3; i++) {
142 for (
unsigned int j = 0; j < 3; j++) {
144 for (
unsigned int k = 0; k < 3; k++)
173 for (
unsigned int i = 0; i < 3; i++) {
174 for (
unsigned int j = 0; j < 3; j++) {
176 for (
unsigned int k = 0; k < 3; k++)
177 s += (*
this)[i][k] * M[k][j];
217 "Cannot multiply a (3x3) rotation matrix by a %d " 218 "dimension column vector",
223 for (
unsigned int j = 0; j <
colNum; j++) {
225 for (
unsigned int i = 0; i <
rowNum; i++) {
226 v_out[i] +=
rowPtrs[i][j] * vj;
241 for (
unsigned int j = 0; j < 3; j++)
244 for (
unsigned int j = 0; j < 3; j++) {
245 for (
unsigned int i = 0; i < 3; i++) {
261 for (
unsigned int i = 0; i <
rowNum; i++)
262 for (
unsigned int j = 0; j <
colNum; j++)
274 for (
unsigned int i = 0; i <
rowNum; i++)
275 for (
unsigned int j = 0; j <
colNum; j++)
289 bool isRotation =
true;
293 for (i = 0; i < 3; i++) {
294 for (j = 0; j < 3; j++) {
296 if (fabs(RtR[i][j] - 1) > threshold)
299 if (fabs(RtR[i][j]) > threshold)
306 for (i = 0; i < 3; i++) {
312 for (i = 0; i < 3; i++) {
390 for (i = 0; i < 3; i++)
391 for (j = 0; j < 3; j++)
392 Rt[j][i] = (*
this)[i][j];
437 for (
unsigned int i = 0; i < 3; i++)
438 std::cout << tu[i] <<
" ";
440 std::cout << std::endl;
455 double theta, si, co, sinc, mcosc;
458 theta = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
464 R[0][0] = co + mcosc * v[0] * v[0];
465 R[0][1] = -sinc * v[2] + mcosc * v[0] * v[1];
466 R[0][2] = sinc * v[1] + mcosc * v[0] * v[2];
467 R[1][0] = sinc * v[2] + mcosc * v[1] * v[0];
468 R[1][1] = co + mcosc * v[1] * v[1];
469 R[1][2] = -sinc * v[0] + mcosc * v[1] * v[2];
470 R[2][0] = -sinc * v[1] + mcosc * v[2] * v[0];
471 R[2][1] = sinc * v[0] + mcosc * v[2] * v[1];
472 R[2][2] = co + mcosc * v[2] * v[2];
474 for (i = 0; i < 3; i++)
475 for (j = 0; j < 3; j++)
476 (*
this)[i][j] = R[i][j];
486 for (
unsigned int i = 0; i < 3; i++)
487 for (
unsigned int j = 0; j < 3; j++)
488 (*
this)[i][j] = M[i][j];
513 double c0, c1, c2, s0, s1, s2;
522 (*this)[0][0] = c0 * c1 * c2 - s0 * s2;
523 (*this)[0][1] = -c0 * c1 * s2 - s0 * c2;
524 (*this)[0][2] = c0 * s1;
525 (*this)[1][0] = s0 * c1 * c2 + c0 * s2;
526 (*this)[1][1] = -s0 * c1 * s2 + c0 * c2;
527 (*this)[1][2] = s0 * s1;
528 (*this)[2][0] = -s1 * c2;
529 (*this)[2][1] = s1 * s2;
545 double c0, c1, c2, s0, s1, s2;
554 (*this)[0][0] = c1 * c2;
555 (*this)[0][1] = -c1 * s2;
557 (*this)[1][0] = c0 * s2 + s0 * s1 * c2;
558 (*this)[1][1] = c0 * c2 - s0 * s1 * s2;
559 (*this)[1][2] = -s0 * c1;
560 (*this)[2][0] = -c0 * s1 * c2 + s0 * s2;
561 (*this)[2][1] = c0 * s1 * s2 + c2 * s0;
562 (*this)[2][2] = c0 * c1;
575 double c0, c1, c2, s0, s1, s2;
584 (*this)[0][0] = c0 * c1;
585 (*this)[0][1] = c0 * s1 * s2 - s0 * c2;
586 (*this)[0][2] = c0 * s1 * c2 + s0 * s2;
588 (*this)[1][0] = s0 * c1;
589 (*this)[1][1] = s0 * s1 * s2 + c0 * c2;
590 (*this)[1][2] = s0 * s1 * c2 - c0 * s2;
593 (*this)[2][1] = c1 * s2;
594 (*this)[2][2] = c1 * c2;
619 (*this)[0][0] = a * a + b * b - c * c - d * d;
620 (*this)[0][1] = 2 * b * c - 2 * a * d;
621 (*this)[0][2] = 2 * a * c + 2 * b * d;
623 (*this)[1][0] = 2 * a * d + 2 * b * c;
624 (*this)[1][1] = a * a - b * b + c * c - d * d;
625 (*this)[1][2] = 2 * c * d - 2 * a * b;
627 (*this)[2][0] = 2 * b * d - 2 * a * c;
628 (*this)[2][1] = 2 * a * b + 2 * c * d;
629 (*this)[2][2] = a * a - b * b - c * c + d * d;
640 unsigned int Rrow = R.
getRows();
641 unsigned int Rcol = R.
getCols();
643 for (
unsigned int i = 0; i < Rrow; i++)
644 for (
unsigned int j = 0; j < Rcol; j++)
645 C[i][j] = R[i][j] * x;
692 unsigned int nb_rows =
getRows();
694 for (
unsigned int i = 0; i < nb_rows; i++)
695 c[i] = (*
this)[i][j];
699 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 710 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) Implementation of a matrix and operations on matrices.
Implementation of an homogeneous matrix and operations on such kind of matrices.
double z() const
Returns z-component of the quaternion.
error that can be emited by ViSP classes.
unsigned int getRows() const
Implementation of a generic 2D array used as vase class of matrices and vectors.
Implementation of a rotation vector as Euler angle minimal representation.
vp_deprecated void setIdentity()
vpRotationMatrix inverse() const
vpRotationMatrix & operator=(const vpRotationMatrix &R)
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
vpRotationMatrix t() const
static double sinc(double x)
Implementation of a rotation matrix and operations on such kind of matrices.
unsigned int getCols() const
unsigned int rowNum
Number of rows in the array.
vpRotationMatrix & operator*=(const double x)
static double mcosc(double cosx, double x)
vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M)
static double sqr(double x)
vpColVector getCol(const unsigned int j) const
Implementation of a rotation vector as quaternion angle minimal representation.
double y() const
Returns y-component of the quaternion.
unsigned int colNum
Number of columns in the array.
double x() const
Returns x-component of the quaternion.
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
Implementation of a rotation vector as Euler angle minimal representation.
double w() const
Returns w-component of the quaternion.
vpThetaUVector getThetaUVector()
Implementation of a rotation vector as Euler angle minimal representation.
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.
bool isARotationMatrix() const
double ** rowPtrs
Address of the first element of each rows.
vpTranslationVector operator*(const vpTranslationVector &tv) const