RzyxVector¶
- class RzyxVector(*args, **kwargs)¶
Bases:
RotationVector
Implementation of a rotation vector as \(R(z,y,x)\) Euler angle minimal representation.
Class that consider the case of the Euler \((\varphi,\theta,\psi)\) angle using the z-y-x convention, where \((\varphi,\theta,\psi)\) are respectively the rotation angles around the \(z\) , \(y\) and \(x\) axis.
\[R_{zyx}(\varphi,\theta,\psi) = R_z(\varphi) \; R_y(\theta) \; R_x(\psi)\]with
\[\begin{split}R_{z}(\varphi) = \left( \begin{array}{ccc} \cos \varphi & -\sin\varphi & 0\\\sin\varphi &\cos \varphi& 0 \\0 & 0 & 1 \end{array} \right) \; R_{y}(\theta) = \left( \begin{array}{ccc} \cos \theta & 0 & \sin\theta\\0 & 1 & 0 \\-\sin\theta & 0 &\cos \theta \end{array} \right) \; R_{x}(\psi) = \left( \begin{array}{ccc} 1 & 0 & 0 \\0 &\cos \psi & -\sin\psi \\0 &\sin \psi & \cos\psi \\\end{array} \right) \end{split}\]The rotation matrix corresponding to the z-y-x convention is given by:
\[\begin{split}R_{zyx}(\varphi,\theta,\psi) = \left( \begin{array}{ccc} \cos\varphi \cos\theta & -\sin\varphi \cos\psi + \cos\varphi\sin\theta\sin\psi & \sin\varphi \sin\psi +\cos\varphi\sin\theta\cos\psi \\\sin\varphi \cos\theta & \cos\varphi\cos\psi + \sin\varphi\sin\theta \sin\psi & -\cos\varphi \sin\psi +\sin\varphi\sin\theta\cos\psi \\-\sin\theta & \cos\theta \sin\psi & \cos\theta \cos\psi \end{array} \right) \end{split}\]The vpRzyxVector class is derived from vpRotationVector .
From the implementation point of view, it is nothing more than an array of three doubles with values in [rad].
You can set values [rad] accessing each element:
vpRzyxVector rzyx; rzyx[0] = M_PI_4; rzyx[1] = M_PI_2; rzyx[2] = M_PI;
You can also initialize the vector using operator<<(double) :
rzyx << M_PI_4, M_PI_2, M_PI;
Or you can also initialize the vector from a list of doubles if ViSP is build with c++11 enabled:
rzyx = {M_PI_4, M_PI_2, M_PI};
To get the values [rad] use:
double rz = rzyx[0]; double ry = rzyx[1]; double rx = rzyx[2];
The code below shows first how to initialize this representation of Euler angles, than how to construct a rotation matrix from a vpRzyxVector and finally how to extract the vpRzyxVector Euler angles from the build rotation matrix.
#include <visp3/core/vpMath.h> #include <visp3/core/vpRotationMatrix.h> #include <visp3/core/vpRzyxVector.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpRzyxVector rzyx; // Initialise the Euler angles rzyx[0] = vpMath::rad( 45.f); // phi angle in rad/s around z axis rzyx[1] = vpMath::rad(-30.f); // theta angle in rad/s around y axis rzyx[2] = vpMath::rad( 90.f); // psi angle in rad/s around x axis // Construct a rotation matrix from the Euler angles vpRotationMatrix R(rzyx); // Extract the Euler angles around z,y,x axis from a rotation matrix rzyx.buildFrom(R); // Print the extracted Euler angles. Values are the same than the // one used for initialization std::cout << rzyx; // Since the rotation vector is 3 values column vector, the // transpose operation produce a row vector. vpRowVector rzyx_t = rzyx.t(); // Print the transpose row vector std::cout << rzyx_t << std::endl; }
Overloaded function.
__init__(self: visp._visp.core.RzyxVector) -> None
Default constructor that initialize all the 3 angles to zero.
__init__(self: visp._visp.core.RzyxVector, rzyx: visp._visp.core.RzyxVector) -> None
Copy constructor.
__init__(self: visp._visp.core.RzyxVector, phi: float, theta: float, psi: float) -> None
Constructor from 3 angles (in radian).
- Parameters:
- phi
math:varphi angle around the \(z\) axis.
- theta
math:theta angle around the \(y\) axis.
- psi
math:psi angle around the \(x\) axis.
__init__(self: visp._visp.core.RzyxVector, R: visp._visp.core.RotationMatrix) -> None
__init__(self: visp._visp.core.RzyxVector, tu: visp._visp.core.ThetaUVector) -> None
__init__(self: visp._visp.core.RzyxVector, rzyx: visp._visp.core.ColVector) -> None
__init__(self: visp._visp.core.RzyxVector, rzyx: list[float]) -> None
Methods
Overloaded function.
Overloaded function.
Inherited Methods
Return the array max value.
- param m:
Second matrix;
Overloaded function.
- return:
The corresponding std::vector<double>.
Return the sum square of all the elements \(r_{i}\) of the rotation vector r(m).
Insert array B in array A at the given position.
Return the number of rows of the 2D array.
Overloaded function.
Overloaded function.
Numpy view of the underlying array data.
Save an array in a YAML-formatted file.
Set the size of the array and initialize all the values to zero.
Return the array min value.
Return the number of columns of the 2D array.
Overloaded function.
Return the number of elements of the 2D array.
Operators
__doc__
Overloaded function.
__module__
Attributes
__annotations__
- __eq__(*args, **kwargs)¶
Overloaded function.
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Equal to comparison operator of a 2D array.
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Equal to comparison operator of a 2D array.
__eq__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Equal to comparison operator of a 2D array.
- __getitem__(*args, **kwargs)¶
Overloaded function.
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple[int, int]) -> float
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: int) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: slice) -> numpy.ndarray[numpy.float64]
__getitem__(self: visp._visp.core.ArrayDouble2D, arg0: tuple) -> numpy.ndarray[numpy.float64]
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.RzyxVector) -> None
Default constructor that initialize all the 3 angles to zero.
__init__(self: visp._visp.core.RzyxVector, rzyx: visp._visp.core.RzyxVector) -> None
Copy constructor.
__init__(self: visp._visp.core.RzyxVector, phi: float, theta: float, psi: float) -> None
Constructor from 3 angles (in radian).
- Parameters:
- phi
math:varphi angle around the \(z\) axis.
- theta
math:theta angle around the \(y\) axis.
- psi
math:psi angle around the \(x\) axis.
__init__(self: visp._visp.core.RzyxVector, R: visp._visp.core.RotationMatrix) -> None
__init__(self: visp._visp.core.RzyxVector, tu: visp._visp.core.ThetaUVector) -> None
__init__(self: visp._visp.core.RzyxVector, rzyx: visp._visp.core.ColVector) -> None
__init__(self: visp._visp.core.RzyxVector, rzyx: list[float]) -> None
- __mul__(*args, **kwargs)¶
Overloaded function.
__mul__(self: visp._visp.core.RotationVector, x: float) -> visp._visp.core.ColVector
Operator that allows to multiply each element of a rotation vector by a scalar.
- Parameters:
- x
The scalar.
- Returns:
The rotation vector multiplied by the scalar as a column vector. The current rotation vector (*this) is unchanged.
__mul__(self: visp._visp.core.RotationVector, x: float) -> visp._visp.core.ColVector
Operator that allows to multiply each element of a rotation vector by a scalar.
- Parameters:
- x
The scalar.
- Returns:
The rotation vector multiplied by the scalar as a column vector. The current rotation vector (*this) is unchanged.
__mul__(self: visp._visp.core.RotationVector, x: float) -> visp._visp.core.ColVector
Operator that allows to multiply each element of a rotation vector by a scalar.
- Parameters:
- x
The scalar.
- Returns:
The rotation vector multiplied by the scalar as a column vector. The current rotation vector (*this) is unchanged.
- __ne__(*args, **kwargs)¶
Overloaded function.
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Not equal to comparison operator of a 2D array.
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Not equal to comparison operator of a 2D array.
__ne__(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D) -> bool
Not equal to comparison operator of a 2D array.
- buildFrom(*args, **kwargs)¶
Overloaded function.
buildFrom(self: visp._visp.core.RzyxVector, R: visp._visp.core.RotationMatrix) -> visp._visp.core.RzyxVector
Convert a rotation matrix into a \(R_{zyx}=(\varphi,\theta,\psi)\) Euler angles vector.
Source: R. Paul, Robot Manipulators: Mathematics, Programming, and Control. MIT Press, 1981, p. 71
- Parameters:
- R
Rotation matrix used as input.
- Returns:
\(R_{zyx}=(\varphi,\theta,\psi)\) Euler angles vector.
buildFrom(self: visp._visp.core.RzyxVector, R: visp._visp.core.ThetaUVector) -> visp._visp.core.RzyxVector
- Returns:
\(R_{zyx}=(\varphi,\theta,\psi)\) Euler angles vector.
buildFrom(self: visp._visp.core.RzyxVector, rxyz: visp._visp.core.ColVector) -> visp._visp.core.RzyxVector
Construct a \(R_{zyx}=(\varphi,\theta,\psi)\) Euler angles vector from a 3-dim vector.
buildFrom(self: visp._visp.core.RzyxVector, rxyz: list[float]) -> visp._visp.core.RzyxVector
Construct a \(R_{zyx}=(\varphi,\theta,\psi)\) Euler angles vector from a 3-dim vector.
buildFrom(self: visp._visp.core.RzyxVector, phi: float, theta: float, psi: float) -> visp._visp.core.RzyxVector
Construction from 3 angles (in radian).
- Parameters:
- phi
math:varphi angle around the \(z\) axis.
- theta
math:theta angle around the \(y\) axis.
- psi
math:psi angle around the \(x\) axis.
- static conv2(*args, **kwargs)¶
Overloaded function.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb6a440>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First matrix.
- kernel
Second matrix.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb8c0a0>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First array.
- kernel
Second array.
- res
Result.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, mode: str) -> visp._visp.core.ArrayDouble2D
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb6a440>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First matrix.
- kernel
Second matrix.
- mode
Convolution mode: “full” (default), “same”, “valid”.
conv2(M: visp._visp.core.ArrayDouble2D, kernel: visp._visp.core.ArrayDouble2D, res: visp._visp.core.ArrayDouble2D, mode: str) -> None
Perform a 2D convolution similar to Matlab conv2 function: \(M \star kernel\) .
<unparsed image <doxmlparser.compound.docImageType object at 0x7f122fb8c0a0>>
Note
This is a very basic implementation that does not use FFT.
- Parameters:
- M
First array.
- kernel
Second array.
- res
Result.
- mode
Convolution mode: “full” (default), “same”, “valid”.
- hadamard(self, m: visp._visp.core.ArrayDouble2D) visp._visp.core.ArrayDouble2D ¶
- Parameters:
- m: visp._visp.core.ArrayDouble2D¶
Second matrix;
- Returns:
m1.hadamard(m2) The Hadamard product : \(m1 \circ m2 = (m1 \circ m2)_{i,j} = (m1)_{i,j} (m2)_{i,j}\)
- insert(*args, **kwargs)¶
Overloaded function.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, r: int, c: int) -> None
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.
insert(self: visp._visp.core.ArrayDouble2D, A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, r: int, c: int) -> visp._visp.core.ArrayDouble2D
Insert array B in array A at the given position.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.
- 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.
- static insertStatic(A: visp._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, C: visp._visp.core.ArrayDouble2D, r: int, c: int) None ¶
Insert array B in array A at the given position.
Warning
Throw exception if the sizes of the arrays do not allow the insertion.
- Parameters:
- A: visp._visp.core.ArrayDouble2D¶
Main array.
- B: visp._visp.core.ArrayDouble2D¶
Array to insert.
- C: visp._visp.core.ArrayDouble2D¶
Result array.
- r: int¶
Index of the row where to insert array B.
- c: int¶
Index of the column where to insert array B.
- numpy(self) numpy.ndarray[numpy.float64] ¶
Numpy view of the underlying array data. This numpy view can be used to directly modify the array.
- resize(self, 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: int¶
number of rows.
- ncols: int¶
number of column.
- flagNullify: bool = true¶
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_: bool = true¶
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 a matrix to a 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.
Note
See load()
- 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.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
Save a matrix to a 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.
Note
See load()
- 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.
save(filename: str, A: visp._visp.core.ArrayDouble2D, binary: bool = false, header: str = ) -> bool
Save a matrix to a 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.
Note
See load()
- 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.
- static saveYAML(filename: str, A: visp._visp.core.ArrayDouble2D, header: str =) bool ¶
Save an array in a YAML-formatted file.
Here is an example of outputs.
vpArray2D<double> M(3,4); 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");
Content of matrix.yml:
example: a YAML-formatted header rows: 3 cols: 4 data: - [0, 0, 0, 0] - [0, 0, 0, 0] - [0, 0, 0, 0]
Content of matrixIndent.yml:
example: - a YAML-formatted header - with inner indentation rows: 3 cols: 4 data: - [0, 0, 0, 0] - [0, 0, 0, 0] - [0, 0, 0, 0]
Note
See loadYAML()
- 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.
- sumSquare(self) float ¶
Return the sum square of all the elements \(r_{i}\) of the rotation vector r(m).
- Returns:
The value
\[\sum{i=0}^{m} r_i^{2}\].
- t(*args, **kwargs)¶
Overloaded function.
t(self: visp._visp.core.RotationVector) -> visp._visp.core.RowVector
Return the transpose of the rotation vector.
t(self: visp._visp.core.ArrayDouble2D) -> visp._visp.core.ArrayDouble2D
Compute the transpose of the array.
- Returns:
vpArray2D<Type> C = A^T
-
__hash__ =
None
¶