RotationMatrix

class RotationMatrix(*args, **kwargs)

Bases: ArrayDouble2D

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>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpRotationMatrix R;
  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;
  }
}

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>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpRotationMatrix R;
  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

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpRotationMatrix R{ 0, 0, -1, 0, -1, 0, -1, 0, 0 };
  std::cout << "R:\n" << R << std::endl;
}

Overloaded function.

  1. __init__(self: visp._visp.core.RotationMatrix) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.RotationMatrix) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> None

  2. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.ThetaUVector) -> None

  3. __init__(self: visp._visp.core.RotationMatrix, p: visp._visp.core.PoseVector) -> None

  4. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyzVector) -> None

  5. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RxyzVector) -> None

  6. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyxVector) -> None

  7. __init__(self: visp._visp.core.RotationMatrix, q: visp._visp.core.QuaternionVector) -> None

  8. __init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.Matrix) -> None

  9. __init__(self: visp._visp.core.RotationMatrix, tux: float, tuy: float, tuz: float) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, list: std::initializer_list<double>) -> None

  2. __init__(self: visp._visp.core.RotationMatrix, np_array: numpy.ndarray[numpy.float64]) -> None

Construct a rotation matrix by copying a 2D numpy array. This numpy array should be of dimensions \(3 \times 3\) and be a valid rotation matrix. If it is not a rotation matrix, an exception will be raised.

Parameters:
np_array

The numpy 1D array to copy.

Methods

__init__

Overloaded function.

buildFrom

Overloaded function.

eye

Initialize the rotation matrix as identity.

getCol

The following example shows how to use this function:

getThetaUVector

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

inverse

Overloaded function.

isARotationMatrix

Test if the rotation matrix is really a rotation matrix.

mean

Overloaded function.

numpy

Numpy view of the underlying array data.

orthogonalize

Perform rotation matrix orthogonalization.

printVector

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

resize

Overloaded function.

t

Overloaded function.

Inherited Methods

getMaxValue

insertStatic

size

Return the number of elements of the 2D array.

getRows

Return the number of rows of the 2D array.

getCols

Return the number of columns of the 2D array.

insert

Overloaded function.

hadamard

conv2

Overloaded function.

save

Overloaded function.

view

Overloaded function.

saveYAML

getMinValue

reshape

Operators

__doc__

__getitem__

Overloaded function.

__imul__

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

__init__

Overloaded function.

__module__

__mul__

Overloaded function.

Attributes

__annotations__

__hash__

__eq__(*args, **kwargs)

Overloaded function.

  1. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  2. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  3. __eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: visp._visp.core.RotationMatrix, arg0: tuple[int, int]) -> float

  2. __getitem__(self: visp._visp.core.RotationMatrix, arg0: int) -> numpy.ndarray[numpy.float64]

  3. __getitem__(self: visp._visp.core.RotationMatrix, arg0: slice) -> numpy.ndarray[numpy.float64]

  4. __getitem__(self: visp._visp.core.RotationMatrix, arg0: tuple) -> numpy.ndarray[numpy.float64]

__imul__(self, x: float) visp.core.RotationMatrix

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

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.core.RotationMatrix) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.RotationMatrix) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> None

  2. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.ThetaUVector) -> None

  3. __init__(self: visp._visp.core.RotationMatrix, p: visp._visp.core.PoseVector) -> None

  4. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyzVector) -> None

  5. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RxyzVector) -> None

  6. __init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyxVector) -> None

  7. __init__(self: visp._visp.core.RotationMatrix, q: visp._visp.core.QuaternionVector) -> None

  8. __init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.Matrix) -> None

  9. __init__(self: visp._visp.core.RotationMatrix, tux: float, tuy: float, tuz: float) -> None

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

  1. __init__(self: visp._visp.core.RotationMatrix, list: std::initializer_list<double>) -> None

  2. __init__(self: visp._visp.core.RotationMatrix, np_array: numpy.ndarray[numpy.float64]) -> None

