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.
__init__(self: visp._visp.core.RotationMatrix) -> None
Default constructor that initialise a 3-by-3 rotation matrix to identity.
__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.
__init__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.ThetaUVector) -> None
__init__(self: visp._visp.core.RotationMatrix, p: visp._visp.core.PoseVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyzVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RxyzVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyxVector) -> None
__init__(self: visp._visp.core.RotationMatrix, q: visp._visp.core.QuaternionVector) -> None
__init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.Matrix) -> None
__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.
__init__(self: visp._visp.core.RotationMatrix, list: std::initializer_list<double>) -> None
__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
Overloaded function.
Overloaded function.
Initialize the rotation matrix as identity.
The following example shows how to use this function:
Return the \(\theta {\bf u}\) vector that corresponds to the rotation matrix.
Overloaded function.
Test if the rotation matrix is really a rotation matrix.
Overloaded function.
Numpy view of the underlying array data.
Perform rotation matrix orthogonalization.
Print to std::cout the rotation matrix as a \(\theta {\bf u}\) angle representation vector.
Overloaded function.
Overloaded function.
Inherited Methods
Return the number of elements of the 2D array.
Return the number of rows of the 2D array.
Return the number of columns of the 2D array.
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Operators
__doc__
Overloaded function.
Operator that allows to multiply all the elements of a rotation matrix by a scalar.
Overloaded function.
__module__
Overloaded function.
Attributes
__annotations__
- __eq__(*args, **kwargs)¶
Overloaded function.
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
- __getitem__(*args, **kwargs)¶
Overloaded function.
__getitem__(self: visp._visp.core.RotationMatrix, arg0: tuple[int, int]) -> float
__getitem__(self: visp._visp.core.RotationMatrix, arg0: int) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.RotationMatrix, arg0: slice) -> numpy.ndarray[numpy.float64]
__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.
__init__(self: visp._visp.core.RotationMatrix) -> None
Default constructor that initialise a 3-by-3 rotation matrix to identity.
__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.
__init__(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.ThetaUVector) -> None
__init__(self: visp._visp.core.RotationMatrix, p: visp._visp.core.PoseVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyzVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RxyzVector) -> None
__init__(self: visp._visp.core.RotationMatrix, r: visp._visp.core.RzyxVector) -> None
__init__(self: visp._visp.core.RotationMatrix, q: visp._visp.core.QuaternionVector) -> None
__init__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.Matrix) -> None
__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.
__init__(self: visp._visp.core.RotationMatrix, list: std::initializer_list<double>) -> None
__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.
__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.
__mul__(self: visp._visp.core.RotationMatrix, R: visp._visp.core.RotationMatrix) -> visp._visp.core.RotationMatrix
Compute the product between two rotation matrices.
__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 .
__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 .
__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
__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.
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
- __setitem__(*args, **kwargs)¶
Overloaded function.
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int], arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[slice, slice], arg1: float) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: int, arg1: numpy.ndarray[numpy.float64]) -> None
__setitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice, arg1: numpy.ndarray[numpy.float64]) -> None
- buildFrom(*args, **kwargs)¶
Overloaded function.
buildFrom(self: visp._visp.core.RotationMatrix, M: visp._visp.core.HomogeneousMatrix) -> visp._visp.core.RotationMatrix
Build a rotation matrix from an homogeneous matrix.
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 \]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 &)
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\) )
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\) )
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\) )
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.
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.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
- 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
- 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.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None
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.
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()
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.
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.
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.
- printVector(self) None ¶
Print to std::cout the rotation matrix as a \(\theta {\bf u}\) angle representation vector.
- resize(*args, **kwargs)¶
Overloaded function.
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.
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.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
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 ¶
- t(*args, **kwargs)¶
Overloaded function.
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()
t(self: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
- static view(*args, **kwargs)¶
Overloaded function.
view(A: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
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
¶