Visual Servoing Platform  version 3.6.1 under development (2024-03-18)
vpRotationMatrix Class Reference

#include <visp3/core/vpRotationMatrix.h>

+ Inheritance diagram for vpRotationMatrix:

Public Member Functions

 vpRotationMatrix ()
 
 vpRotationMatrix (const vpRotationMatrix &R)
 
 vpRotationMatrix (const vpHomogeneousMatrix &M)
 
 vpRotationMatrix (const vpThetaUVector &r)
 
 vpRotationMatrix (const vpPoseVector &p)
 
 vpRotationMatrix (const vpRzyzVector &r)
 
 vpRotationMatrix (const vpRxyzVector &r)
 
 vpRotationMatrix (const vpRzyxVector &r)
 
 vpRotationMatrix (const vpQuaternionVector &q)
 
 vpRotationMatrix (const vpMatrix &R)
 
 vpRotationMatrix (double tux, double tuy, double tuz)
 
 vpRotationMatrix (const std::initializer_list< double > &list)
 
vpRotationMatrix buildFrom (const vpHomogeneousMatrix &M)
 
vpRotationMatrix buildFrom (const vpThetaUVector &v)
 
vpRotationMatrix buildFrom (const vpPoseVector &p)
 
vpRotationMatrix buildFrom (const vpRzyzVector &v)
 
vpRotationMatrix buildFrom (const vpRxyzVector &v)
 
vpRotationMatrix buildFrom (const vpRzyxVector &v)
 
vpRotationMatrix buildFrom (const vpQuaternionVector &q)
 
vpRotationMatrix buildFrom (double tux, double tuy, double tuz)
 
void eye ()
 
vpColVector getCol (unsigned int j) const
 
vpThetaUVector getThetaUVector ()
 
vpRotationMatrix inverse () const
 
void inverse (vpRotationMatrix &R) const
 
bool isARotationMatrix (double threshold=1e-6) const
 
vpRotationMatrixoperator= (const vpRotationMatrix &R)
 
vpRotationMatrixoperator= (const vpMatrix &M)
 
vpRotationMatrixoperator= (const std::initializer_list< double > &list)
 
vpTranslationVector operator* (const vpTranslationVector &tv) const
 
vpRotationMatrix operator* (const vpRotationMatrix &R) const
 
vpHomogeneousMatrix operator* (const vpHomogeneousMatrix &M) const
 
vpMatrix operator* (const vpMatrix &M) const
 
vpColVector operator* (const vpColVector &v) const
 
vpRotationMatrix operator* (double x) const
 
vpRotationMatrixoperator*= (double x)
 
vpRotationMatrixoperator<< (double val)
 
vpRotationMatrixoperator, (double val)
 
void orthogonalize ()
 
void printVector ()
 
void resize (unsigned int nrows, unsigned int ncols, bool flagNullify=true)
 
vpRotationMatrix t () const
 
Inherited functionalities from vpArray2D
unsigned int getCols () const
 
double getMaxValue () const
 
double getMinValue () const
 
unsigned int getRows () const
 
unsigned int size () const
 