Construct a rotation matrix by copying a 2D numpy array. This numpy array should be of dimensions \(3 \times 3\) and be a valid rotation matrix. If it is not a rotation matrix, an exception will be raised.

Parameters:
np_array

The numpy 1D array to copy.

__mul__(*args, **kwargs)

Overloaded function.

  1. __mul__(self: visp._visp.core.RotationMatrix, tv: visp._visp.core.TranslationVector) -> visp._visp.core.TranslationVector

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

  1. __mul__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.RotationMatrix) -> visp._visp.core.RotationMatrix

Compute the product between two rotation matrices.

  1. __mul__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> visp._visp.core.HomogeneousMatrix

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

The following snippet shows how to use this method:

vpRotationMatrix c1_R_c2;
vpHomogeneousMatrix c2_M_c3;
vpHomogeneousMatrix c1_M_c3 = c1_R_c2 * c2_M_c3;
Parameters:
M

Homogeneous matrix.

Returns:

The product between the rotation matrix and the homogeneous matrix M .

  1. __mul__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.Matrix) -> visp._visp.core.Matrix

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.

The following snippet shows how to use this method:

vpRotationMatrix R;
vpTranslationVector t;
vpMatrix M = t.skew();
vpMatrix RM = R * M;
Parameters:
M

3-by-3 matrix.

Returns:

The product between the rotation matrix and the 3-by-3 matrix M .

  1. __mul__(self: visp._visp.core.RotationMatrix, v: visp._visp.core.ColVector) -> visp._visp.core.ColVector

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

The code below shows how to use this operator.

#include <visp3/core/vpColVector.h>
#include <visp3/core/vpRotationMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpColVector p1(3), p2(3);
  vpRotationMatrix R;

  p2 = R * p1;

  return 0;
}
Parameters:
v

Three dimension column vector.

Returns:

The product of the rotation matrix by the column vector

  1. __mul__(self: visp._visp.core.RotationMatrix, x: float) -> visp._visp.core.RotationMatrix

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

__ne__(*args, **kwargs)

Overloaded function.

  1. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  2. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

  3. __ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool

__setitem__(*args, **kwargs)

Overloaded function.

  1. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int], arg1: float) -> None

  2. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: float) -> None

  3. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: float) -> None

  4. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[slice, slice], arg1: float) -> None

  5. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None

  6. __setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: numpy.ndarray[numpy.float64]) -> None

buildFrom(*args, **kwargs)

Overloaded function.

  1. buildFrom(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> visp._visp.core.RotationMatrix

Build a rotation matrix from an homogeneous matrix.

  1. buildFrom(self: visp._visp.core.RotationMatrix, v: visp._visp.core.ThetaUVector) -> visp._visp.core.RotationMatrix

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 \]
  1. buildFrom(self: visp._visp.core.RotationMatrix, p: visp._visp.core.PoseVector) -> visp._visp.core.RotationMatrix

Build a rotation matrix from a pose vector.

Note

See buildFrom(const vpThetaUVector &)

  1. buildFrom(self: visp._visp.core.RotationMatrix, v: visp._visp.core.RzyzVector) -> visp._visp.core.RotationMatrix

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

  1. buildFrom(self: visp._visp.core.RotationMatrix, v: visp._visp.core.RxyzVector) -> visp._visp.core.RotationMatrix

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

  1. buildFrom(self: visp._visp.core.RotationMatrix, v: visp._visp.core.RzyxVector) -> visp._visp.core.RotationMatrix

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

  1. buildFrom(self: visp._visp.core.RotationMatrix, q: visp._visp.core.QuaternionVector) -> visp._visp.core.RotationMatrix

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

  1. buildFrom(self: visp._visp.core.RotationMatrix, tux: float, tuy: float, tuz: float) -> visp._visp.core.RotationMatrix

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

static conv2(*args, **kwargs)

Overloaded function.

  1. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D

  2. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None

  3. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D

  4. conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None

eye(self) None

Initialize the rotation matrix as identity.

Note

See setIdentity()

getCol(self, j: int) visp.core.ColVector

