![]() |
Visual Servoing Platform
version 3.3.0
|
#include <vpRotationMatrix.h>
Static Public Member Functions | |
static vpRotationMatrix | mean (const std::vector< vpHomogeneousMatrix > &vec_M) |
static vpRotationMatrix | mean (const std::vector< vpRotationMatrix > &vec_R) |
Public Attributes | |
double * | data |
Protected Attributes | |
unsigned int | rowNum |
unsigned int | colNum |
double ** | rowPtrs |
unsigned int | dsize |
Related Functions | |
(Note that these are not member functions.) | |
enum | vpGEMMmethod |
void | vpGEMM (const vpArray2D< double > &A, const vpArray2D< double > &B, const double &alpha, const vpArray2D< double > &C, const double &beta, vpArray2D< double > &D, const unsigned int &ops=0) |
Deprecated functions | |
unsigned int | m_index |
vp_deprecated void | init () |
vp_deprecated void | setIdentity () |
Implementation of a rotation matrix and operations on such kind of matrices.
The vpRotationMatrix considers the particular case of a rotation matrix.
The vpRotationMatrix class is derived from vpArray2D<double>.
The code below shows how to create a rotation matrix, set the element values and access them:
Once build, this previous code produces the following output:
You can also use operator<< to initialize a rotation matrix as previously:
If ViSP is build with c++11 enabled, you can do the same using:
Definition at line 122 of file vpRotationMatrix.h.
vpRotationMatrix::vpRotationMatrix | ( | ) |
Default constructor that initialise a 3-by-3 rotation matrix to identity.
Definition at line 441 of file vpRotationMatrix.cpp.
References eye().
vpRotationMatrix::vpRotationMatrix | ( | const vpRotationMatrix & | M | ) |
Copy contructor that construct a 3-by-3 rotation matrix from another rotation matrix.
Definition at line 447 of file vpRotationMatrix.cpp.
|
explicit |
Construct a 3-by-3 rotation matrix from an homogeneous matrix.
Definition at line 451 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from angle representation.
Definition at line 457 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from a pose vector.
Definition at line 462 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from Euler angle representation.
Definition at line 468 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from Euler angle representation.
Definition at line 474 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from Euler angle representation.
Definition at line 480 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from quaternion angle representation.
Definition at line 499 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a 3-by-3 rotation matrix from a matrix that contains values corresponding to a rotation matrix.
Definition at line 485 of file vpRotationMatrix.cpp.
vpRotationMatrix::vpRotationMatrix | ( | double | tux, |
double | tuy, | ||
double | tuz | ||
) |
Construct a 3-by-3 rotation matrix from angle representation.
Definition at line 491 of file vpRotationMatrix.cpp.
References buildFrom().
|
explicit |
Construct a rotation matrix from a list of 9 double values.
list | : List of double. The following code shows how to use this constructor to initialize a rotation matrix: #include <visp3/core/vpRotationMatrix.h>
int main()
{
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
vpRotationMatrix R{ 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
#endif
}
R:
0 0 -1
0 -1 0
-1 0 0
|
Definition at line 525 of file vpRotationMatrix.cpp.
References vpException::fatalError, and isARotationMatrix().
|
inlinevirtual |
Destructor.
Definition at line 144 of file vpRotationMatrix.h.
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpHomogeneousMatrix & | M | ) |
Build a rotation matrix from an homogeneous matrix.
Definition at line 638 of file vpRotationMatrix.cpp.
Referenced by buildFrom(), vpRxyzVector::buildFrom(), vpRzyzVector::buildFrom(), vpRzyxVector::buildFrom(), vpExponentialMap::direct(), vpPoseVector::extract(), vpRobotAfma6::setPosition(), and vpRotationMatrix().
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpPoseVector & | p | ) |
Build a rotation matrix from a pose vector.
Definition at line 652 of file vpRotationMatrix.cpp.
References buildFrom().
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpQuaternionVector & | q | ) |
Construct a 3-by-3 rotation matrix from a quaternion representation.
Definition at line 767 of file vpRotationMatrix.cpp.
References vpQuaternionVector::w(), vpQuaternionVector::x(), vpQuaternionVector::y(), and vpQuaternionVector::z().
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpRxyzVector & | v | ) |
Transform a vector representing the Rxyz angle into a rotation matrix. Rxyz( ) = Rot(
) Rot(
) Rot(
)
Definition at line 697 of file vpRotationMatrix.cpp.
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpRzyxVector & | v | ) |
Transform a vector representing the Rzyx angle into a rotation matrix. Rxyz( ) = Rot(
) Rot(
)Rot(
)
Definition at line 727 of file vpRotationMatrix.cpp.
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpRzyzVector & | v | ) |
Transform a vector representing the Euler angle into a rotation matrix. Rzyz( ) = Rot(
) Rot(
) Rot(
)
Definition at line 665 of file vpRotationMatrix.cpp.
vpRotationMatrix vpRotationMatrix::buildFrom | ( | const vpThetaUVector & | v | ) |
Transform a angle representation into a rotation matrix.
The rotation is computed using :
Definition at line 606 of file vpRotationMatrix.cpp.
References vpMath::mcosc(), and vpMath::sinc().
vpRotationMatrix vpRotationMatrix::buildFrom | ( | double | tux, |
double | tuy, | ||
double | tuz | ||
) |
Construct a 3-by-3 rotation matrix from angle representation.
Definition at line 757 of file vpRotationMatrix.cpp.
References buildFrom().
void vpRotationMatrix::eye | ( | ) |
Initialize the rotation matrix as identity.
Definition at line 64 of file vpRotationMatrix.cpp.
Referenced by setIdentity(), and vpRotationMatrix().
vpColVector vpRotationMatrix::getCol | ( | unsigned int | j | ) | const |
Extract a column vector from a rotation matrix.
j | : Index of the column to extract. If j=0, the first column is extracted. |
The following example shows how to use this function:
It produces the following output:
Definition at line 842 of file vpRotationMatrix.cpp.
References vpException::dimensionError, vpArray2D< double >::getCols(), and vpArray2D< double >::getRows().
|
inlineinherited |
Return the number of columns of the 2D array.
Definition at line 279 of file vpArray2D.h.
|
inherited |
Return the array max value.
Definition at line 281 of file vpArray2D.h.
|
inherited |
Return the array min value.
Definition at line 283 of file vpArray2D.h.
|
inlineinherited |
Return the number of rows of the 2D array.
Definition at line 289 of file vpArray2D.h.
vpThetaUVector vpRotationMatrix::getThetaUVector | ( | ) |
Return the vector that corresponds to the rotation matrix.
Definition at line 808 of file vpRotationMatrix.cpp.
References vpThetaUVector::buildFrom().
Referenced by vpRobotBebop2::setPosition().
Compute the Hadamard product (element wise matrix multiplication).
m | : Second matrix; |
Definition at line 519 of file vpArray2D.h.
|
inline |
Definition at line 217 of file vpRotationMatrix.h.
vpRotationMatrix vpRotationMatrix::inverse | ( | ) | const |
Return the rotation matrix inverse which is also the transpose of the rotation matrix.
Definition at line 557 of file vpRotationMatrix.cpp.
References t().
Referenced by vpViper::get_eJe(), and inverse().
void vpRotationMatrix::inverse | ( | vpRotationMatrix & | R | ) | const |
Inverse the rotation matrix.
R | (output): Inverted rotation matrix. |
Definition at line 581 of file vpRotationMatrix.cpp.
References inverse().
bool vpRotationMatrix::isARotationMatrix | ( | ) | const |
Test if the rotation matrix is really a rotation matrix.
Definition at line 399 of file vpRotationMatrix.cpp.
References vpArray2D< double >::getCols(), vpArray2D< double >::getRows(), vpMath::sqr(), and t().
Referenced by vpHomogeneousMatrix::isAnHomogeneousMatrix(), operator=(), and vpRotationMatrix().
|
inlinestaticinherited |
Load a matrix from a file.
filename | : Absolute file name. |
A | : Array to be loaded |
binary | : If true the matrix is loaded from a binary file, else from a text file. |
header | : Header of the file is loaded in this parameter. |
Definition at line 541 of file vpArray2D.h.
|
inlinestaticinherited |
Load an array from a YAML-formatted file.
filename | : absolute file name. |
A | : array to be loaded from the file. |
header | : header of the file is loaded in this parameter. |
Definition at line 653 of file vpArray2D.h.
|
static |
Compute the Euclidean mean of the rotation matrices extracted from a vector of homogeneous matrices following Moakher's method (SIAM 2002).
[in] | vec_M | : Set of homogeneous matrices. |
Definition at line 861 of file vpRotationMatrix.cpp.
References vpMatrix::pseudoInverse(), and vpMatrix::t().
|
static |
Compute the Euclidean mean of the rotation matrices following Moakher's method (SIAM 2002).
[in] | vec_R | : Set of rotation matrices. |
Definition at line 898 of file vpRotationMatrix.cpp.
References vpMatrix::pseudoInverse(), and vpMatrix::t().
Not equal to comparison operator of a 2D array.
Definition at line 411 of file vpArray2D.h.
vpColVector vpRotationMatrix::operator* | ( | const vpColVector & | v | ) | const |
Operator that allows to multiply a rotation matrix by a 3 dimension column vector.
v | : Three dimension column vector. |
vpException::dimensionError | If the column vector v is not a 3 dimension vector. |
The code below shows how to use this operator.
Definition at line 326 of file vpRotationMatrix.cpp.
References vpArray2D< double >::colNum, vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.
Operator that allows to multiply a rotation matrix by a 3-by-3 matrix. Allows for example to multiply a rotation matrix by a skew matrix.
vpException::dimensionError | : If M is not a 3-by-3 dimension matrix. |
Definition at line 278 of file vpRotationMatrix.cpp.
References vpException::dimensionError, vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().
vpRotationMatrix vpRotationMatrix::operator* | ( | const vpRotationMatrix & | R | ) | const |
Compute the product between two rotation matrices.
Definition at line 250 of file vpRotationMatrix.cpp.
References vpArray2D< double >::rowPtrs, and vpArray2D< Type >::rowPtrs.
vpTranslationVector vpRotationMatrix::operator* | ( | const vpTranslationVector & | tv | ) | const |
Multiply a rotation matrix by a translation vector and return the resulting translation vector.
Definition at line 350 of file vpRotationMatrix.cpp.
References vpArray2D< double >::rowPtrs.
vpRotationMatrix vpRotationMatrix::operator* | ( | double | x | ) | const |
Operator that allows to multiply all the elements of a rotation matrix by a scalar.
Definition at line 370 of file vpRotationMatrix.cpp.
References vpArray2D< double >::colNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.
vpRotationMatrix & vpRotationMatrix::operator*= | ( | double | x | ) |
Operator that allows to multiply all the elements of a rotation matrix by a scalar.
Definition at line 385 of file vpRotationMatrix.cpp.
References vpArray2D< double >::colNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.
vpRotationMatrix & vpRotationMatrix::operator, | ( | double | val | ) |
Set the second and next element of the rotation matrix.
val | : Value of the matrix second or next element. |
The following example shows how to initialize a rotation matrix using this operator.
It produces the following printings:
Definition at line 237 of file vpRotationMatrix.cpp.
References vpArray2D< double >::data, vpException::dimensionError, m_index, and vpArray2D< double >::size().
vpRotationMatrix & vpRotationMatrix::operator<< | ( | double | val | ) |
Set the first element of the rotation matrix.
val | : Value of the matrix first element. |
The following example shows how to initialize a rotation matrix using this operator.
It produces the following printings:
Definition at line 203 of file vpRotationMatrix.cpp.
References vpArray2D< double >::data, and m_index.
vpRotationMatrix & vpRotationMatrix::operator= | ( | const std::initializer_list< double > & | list | ) |
Set a rotation matrix from a list of 9 double values.
list | : List of double. The following code shows how to use this constructor to initialize a rotation matrix: #include <visp3/core/vpRotationMatrix.h>
int main()
{
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
#endif
}
R:
0 0 -1
0 -1 0
-1 0 0
|
Definition at line 122 of file vpRotationMatrix.cpp.
References vpArray2D< double >::data, vpException::dimensionError, vpArray2D< double >::dsize, vpException::fatalError, and isARotationMatrix().
vpRotationMatrix & vpRotationMatrix::operator= | ( | const vpMatrix & | M | ) |
Converts a 3-by-3 matrix into a rotation matrix.
M | : Input matrix. |
vpException::fatalError | If the input matrix is not a rotation matrix. |
Definition at line 154 of file vpRotationMatrix.cpp.
References vpException::dimensionError, vpException::fatalError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), and isARotationMatrix().
vpRotationMatrix & vpRotationMatrix::operator= | ( | const vpRotationMatrix & | R | ) |
Set the current rotation matrix from a rotation matrix R.
R | : Rotation matrix. vpRotationMatrix R2 = R1;
|
Definition at line 85 of file vpRotationMatrix.cpp.
References vpArray2D< double >::rowPtrs, and vpArray2D< Type >::rowPtrs.
Equal to comparison operator of a 2D array.
Definition at line 407 of file vpArray2D.h.
Definition at line 979 of file vpArray2D.h.
|
inlineinherited |
Set element using A[i][j] = x.
Definition at line 485 of file vpArray2D.h.
|
inlineinherited |
Get element using x = A[i][j].
Definition at line 487 of file vpArray2D.h.
void vpRotationMatrix::printVector | ( | ) |
Print to std::cout the rotation matrix as a angle representation vector.
Definition at line 587 of file vpRotationMatrix.cpp.
|
inlineinherited |
Definition at line 380 of file vpArray2D.h.
|
inline |
This function is not applicable to a rotation matrix that is always a 3-by-3 matrix.
vpException::fatalError | When this function is called. |
Definition at line 194 of file vpRotationMatrix.h.
References vpException::fatalError.
|
inlineinherited |
Set the size of the array and initialize all the values to zero.
nrows | : number of rows. |
ncols | : number of column. |
flagNullify | : if true, then the array is re-initialized to 0 after resize. If false, the initial values from the common part of the array (common part between old and new version of the array) are kept. Default value is true. |
recopy_ | : if true, will perform an explicit recopy of the old data if needed and if flagNullify is set to false. |
Definition at line 305 of file vpArray2D.h.
|
inlinestaticinherited |
Save a matrix to a file.
filename | : Absolute file name. |
A | : Array to be saved. |
binary | : If true the matrix is saved in a binary file, else a text file. |
header | : Optional line that will be saved at the beginning of the file. |
Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.
Definition at line 738 of file vpArray2D.h.
|
inlinestaticinherited |
Save an array in a YAML-formatted file.
filename | : absolute file name. |
A | : array to be saved in the file. |
header | : optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any. |
Here is an example of outputs.
Content of matrix.yml:
Content of matrixIndent.yml:
Definition at line 831 of file vpArray2D.h.
void vpRotationMatrix::setIdentity | ( | ) |
Initializes the rotation matrix as identity.
Definition at line 935 of file vpRotationMatrix.cpp.
References eye().
|
inlineinherited |
Return the number of elements of the 2D array.
Definition at line 291 of file vpArray2D.h.
vpRotationMatrix vpRotationMatrix::t | ( | ) | const |
Return the rotation matrix transpose which is also the inverse of the rotation matrix.
Definition at line 539 of file vpRotationMatrix.cpp.
Referenced by vpVelocityTwistMatrix::extract(), inverse(), vpHomogeneousMatrix::inverse(), vpVelocityTwistMatrix::inverse(), isARotationMatrix(), and vpSimulatorAfma6::setPosition().
|
related |
This function performs generalized matrix multiplication: D = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T. Operation on A, B and C matrices is described by enumeration vpGEMMmethod().
For example, to compute D = alpha*A^T*B^T+beta*C we need to call :
If C is not used, vpGEMM must be called using an empty array null. Thus to compute D = alpha*A^T*B, we have to call:
vpException::incorrectMatrixSizeError | if the sizes of the matrices do not allow the operations. |
A | : An array that could be a vpMatrix. |
B | : An array that could be a vpMatrix. |
alpha | : A scalar. |
C | : An array that could be a vpMatrix. |
beta | : A scalar. |
D | : The resulting array that could be a vpMatrix. |
ops | : A scalar describing operation applied on the matrices. Possible values are the one defined in vpGEMMmethod(): VP_GEMM_A_T, VP_GEMM_B_T, VP_GEMM_C_T. |
|
related |
Enumeration of the operations applied on matrices in vpGEMM() function.
Operations are :
|
protectedinherited |
Number of columns in the array.
Definition at line 137 of file vpArray2D.h.
|
inherited |
Address of the first element of the data array.
Definition at line 145 of file vpArray2D.h.
|
protectedinherited |
Current array size (rowNum * colNum)
Definition at line 141 of file vpArray2D.h.
|
protected |
Definition at line 229 of file vpRotationMatrix.h.
Referenced by operator,(), and operator<<().
|
protectedinherited |
Number of rows in the array.
Definition at line 135 of file vpArray2D.h.
|
protectedinherited |
Address of the first element of each rows.
Definition at line 139 of file vpArray2D.h.