void resize (unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
 
void reshape (unsigned int nrows, unsigned int ncols)
 
void insert (const vpArray2D< double > &A, unsigned int r, unsigned int c)
 
bool operator== (const vpArray2D< double > &A) const
 
bool operator!= (const vpArray2D< double > &A) const
 
double * operator[] (unsigned int i)
 
double * operator[] (unsigned int i) const
 
vpArray2D< double > hadamard (const vpArray2D< double > &m) const
 

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
 
bool operator== (const vpArray2D< double > &A) const
 
bool operator== (const vpArray2D< float > &A) const
 
bool operator!= (const vpArray2D< double > &A) const
 
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 ()
 

Inherited I/O from vpArray2D with Static Public Member Functions

vpArray2D< double > insert (const vpArray2D< double > &A, const vpArray2D< double > &B, unsigned int r, unsigned int c)
 
static bool load (const std::string &filename, vpArray2D< double > &A, bool binary=false, char *header=nullptr)
 
static bool loadYAML (const std::string &filename, vpArray2D< double > &A, char *header=nullptr)
 
static bool save (const std::string &filename, const vpArray2D< double > &A, bool binary=false, const char *header="")
 
static bool saveYAML (const std::string &filename, const vpArray2D< double > &A, const char *header="")
 
static vpArray2D< double > conv2 (const vpArray2D< double > &M, const vpArray2D< double > &kernel, const std::string &mode)
 
static void conv2 (const vpArray2D< double > &M, const vpArray2D< double > &kernel, vpArray2D< double > &res, const std::string &mode)
 
static void insert (const vpArray2D< double > &A, const vpArray2D< double > &B, vpArray2D< double > &C, unsigned int r, unsigned int c)
 

Detailed Description

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:

#include <visp3/core/vpRotationMatrix.h>
int main()
{
R[0][0] = 0; R[0][1] = 0; R[0][2] = -1;
R[1][0] = 0; R[1][1] = -1; R[1][2] = 0;
R[2][0] = -1; R[2][1] = 0; R[2][2] = 0;
std::cout << "R:" << std::endl;
for (unsigned int i = 0; i < R.getRows(); i++) {
for (unsigned int j = 0; j < R.getCols(); j++) {
std::cout << R[i][j] << " ";
}
std::cout << std::endl;
}
}
unsigned int getCols() const
Definition: vpArray2D.h:274
unsigned int getRows() const
Definition: vpArray2D.h:284
Implementation of a rotation matrix and operations on such kind of matrices.

Once build, this previous code produces the following output:

R:
0 0 -1
0 -1 0
-1 0 0

You can also use operator<< to initialize a rotation matrix as previously:

#include <visp3/core/vpRotationMatrix.h>
int main()
{
R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
std::cout << "R:\n" << R << std::endl;
}

If ViSP is build with c++11 enabled, you can do the same using:

#include <visp3/code/vpRotationMatrix.h
int main()
{
vpRotationMatrix R{ 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
}
Examples
AROgreBasic.cpp, ClassUsingPclViewer.h, HelloWorldOgre.cpp, exponentialMap.cpp, homographyHLM2DObject.cpp, homographyHLM3DObject.cpp, homographyHartleyDLT2DObject.cpp, homographyRansac2DObject.cpp, manGeometricFeatures.cpp, mbot-apriltag-2D-half-vs.cpp, mbot-apriltag-ibvs.cpp, mbot-apriltag-pbvs.cpp, servoAfma6AprilTagIBVS.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6FourPoints2DCamVelocityLs_cur.cpp, servoAfma6FourPoints2DCamVelocityLs_des.cpp, servoBebop2.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoFlirPtuIBVS.cpp, servoFrankaIBVS.cpp, servoFrankaPBVS.cpp, servoPololuPtuPoint2DJointVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, servoViper650FourPoints2DArtVelocityLs_cur.cpp, servoViper650FourPoints2DCamVelocityLs_cur-SR300.cpp, servoViper650FourPoints2DCamVelocityLs_cur.cpp, servoViper850FourPoints2DArtVelocityLs_cur.cpp, servoViper850FourPoints2DCamVelocityLs_cur.cpp, servoViper850FourPointsKinect.cpp, testDisplacement.cpp, testDisplays.cpp, testImageDraw.cpp, testMatrix.cpp, testMatrixInitialization.cpp, testPoseVector.cpp, testRobotAfma6Pose.cpp, testRobotViper650-frames.cpp, testRobotViper850-frames.cpp, testRobotViper850.cpp, testRobotViper850Pose.cpp, testRotation2.cpp, testTwistMatrix.cpp, testViper650.cpp, testViper850.cpp, testVirtuoseHapticBox.cpp, tutorial-draw-frame.cpp, tutorial-flir-ptu-ibvs.cpp, tutorial-homography-from-points.cpp, tutorial-ibvs-4pts-ogre-tracking.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, tutorial-simu-pioneer-pan.cpp, and tutorial-simu-pioneer.cpp.

Definition at line 115 of file vpRotationMatrix.h.

Constructor & Destructor Documentation

◆ vpRotationMatrix() [1/12]

vpRotationMatrix::vpRotationMatrix ( )

Default constructor that initialise a 3-by-3 rotation matrix to identity.

Definition at line 476 of file vpRotationMatrix.cpp.

References eye().

◆ vpRotationMatrix() [2/12]

vpRotationMatrix::vpRotationMatrix ( const vpRotationMatrix M)

Copy constructor that construct a 3-by-3 rotation matrix from another rotation matrix.

Definition at line 482 of file vpRotationMatrix.cpp.

◆ vpRotationMatrix() [3/12]

vpRotationMatrix::vpRotationMatrix ( const vpHomogeneousMatrix M)
explicit

Construct a 3-by-3 rotation matrix from an homogeneous matrix.

Definition at line 487 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [4/12]

vpRotationMatrix::vpRotationMatrix ( const vpThetaUVector tu)
explicit

Construct a 3-by-3 rotation matrix from $ \theta {\bf u}$ angle representation.

Definition at line 493 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [5/12]

vpRotationMatrix::vpRotationMatrix ( const vpPoseVector p)
explicit

Construct a 3-by-3 rotation matrix from a pose vector.

Definition at line 498 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [6/12]

vpRotationMatrix::vpRotationMatrix ( const vpRzyzVector euler)
explicit

Construct a 3-by-3 rotation matrix from $ R(z,y,z) $ Euler angle representation.

Definition at line 504 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [7/12]

vpRotationMatrix::vpRotationMatrix ( const vpRxyzVector Rxyz)
explicit

Construct a 3-by-3 rotation matrix from $ R(x,y,z) $ Euler angle representation.

Definition at line 513 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [8/12]

vpRotationMatrix::vpRotationMatrix ( const vpRzyxVector Rzyx)
explicit

Construct a 3-by-3 rotation matrix from $ R(z,y,x) $ Euler angle representation.

Definition at line 519 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [9/12]

vpRotationMatrix::vpRotationMatrix ( const vpQuaternionVector q)
explicit

Construct a 3-by-3 rotation matrix from quaternion angle representation.

Definition at line 538 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [10/12]

vpRotationMatrix::vpRotationMatrix ( const vpMatrix R)
explicit

Construct a 3-by-3 rotation matrix from a matrix that contains values corresponding to a rotation matrix.

Definition at line 524 of file vpRotationMatrix.cpp.

◆ vpRotationMatrix() [11/12]

vpRotationMatrix::vpRotationMatrix ( double  tux,
double  tuy,
double  tuz 
)

Construct a 3-by-3 rotation matrix from $ \theta {\bf u}=(\theta u_x, \theta u_y, \theta u_z)^T$ angle representation.

Definition at line 530 of file vpRotationMatrix.cpp.

References buildFrom().

◆ vpRotationMatrix() [12/12]

vpRotationMatrix::vpRotationMatrix ( const std::initializer_list< double > &  list)
explicit

Construct a rotation matrix from a list of 9 double values.

Parameters
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()
{
vpRotationMatrix R{ 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
}
It produces the following output:
R:
0 0 -1
0 -1 0
-1 0 0

Definition at line 562 of file vpRotationMatrix.cpp.

References vpException::fatalError, isARotationMatrix(), and orthogonalize().

Member Function Documentation

◆ buildFrom() [1/8]

◆ buildFrom() [2/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpPoseVector p)

Build a rotation matrix from a pose vector.

See also
buildFrom(const vpThetaUVector &)

Definition at line 695 of file vpRotationMatrix.cpp.

References buildFrom().

◆ buildFrom() [3/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpQuaternionVector q)

Construct a 3-by-3 rotation matrix from a quaternion representation.

Definition at line 810 of file vpRotationMatrix.cpp.

References vpQuaternionVector::w(), vpQuaternionVector::x(), vpQuaternionVector::y(), and vpQuaternionVector::z().

◆ buildFrom() [4/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpRxyzVector v)

Transform a vector representing the Rxyz angle into a rotation matrix. Rxyz( $ \phi,\theta, \psi $) = Rot( $ x, \psi $) Rot( $ y, \theta $ ) Rot( $ z,\phi $)

Definition at line 740 of file vpRotationMatrix.cpp.

◆ buildFrom() [5/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpRzyxVector v)

Transform a vector representing the Rzyx angle into a rotation matrix. Rxyz( $ \phi, \theta , \psi $) = Rot( $ z, \psi $) Rot( $ y, \theta $)Rot( $ x, \phi $)

Definition at line 770 of file vpRotationMatrix.cpp.

◆ buildFrom() [6/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpRzyzVector v)

Transform a vector representing the Euler angle into a rotation matrix. Rzyz( $ \phi, \theta , \psi $) = Rot( $ z,\phi $) Rot( $ y,\theta $) Rot( $ z,\psi $)

Definition at line 708 of file vpRotationMatrix.cpp.

◆ buildFrom() [7/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( const vpThetaUVector v)

Transform a $ \theta {\bf u}$ angle representation into a rotation matrix.

The rotation is computed using :

\[ R = \cos{ \theta} \; {I}_{3} + (1 - \cos{ \theta}) \; u u^{T} + \sin{ \theta} \; [u]_\times \]

Definition at line 650 of file vpRotationMatrix.cpp.

References vpMath::mcosc(), and vpMath::sinc().

◆ buildFrom() [8/8]

vpRotationMatrix vpRotationMatrix::buildFrom ( double  tux,
double  tuy,
double  tuz 
)

Construct a 3-by-3 rotation matrix from $ \theta {\bf u}=(\theta u_x, \theta u_y, \theta u_z)^T$ angle representation.

Definition at line 800 of file vpRotationMatrix.cpp.

References buildFrom().

◆ conv2() [1/2]

vpArray2D< double > vpArray2D< double >::conv2 ( const vpArray2D< Type > &  M,
const vpArray2D< Type > &  kernel,
const std::string &  mode 
)
staticinherited

Perform a 2D convolution similar to Matlab conv2 function: $ M \star kernel $.

Parameters
M: First matrix.
kernel: Second matrix.
mode: Convolution mode: "full" (default), "same", "valid".
Convolution mode: full, same, valid (image credit: Theano doc).
Note
This is a very basic implementation that does not use FFT.
Examples
testMatrixConvolution.cpp.

Definition at line 976 of file vpArray2D.h.

◆ conv2() [2/2]

void vpArray2D< double >::conv2 ( const vpArray2D< Type > &  M,
const vpArray2D< Type > &  kernel,
vpArray2D< Type > &  res,
const std::string &  mode 
)
staticinherited

Perform a 2D convolution similar to Matlab conv2 function: $ M \star kernel $.

Parameters
M: First array.
kernel: Second array.
res: Result.
mode: Convolution mode: "full" (default), "same", "valid".
Convolution mode: full, same, valid (image credit: Theano doc).
Note
This is a very basic implementation that does not use FFT.

Definition at line 990 of file vpArray2D.h.

◆ eye()

void vpRotationMatrix::eye ( )

Initialize the rotation matrix as identity.

See also
setIdentity()

Definition at line 60 of file vpRotationMatrix.cpp.

Referenced by setIdentity(), and vpRotationMatrix().

◆ getCol()

vpColVector vpRotationMatrix::getCol ( unsigned int  j) const

Extract a column vector from a rotation matrix.

Warning
All the indexes start from 0 in this function.
Parameters
j: Index of the column to extract. If j=0, the first column is extracted.
Returns
The extracted column vector.

The following example shows how to use this function:

#include <visp3/core/vpColVector.h>
#include <visp3/core/vpRotationMatrix.h>
int main()
{
vpColVector r = R.getCol(2);
std::cout << "Last column: \n" << r << std::endl;
}
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
vpColVector getCol(unsigned int j) const

It produces the following output:

Last column:
0
0
1
Examples
testVirtuoseHapticBox.cpp.

Definition at line 885 of file vpRotationMatrix.cpp.

References vpException::dimensionError, vpArray2D< double >::getCols(), and vpArray2D< double >::getRows().

◆ getCols()

◆ getMaxValue()

double vpArray2D< double >::getMaxValue
inherited

Return the array max value.

Examples
servoMomentImage.cpp.

Definition at line 276 of file vpArray2D.h.

◆ getMinValue()

double vpArray2D< double >::getMinValue
inherited

Return the array min value.

Examples
servoMomentImage.cpp.

Definition at line 278 of file vpArray2D.h.

◆ getRows()

◆ getThetaUVector()

vpThetaUVector vpRotationMatrix::getThetaUVector ( )

Return the $\theta {\bf u}$ vector that corresponds to the rotation matrix.

Definition at line 851 of file vpRotationMatrix.cpp.

References vpThetaUVector::buildFrom().

Referenced by vpRobotBebop2::setPosition().

◆ hadamard()

vpArray2D< double > vpArray2D< double >::hadamard ( const vpArray2D< Type > &  m) const
inherited

Compute the Hadamard product (element wise matrix multiplication).

Parameters
m: Second matrix;
Returns
m1.hadamard(m2) The Hadamard product : $ m1 \circ m2 = (m1 \circ m2)_{i,j} = (m1)_{i,j} (m2)_{i,j} $

Definition at line 572 of file vpArray2D.h.

◆ init()

vp_deprecated void vpRotationMatrix::init ( )
inline
Deprecated:
Provided only for compat with previous releases. This function does nothing.

Definition at line 207 of file vpRotationMatrix.h.

◆ insert() [1/2]

vpArray2D< double > vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
const vpArray2D< Type > &  B,
unsigned int  r,
unsigned int  c 
)
inherited

Insert array B in array A at the given position.

Parameters
A: Main array.
B: Array to insert.
r: Index of the row where to add the array.
c: Index of the column where to add the array.
Returns
Array with B insert in A.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.

Definition at line 1004 of file vpArray2D.h.

◆ insert() [2/2]

void vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
unsigned int  r,
unsigned int  c 
)
inlineinherited

Insert array A at the given position in the current array.

Warning
Throw vpException::dimensionError if the dimensions of the matrices do not allow the operation.
Parameters
A: The array to insert.
r: The index of the row to begin to insert data.
c: The index of the column to begin to insert data.

Definition at line 431 of file vpArray2D.h.

◆ inverse() [1/2]

vpRotationMatrix vpRotationMatrix::inverse ( ) const

Return the rotation matrix inverse which is also the transpose of the rotation matrix.

See also
t()
Examples
servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, testVirtuoseAfma6.cpp, and testVirtuoseHapticBox.cpp.

Definition at line 601 of file vpRotationMatrix.cpp.

References t().

Referenced by vpViper::get_eJe(), and inverse().

◆ inverse() [2/2]

void vpRotationMatrix::inverse ( vpRotationMatrix R) const

Inverse the rotation matrix.

Parameters
R(output): Inverted rotation matrix.
#include <visp3/core/vpRotationMatrix.h>
int main()
{
// ... Update rotation matrix R
// Compute the inverse in Rinv
R.inverse(Rinv);
}
vpRotationMatrix inverse() const

Definition at line 625 of file vpRotationMatrix.cpp.

References inverse().

◆ isARotationMatrix()

bool vpRotationMatrix::isARotationMatrix ( double  threshold = 1e-6) const

Test if the rotation matrix is really a rotation matrix.

Returns
true if the matrix is a rotation matrix, false otherwise.

Definition at line 430 of file vpRotationMatrix.cpp.

References vpArray2D< double >::getCols(), vpArray2D< double >::getRows(), vpMath::sqr(), and t().

Referenced by vpHomogeneousMatrix::isAnHomogeneousMatrix(), operator=(), and vpRotationMatrix().

◆ load()

static bool vpArray2D< double >::load ( const std::string &  filename,
vpArray2D< Type > &  A,
bool  binary = false,
char *  header = nullptr 
)
inlinestaticinherited

Load a matrix from a file.

Parameters
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.
Returns
Returns true if success.
See also
save()

Definition at line 600 of file vpArray2D.h.

◆ loadYAML()

static bool vpArray2D< double >::loadYAML ( const std::string &  filename,
vpArray2D< Type > &  A,
char *  header = nullptr 
)
inlinestaticinherited

Load an array from a YAML-formatted file.

Parameters
filename: absolute file name.
A: array to be loaded from the file.
header: header of the file is loaded in this parameter.
Returns
Returns true on success.
See also
saveYAML()
Examples
servoFlirPtuIBVS.cpp, servoFrankaIBVS.cpp, servoFrankaPBVS.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, and tutorial-flir-ptu-ibvs.cpp.

Definition at line 714 of file vpArray2D.h.

◆ mean() [1/2]

vpRotationMatrix vpRotationMatrix::mean ( const std::vector< vpHomogeneousMatrix > &  vec_M)
static

Compute the Euclidean mean of the rotation matrices extracted from a vector of homogeneous matrices following Moakher's method (SIAM 2002).

Parameters
[in]vec_M: Set of homogeneous matrices.
Returns
The Euclidean mean of the rotation matrices.
See also
vpTranslationVector::mean()

Definition at line 905 of file vpRotationMatrix.cpp.

References vpMatrix::pseudoInverse(), and vpMatrix::t().

◆ mean() [2/2]

vpRotationMatrix vpRotationMatrix::mean ( const std::vector< vpRotationMatrix > &  vec_R)
static

Compute the Euclidean mean of the rotation matrices following Moakher's method (SIAM 2002).

Parameters
[in]vec_R: Set of rotation matrices.
Returns
The Euclidean mean of the rotation matrices.
See also
vpTranslationVector::mean()

Definition at line 943 of file vpRotationMatrix.cpp.

References vpMatrix::pseudoInverse(), and vpMatrix::t().

◆ operator!=()

bool operator!= ( const vpArray2D< Type > &  A) const
inherited

Not equal to comparison operator of a 2D array.

Definition at line 456 of file vpArray2D.h.

◆ operator*() [1/6]

vpColVector vpRotationMatrix::operator* ( const vpColVector v) const

Operator that allows to multiply a rotation matrix by a 3 dimension column vector.

Parameters
v: Three dimension column vector.
Returns
The product of the rotation matrix by the column vector
Exceptions
vpException::dimensionErrorIf the column vector v is not a 3 dimension vector.

The code below shows how to use this operator.

#include <visp3/core/vpColVector.h>
#include <visp3/core/vpRotationMatrix.h>
int main()
{
vpColVector p1(3), p2(3);
p2 = R * p1;
return 0;
}

Definition at line 354 of file vpRotationMatrix.cpp.

References vpArray2D< double >::colNum, vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

◆ operator*() [2/6]

vpHomogeneousMatrix vpRotationMatrix::operator* ( const vpHomogeneousMatrix M) const

Operator that allows to multiply a rotation matrix by a homogeneous matrix.

Parameters
[in]M: Homogeneous matrix.
Returns
The product between the rotation matrix and the homogeneous matrix M.

The following snippet shows how to use this method:

vpHomogeneousMatrix c1_M_c3 = c1_R_c2 * c2_M_c3;
Implementation of an homogeneous matrix and operations on such kind of matrices.

Definition at line 320 of file vpRotationMatrix.cpp.

References vpHomogeneousMatrix::getRotationMatrix(), and vpHomogeneousMatrix::getTranslationVector().

◆ operator*() [3/6]

vpMatrix vpRotationMatrix::operator* ( const vpMatrix M) const

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.

Parameters
[in]M: 3-by-3 matrix.
Returns
The product between the rotation matrix and the 3-by-3 matrix M.
Exceptions
vpException::dimensionError: If M is not a 3-by-3 dimension matrix.

The following snippet shows how to use this method:

vpMatrix M = t.skew();
vpMatrix RM = R * M;
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
vpRotationMatrix t() const
Class that consider the case of a translation vector.

Definition at line 287 of file vpRotationMatrix.cpp.

References vpException::dimensionError, vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

◆ operator*() [4/6]

vpRotationMatrix vpRotationMatrix::operator* ( const vpRotationMatrix R) const

Compute the product between two rotation matrices.

Definition at line 255 of file vpRotationMatrix.cpp.

References vpArray2D< Type >::rowPtrs, and vpArray2D< double >::rowPtrs.

◆ operator*() [5/6]

vpTranslationVector vpRotationMatrix::operator* ( const vpTranslationVector tv) const

Multiply a rotation matrix by a translation vector and return the resulting translation vector.

Definition at line 378 of file vpRotationMatrix.cpp.

References vpArray2D< double >::rowPtrs.

◆ operator*() [6/6]

vpRotationMatrix vpRotationMatrix::operator* ( double  x) const

Operator that allows to multiply all the elements of a rotation matrix by a scalar.

Definition at line 398 of file vpRotationMatrix.cpp.

References vpArray2D< double >::colNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

◆ operator*=()

vpRotationMatrix & vpRotationMatrix::operator*= ( double  x)

Operator that allows to multiply all the elements of a rotation matrix by a scalar.

Definition at line 413 of file vpRotationMatrix.cpp.

References vpArray2D< double >::colNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

◆ operator,()

vpRotationMatrix & vpRotationMatrix::operator, ( double  val)

Set the second and next element of the rotation matrix.

Parameters
val: Value of the matrix second or next element.
Returns
An updated matrix.

The following example shows how to initialize a rotation matrix using this operator.

#include <visp3/core/vpRotationMatrix.h>
int main()
{
R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
std::cout << "R:\n" << R << std::endl;
}

It produces the following printings:

R:
0 0 -1
0 -1 0
-1 0 0
See also
operator<<()

Definition at line 239 of file vpRotationMatrix.cpp.

References vpArray2D< double >::data, vpException::dimensionError, m_index, and vpArray2D< double >::size().

◆ operator<<()

vpRotationMatrix & vpRotationMatrix::operator<< ( double  val)

Set rotation matrix first element.

Parameters
val: Value of the matrix first element.
Returns
An updated matrix.

The following example shows how to initialize a rotation matrix using this operator.

#include <visp3/core/vpRotationMatrix.h>
int main()
{
R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
std::cout << "R:\n" << R << std::endl;
}

It produces the following printings:

R:
0 0 -1
0 -1 0
-1 0 0
See also
operator,()

Definition at line 205 of file vpRotationMatrix.cpp.

References vpArray2D< double >::data, and m_index.

◆ operator=() [1/3]

vpRotationMatrix & vpRotationMatrix::operator= ( const std::initializer_list< double > &  list)

Set a rotation matrix from a list of 9 double values.

Parameters
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()
{
R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
}
It produces the following output:
R:
0 0 -1
0 -1 0
-1 0 0
See also
operator<<()

Definition at line 116 of file vpRotationMatrix.cpp.

References vpArray2D< double >::data, vpException::dimensionError, vpArray2D< double >::dsize, vpException::fatalError, isARotationMatrix(), and orthogonalize().

◆ operator=() [2/3]

vpRotationMatrix & vpRotationMatrix::operator= ( const vpMatrix M)

Converts a 3-by-3 matrix into a rotation matrix.

Parameters
M: Input matrix.
vpMatrix M(3, 3);
M.eye()
Exceptions
vpException::fatalErrorIf the input matrix is not a rotation matrix.
See also
isARotationMatrix()

Definition at line 156 of file vpRotationMatrix.cpp.

References vpException::dimensionError, vpException::fatalError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), and isARotationMatrix().

◆ operator=() [3/3]

vpRotationMatrix & vpRotationMatrix::operator= ( const vpRotationMatrix R)

Set the current rotation matrix from a rotation matrix R.

Parameters
R: Rotation matrix.
static double rad(double deg)
Definition: vpMath.h:127

Definition at line 81 of file vpRotationMatrix.cpp.

References vpArray2D< Type >::rowPtrs, and vpArray2D< double >::rowPtrs.

◆ operator==()

bool vpArray2D< double >::operator== ( const vpArray2D< Type > &  A) const
inherited

Equal to comparison operator of a 2D array.

Definition at line 452 of file vpArray2D.h.

◆ operator[]() [1/2]

double * vpArray2D< double >::operator[] ( unsigned int  i)
inlineinherited

Set element $A_{ij} = x$ using A[i][j] = x.

Definition at line 538 of file vpArray2D.h.

◆ operator[]() [2/2]

double * vpArray2D< double >::operator[] ( unsigned int  i) const
inlineinherited

Get element $x = A_{ij}$ using x = A[i][j].

Definition at line 540 of file vpArray2D.h.

◆ orthogonalize()

void vpRotationMatrix::orthogonalize ( )

◆ printVector()

void vpRotationMatrix::printVector ( )

Print to std::cout the rotation matrix as a $ \theta {\bf u} $ angle representation vector.

Definition at line 631 of file vpRotationMatrix.cpp.

◆ reshape()

void vpArray2D< double >::reshape ( unsigned int  nrows,
unsigned int  ncols 
)
inlineinherited
Examples
testMatrixInitialization.cpp.

Definition at line 390 of file vpArray2D.h.

◆ resize() [1/2]

void vpRotationMatrix::resize ( unsigned int  nrows,
unsigned int  ncols,
bool  flagNullify = true 
)
inline

This function is not applicable to a rotation matrix that is always a 3-by-3 matrix.

Exceptions
vpException::fatalErrorWhen this function is called.

Definition at line 184 of file vpRotationMatrix.h.

References vpException::fatalError.

◆ resize() [2/2]

void vpArray2D< double >::resize ( unsigned int  nrows,
unsigned int  ncols,
bool  flagNullify = true,
bool  recopy_ = true 
)
inlineinherited

Set the size of the array and initialize all the values to zero.

Parameters
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.
Examples
testArray2D.cpp, testMatrix.cpp, testMatrixDeterminant.cpp, testMatrixInverse.cpp, testMatrixPseudoInverse.cpp, and testSvd.cpp.

Definition at line 299 of file vpArray2D.h.

◆ save()

static bool vpArray2D< double >::save ( const std::string &  filename,
const vpArray2D< Type > &  A,
bool  binary = false,
const char *  header = "" 
)
inlinestaticinherited

Save a matrix to a file.

Parameters
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.
Returns
Returns true if success.

Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.

See also
load()

Definition at line 802 of file vpArray2D.h.

◆ saveYAML()

static bool vpArray2D< double >::saveYAML ( const std::string &  filename,
const vpArray2D< Type > &  A,
const char *  header = "" 
)
inlinestaticinherited

Save an array in a YAML-formatted file.

Parameters
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.
Returns
Returns true if success.

Here is an example of outputs.

vpArray2D::saveYAML("matrix.yml", M, "example: a YAML-formatted header");
vpArray2D::saveYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted \
header\n - with inner indentation");
static bool saveYAML(const std::string &filename, const vpArray2D< Type > &A, const char *header="")
Definition: vpArray2D.h:897

Content of matrix.yml:

example: a YAML-formatted header
rows: 3
cols: 4
- [0, 0, 0, 0]
- [0, 0, 0, 0]
- [0, 0, 0, 0]
double * data
Address of the first element of the data array.
Definition: vpArray2D.h:138

Content of matrixIndent.yml:

example:
- a YAML-formatted header
- with inner indentation
rows: 3
cols: 4
- [0, 0, 0, 0]
- [0, 0, 0, 0]
- [0, 0, 0, 0]
See also
loadYAML()

Definition at line 897 of file vpArray2D.h.

◆ setIdentity()

void vpRotationMatrix::setIdentity ( )
Deprecated:
You should rather use eye().
Deprecated:
You should rather use eye().

Initializes the rotation matrix as identity.

See also
eye()

Definition at line 1013 of file vpRotationMatrix.cpp.

References eye().

◆ size()

◆ t()

vpRotationMatrix vpRotationMatrix::t ( ) const

Return the rotation matrix transpose which is also the inverse of the rotation matrix.

See also
inverse()
Examples
testMathUtils.cpp.

Definition at line 584 of file vpRotationMatrix.cpp.

Referenced by vpVelocityTwistMatrix::extract(), vpHomogeneousMatrix::inverse(), inverse(), vpVelocityTwistMatrix::inverse(), isARotationMatrix(), and vpSimulatorAfma6::setPosition().

Friends And Related Function Documentation

◆ insert()

void vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
const vpArray2D< Type > &  B,
vpArray2D< Type > &  C,
unsigned int  r,
unsigned int  c 
)
related