The following example shows how to use this function:

#include <visp3/core/vpColVector.h>
#include <visp3/core/vpRotationMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpRotationMatrix R;

  vpColVector r = R.getCol(2);
  std::cout << "Last column: \n" << r << std::endl;
}

It produces the following output:

Last column:
0
0
1
Parameters:
j: int

Index of the column to extract. If j=0, the first column is extracted.

Returns:

The extracted column vector.

getCols(self) int

Return the number of columns of the 2D array.

Note

See getRows() , size()

getMaxValue(self) float
getMinValue(self) float
getRows(self) int

Return the number of rows of the 2D array.

Note

See getCols() , size()

getThetaUVector(self) visp.core.ThetaUVector

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

hadamard(self, m: visp.core.ArrayDouble2D) visp.core.ArrayDouble2D
insert(*args, **kwargs)

Overloaded function.

  1. insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None

  2. insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, r: int, c: int) -> visp._visp.core.ArrayDouble2D

static insertStatic(A: visp.core.ArrayDouble2D, B: visp.core.ArrayDouble2D, C: visp.core.ArrayDouble2D, r: int, c: int) None
inverse(*args, **kwargs)

Overloaded function.

  1. inverse(self: visp._visp.core.RotationMatrix) -> visp._visp.core.RotationMatrix

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

Note

See t()

  1. inverse(self: visp._visp.core.RotationMatrix, R: visp._visp.core.RotationMatrix) -> None

Inverse the rotation matrix.

#include <visp3/core/vpRotationMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpRotationMatrix R, Rinv;
  // ... Update rotation matrix R
  // Compute the inverse in Rinv
  R.inverse(Rinv);
}
Parameters:
R

(output): Inverted rotation matrix.

isARotationMatrix(self, threshold: float = 1e-6) bool

Test if the rotation matrix is really a rotation matrix.

Returns:

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

static mean(*args, **kwargs)

Overloaded function.

  1. mean(vec_M: list[visp._visp.core.HomogeneousMatrix]) -> visp._visp.core.RotationMatrix

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

Note

See vpTranslationVector::mean()

Parameters:
vec_M

Set of homogeneous matrices.

Returns:

The Euclidean mean of the rotation matrices.

  1. mean(vec_R: list[visp._visp.core.RotationMatrix]) -> visp._visp.core.RotationMatrix

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

Note

See vpTranslationVector::mean()

Parameters:
vec_R

Set of rotation matrices.

Returns:

The Euclidean mean of the rotation matrices.

numpy(self) numpy.ndarray[numpy.float64]

Numpy view of the underlying array data. This numpy view cannot be modified. If you try to modify the array, an exception will be raised.

orthogonalize(self) None

Perform rotation matrix orthogonalization.

printVector(self) None

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

reshape(self, nrows: int, ncols: int) None
resize(*args, **kwargs)

Overloaded function.

  1. resize(self: visp._visp.core.RotationMatrix, nrows: int, ncols: int, flagNullify: bool = true) -> None

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

  1. resize(self: visp._visp.core.ArrayDouble2D, nrows: int, ncols: int, flagNullify: bool = true, recopy_: bool = true) -> None

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.

static save(*args, **kwargs)

Overloaded function.

  1. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

  2. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

  3. save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool

static saveYAML(filename: str, A: visp._visp.core.ArrayDouble2D, header: str =) bool
size(self) int

Return the number of elements of the 2D array.

t(*args, **kwargs)

Overloaded function.

  1. t(self: visp._visp.core.RotationMatrix) -> visp._visp.core.RotationMatrix

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

Note

See inverse()

  1. t(self: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D

static view(*args, **kwargs)

Overloaded function.

  1. view(A: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D

  2. view(np_array: numpy.ndarray[numpy.float64]) -> visp._visp.core.ArrayDouble2D

Construct a 2D ViSP array that is a view of a numpy array. When it is modified, the numpy array is also modified. It cannot be resized.

Parameters:
np_array

The numpy array to copy.

__hash__ = None