TranslationVector¶
- class TranslationVector(*args, **kwargs)¶
Bases:
ArrayDouble2D
Class that consider the case of a translation vector.
Let us denote \(^{a}{\bf t}_{b} = [t_x,t_y,t_z]^\top\) the translation from frame \(a\) to frame \(b\) . The representation of a translation is a column vector of dimension 3.
Translations along x,y,z axis are expressed in meters.
From the implementation point of view, it is nothing more than an array of three doubles with values in [meters].
You can set values [meters] accessing each element:
vpTranslationVector t; t[0] = 0; t[1] = 0.1; t[2] = 0.5;
You can also initialize the vector using operator<<(double) :
t << 0, 0.1, 05;
Or you can also initialize the vector from a list of doubles if ViSP is build with c++11 enabled:
t = {0, 0.1, 0.5};
To get the values [meters] use:
double tx = t[0]; double ty = t[1]; double tz = t[2];
The code below shows how to use a translation vector to build an homogeneous matrix.
#include <visp3/core/vpHomogeneousMatrix.h> #include <visp3/core/vpRotationMatrix.h> #include <visp3/core/vpTranslationVector.h> int main() { vpTranslationVector t; // Translation vector // Initialization of the translation vector t[0] = 0.2; // tx = 0.2 meters t[1] = -0.1; // ty = -0.1 meters t[2] = 1.0; // tz = 1 meters // Construction of a rotation matrix vpRotationMatrix R; // Set to identity by default // Construction of an homogeneous matrix vpHomogeneousMatrix M(t, R); }
Overloaded function.
__init__(self: visp._visp.core.TranslationVector) -> None
Default constructor. The translation vector is initialized to zero.
__init__(self: visp._visp.core.TranslationVector, tx: float, ty: float, tz: float) -> None
Construct a translation vector \(\bf t\) from 3 doubles.
- Parameters:
- tx
Translation respectively along x, y and z axis. Values are in meters.
- ty
Translation respectively along x, y and z axis. Values are in meters.
- tz
Translation respectively along x, y and z axis. Values are in meters.
__init__(self: visp._visp.core.TranslationVector, tv: visp._visp.core.TranslationVector) -> None
Copy constructor.
vpTranslationVector t1(1,2,3); // Create and initialize a translation vector vpTranslationVector t2(t1); // t2 is now a copy of t1
- Parameters:
- tv
Translation vector to copy.
__init__(self: visp._visp.core.TranslationVector, M: visp._visp.core.HomogeneousMatrix) -> None
Construct a translation vector \(\bf t\) from the translation contained in an homogeneous matrix.
- Parameters:
- M
Homogeneous matrix where translations are in meters.
__init__(self: visp._visp.core.TranslationVector, p: visp._visp.core.PoseVector) -> None
Construct a translation vector \(\bf t\) from the translation contained in a pose vector.
- Parameters:
- p
Pose vector where translations are in meters.
__init__(self: visp._visp.core.TranslationVector, v: visp._visp.core.ColVector) -> None
Construct a translation vector \(\bf t\) from a 3-dimension column vector.
vpColVector v(3); v[0] = 1; v[1] = 2; v[2] = 3; // Create and initialize a column vector vpTranslationVector t(v); // t contains [1, 2, 3,]
- Parameters:
- v
3-dimension column vector.
__init__(self: visp._visp.core.TranslationVector, np_array: numpy.ndarray[numpy.float64]) -> None
Construct a Translation vector by copying a 1D numpy array of size 3.
- Parameters:
- np_array
The numpy 1D array to copy.
Methods
Overloaded function.
Overloaded function.
Return the cross product of two translation vectors \(a \times b\) .
Compute and return the Frobenius norm \(||t|| = \sqrt{ \sum{t_{i}^2}}\) .
Overloaded function.
Numpy view of the underlying array data.
Overloaded function.
Initialize a translation vector from 3 doubles.
Compute the skew symmetric matrix \(M\) of the translation vector (matrice de pre-produit vectoriel), where
Overloaded function.
Return the sum square of all the elements \(t_{i}\) of the translation vector t(m).
Overloaded function.
Inherited Methods
Overloaded function.
Return the number of columns of the 2D array.
Insert array B in array A at the given position.
Overloaded function.
Return the number of rows of the 2D array.
Return the number of elements of the 2D array.
Return the array min value.
Return the array max value.
- param m:
Second matrix;
Save an array in a YAML-formatted file.
Overloaded function.
Operators
Overloaded function.
__doc__
Overloaded function.
Operator that allows to multiply each element of a translation vector by a scalar.
Overloaded function.
Operator that allows to divide each element of a translation vector by a scalar.
__module__
Overloaded function.
Operator that allows to negate a translation vector.
Operator that allows to subtract two translation vectors.
Operator that allows to divide each element of a translation vector by a scalar.
Attributes
__annotations__
- __add__(*args, **kwargs)¶
Overloaded function.
__add__(self: visp._visp.core.TranslationVector, tv: visp._visp.core.TranslationVector) -> visp._visp.core.TranslationVector
Operator that allows to add two translation vectors.
- Parameters:
- tv
Translation vector to add.
- Returns:
The sum of the current translation vector (*this) and the one to add.
vpTranslationVector t1(1,2,3); vpTranslationVector t2(4,5,6); vpTranslationVector t3; t3 = t2 + t1; // t1 and t2 leave unchanged // t3 is now equal to : 5, 7, 9
__add__(self: visp._visp.core.TranslationVector, v: visp._visp.core.ColVector) -> visp._visp.core.TranslationVector
Operator that allows to add a translation vector to a column vector.
- Parameters:
- v
3-dimension column vector to add.
- Returns:
The sum of the current translation vector (*this) and the column vector to add.
vpTranslationVector t1(1,2,3); vpColVector v(3); v[0] = 4; v[1] = 5; v[2] = 6; vpTranslationVector t2; t2 = t1 + v; // t1 and v leave unchanged // t2 is now equal to : 5, 7, 9
- __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.TranslationVector, arg0: int) -> float
__getitem__(self: visp._visp.core.TranslationVector, arg0: slice) -> numpy.ndarray[numpy.float64]
- __imul__(self, x: float) visp._visp.core.TranslationVector ¶
Operator that allows to multiply each element of a translation vector by a scalar.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.TranslationVector) -> None
Default constructor. The translation vector is initialized to zero.
__init__(self: visp._visp.core.TranslationVector, tx: float, ty: float, tz: float) -> None
Construct a translation vector \(\bf t\) from 3 doubles.
- Parameters:
- tx
Translation respectively along x, y and z axis. Values are in meters.
- ty
Translation respectively along x, y and z axis. Values are in meters.
- tz
Translation respectively along x, y and z axis. Values are in meters.
__init__(self: visp._visp.core.TranslationVector, tv: visp._visp.core.TranslationVector) -> None
Copy constructor.
vpTranslationVector t1(1,2,3); // Create and initialize a translation vector vpTranslationVector t2(t1); // t2 is now a copy of t1
- Parameters:
- tv
Translation vector to copy.
__init__(self: visp._visp.core.TranslationVector, M: visp._visp.core.HomogeneousMatrix) -> None
Construct a translation vector \(\bf t\) from the translation contained in an homogeneous matrix.
- Parameters:
- M
Homogeneous matrix where translations are in meters.
__init__(self: visp._visp.core.TranslationVector, p: visp._visp.core.PoseVector) -> None
Construct a translation vector \(\bf t\) from the translation contained in a pose vector.
- Parameters:
- p
Pose vector where translations are in meters.
__init__(self: visp._visp.core.TranslationVector, v: visp._visp.core.ColVector) -> None
Construct a translation vector \(\bf t\) from a 3-dimension column vector.
vpColVector v(3); v[0] = 1; v[1] = 2; v[2] = 3; // Create and initialize a column vector vpTranslationVector t(v); // t contains [1, 2, 3,]
- Parameters:
- v
3-dimension column vector.
__init__(self: visp._visp.core.TranslationVector, np_array: numpy.ndarray[numpy.float64]) -> None
Construct a Translation vector by copying a 1D numpy array of size 3.
- Parameters:
- np_array
The numpy 1D array to copy.
- __itruediv__(self, x: float) visp._visp.core.TranslationVector ¶
Operator that allows to divide each element of a translation vector by a scalar.
- __mul__(*args, **kwargs)¶
Overloaded function.
__mul__(self: visp._visp.core.TranslationVector, v: visp._visp.core.RowVector) -> visp._visp.core.Matrix
Multiply a 3-by-1 dimension translation vector by a 1-by-n row vector.
- Parameters:
- v
Row vector.
- Returns:
The resulting matrix that is 3-by-n dimension.
__mul__(self: visp._visp.core.TranslationVector, x: float) -> visp._visp.core.TranslationVector
Operator that allows to multiply each element of a translation vector by a scalar.
vpTranslationVector t1(1,2,3); t2 = t1 * 3; // t1 is unchanged // t2 is now equal to : [3, 6, 9]
- Parameters:
- x
The scalar.
- Returns:
The translation vector multiplied by the scalar. The current translation 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.
- __neg__(self) visp._visp.core.TranslationVector ¶
Operator that allows to negate a translation vector.
vpTranslationVector t1(1,2,3); vpTranslationVector t2; t2 = -t1; // t1 is unchanged // t2 is now equal to : [-1, -2, -3]
- Returns:
The negate translation. The current translation vector (*this) is unchanged.
- __sub__(self, tv: visp._visp.core.TranslationVector) visp._visp.core.TranslationVector ¶
Operator that allows to subtract two translation vectors.
- Parameters:
- tv: visp._visp.core.TranslationVector¶
Translation vector to subtract.
- Returns:
The subtraction of the current translation vector (*this) and the one to subtract.
vpTranslationVector t1(1,2,3); vpTranslationVector t2(4,5,6); vpTranslationVector t3; t3 = t2 - t1; // t1 and t2 leave unchanged // t3 is now equal to : 3, 3, 3
- __truediv__(self, x: float) visp._visp.core.TranslationVector ¶
Operator that allows to divide each element of a translation vector by a scalar.
vpTranslationVector t1(8,4,2); t2 = t1 / 2; // t1 is unchanged // t2 is now equal to : [4, 2, 1]
- buildFrom(*args, **kwargs)¶
Overloaded function.
buildFrom(self: visp._visp.core.TranslationVector, tx: float, ty: float, tz: float) -> visp._visp.core.TranslationVector
Build a 3 dimension translation vector \(\bf t\) from 3 doubles.
Note
See set()
- Parameters:
- tx
Translation respectively along x, y and z axis in meter.
- ty
Translation respectively along x, y and z axis in meter.
- tz
Translation respectively along x, y and z axis in meter.
- Returns:
The build translation vector.
buildFrom(self: visp._visp.core.TranslationVector, M: visp._visp.core.HomogeneousMatrix) -> visp._visp.core.TranslationVector
Build a 3 dimension translation vector \(\bf t\) from an homogeneous matrix \(\bf M\) .
- Parameters:
- M
Homogeneous matrix \(\bf M\) from which translation \(\bf t\) and \(\theta \bf u\) vectors are extracted to initialize the pose vector.
- Returns:
The build translation vector.
buildFrom(self: visp._visp.core.TranslationVector, p: visp._visp.core.PoseVector) -> visp._visp.core.TranslationVector
Build a 3 dimension translation vector \(\bf t\) from the translation contained in a pose vector.
- Parameters:
- p
Pose vector where translations are in meters.
- Returns:
The build translation vector.
buildFrom(self: visp._visp.core.TranslationVector, v: visp._visp.core.ColVector) -> visp._visp.core.TranslationVector
Build a 3 dimension translation vector \(\bf t\) from a 3-dimension column vector.
- Parameters:
- v
3-dimension column vector.
- Returns:
The build translation vector.
- 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 0x7ff6a36292a0>>
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 0x7ff6a362aec0>>
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”.
- static cross(a: visp._visp.core.TranslationVector, b: visp._visp.core.TranslationVector) visp._visp.core.TranslationVector ¶
Return the cross product of two translation vectors \(a \times b\) .
- Parameters:
- a: visp._visp.core.TranslationVector¶
Translation vectors in input.
- b: visp._visp.core.TranslationVector¶
Translation vectors in input.
- Returns:
The cross product of two translation vectors \(a \times b\) .
- frobeniusNorm(self) float ¶
Compute and return the Frobenius norm \(||t|| = \sqrt{ \sum{t_{i}^2}}\) .
- Returns:
The Frobenius norm if the vector is initialized, 0 otherwise.
- 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.
- static mean(*args, **kwargs)¶
Overloaded function.
mean(vec_M: list[visp._visp.core.HomogeneousMatrix]) -> visp._visp.core.TranslationVector
Compute the Euclidean mean of the translation vector extracted from a vector of homogeneous matrices.
Note
See vpRotationMatrix::mean()
- Parameters:
- vec_M
Set of homogeneous matrices.
- Returns:
The Euclidean mean of the translation vectors.
mean(vec_t: list[visp._visp.core.TranslationVector]) -> visp._visp.core.TranslationVector
Compute the Euclidean mean of a vector of translation vector.
Note
See vpRotationMatrix::mean()
- Parameters:
- vec_t
Set of translation vectors.
- Returns:
The Euclidean mean of the translation vectors.
- 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(*args, **kwargs)¶
Overloaded function.
resize(self: visp._visp.core.TranslationVector, nrows: int, ncols: int, flagNullify: bool = true) -> None
This function is not applicable to a translation vector that is always a 3-by-1 column vector.
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 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.
- skew(self) visp._visp.core.Matrix ¶
Compute the skew symmetric matrix \(M\) of the translation vector (matrice de pre-produit vectoriel), where
\[\begin{split}M = \left( \begin{array}{ccc} 0 & -t_z & t_y \\t_z & 0 & -t_x \\-t_y & t_x & 0 \end{array}\right) \end{split}\]and where \((t_x,t_y,t_z)\) are the coordinates of the translation vector.
- Returns:
Skew symmetric matrix \(M\) of the translation vector.
- static skewOf(*args, **kwargs)¶
Overloaded function.
skewOf(tv: visp._visp.core.TranslationVector) -> visp._visp.core.Matrix
Compute the skew symmetric matrix \(M\) of translation vector tv .
\[\begin{split}\mbox{if} \quad {\bf t} = \left( \begin{array}{c} t_x \\t_y \\t_z \end{array}\right), \quad \mbox{then} \qquad M = \left( \begin{array}{ccc} 0 & -t_z & t_y \\t_z & 0 & -t_x \\-t_y & t_x & 0 \end{array}\right) \end{split}\]- Parameters:
- tv
Translation vector in input.
- Returns:
Skew symmetric matrix \(M\) of translation vector \(t\) .
skewOf(tv: visp._visp.core.TranslationVector, M: visp._visp.core.Matrix) -> None
Compute the skew symmetric matrix \(M\) of translation vector tv .
\[\begin{split}\mbox{if} \quad {\bf t} = \left( \begin{array}{c} t_x \\t_y \\t_z \end{array}\right), \quad \mbox{then} \qquad M = \left( \begin{array}{ccc} 0 & -t_z & t_y \\t_z & 0 & -t_x \\-t_y & t_x & 0 \end{array}\right) \end{split}\]- Parameters:
- tv
Translation vector in input used to compute the skew symmetric matrix M.
- M
Skew symmetric matrix of translation vector \(t\) .
- sumSquare(self) float ¶
Return the sum square of all the elements \(t_{i}\) of the translation vector t(m).
- Returns:
The value
\[\sum{i=0}^{m} t_i^{2}\].
- t(*args, **kwargs)¶
Overloaded function.
t(self: visp._visp.core.TranslationVector) -> visp._visp.core.RowVector
Transpose the translation vector. The resulting vector becomes a row 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
¶