Insert array B in array A at the given position.

Parameters
A: Main array.
B: Array to insert.
C: Result array.
r: Index of the row where to insert array B.
c: Index of the column where to insert array B.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.

Definition at line 1019 of file vpArray2D.h.

◆ operator!=()

bool operator!= ( const vpArray2D< Type > &  A) const
related

Definition at line 1247 of file vpArray2D.h.

◆ operator==() [1/2]

bool operator== ( const vpArray2D< double > &  A) const
related

Definition at line 1211 of file vpArray2D.h.

◆ operator==() [2/2]

bool operator== ( const vpArray2D< float > &  A) const
related

Definition at line 1229 of file vpArray2D.h.

◆ vpGEMM()

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 
)
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 :

vpGEMM(A, B, alpha, C, beta, D, VP_GEMM_A_T + VP_GEMM_B_T);
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)
Definition: vpGEMM.h:388

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:

vpGEMM(A, B, alpha, null, 0, D, VP_GEMM_B_T);
Exceptions
vpException::incorrectMatrixSizeErrorif the sizes of the matrices do not allow the operations.
Parameters
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.

Definition at line 388 of file vpGEMM.h.

◆ vpGEMMmethod

enum vpGEMMmethod
related

Enumeration of the operations applied on matrices in vpGEMM() function.

Operations are :

  • VP_GEMM_A_T to use the transpose matrix of A instead of the matrix A
  • VP_GEMM_B_T to use the transpose matrix of B instead of the matrix B
  • VP_GEMM_C_T to use the transpose matrix of C instead of the matrix C

Definition at line 52 of file vpGEMM.h.

Member Data Documentation

◆ colNum

unsigned int vpArray2D< double >::colNum
protectedinherited

Number of columns in the array.

Definition at line 130 of file vpArray2D.h.

◆ data

double * vpArray2D< double >::data
inherited

◆ dsize

unsigned int vpArray2D< double >::dsize
protectedinherited

Current array size (rowNum * colNum)

Definition at line 134 of file vpArray2D.h.

◆ m_index

unsigned int vpRotationMatrix::m_index
protected

Definition at line 216 of file vpRotationMatrix.h.

Referenced by operator,(), and operator<<().

◆ rowNum

unsigned int vpArray2D< double >::rowNum
protectedinherited

Number of rows in the array.

Definition at line 128 of file vpArray2D.h.

◆ rowPtrs

double ** vpArray2D< double >::rowPtrs
protectedinherited

Address of the first element of each rows.

Definition at line 132 of file vpArray2D.h.