ThetaUVector

class ThetaUVector(*args, **kwargs)

Bases: RotationVector

Implementation of a rotation vector as \(\theta {\bf u}\) axis-angle minimal representation.

Class that consider the case of the \(\theta {\bf u}\) parameterization for the rotation.

The vpThetaUVector class is derived from vpRotationVector .

The \(\theta {\bf u}\) representation is one of the minimal representation of a rotation matrix, where \({\bf u} = (u_{x} \; u_{y} \; u_{z})^{\top}\) is a unit vector representing the rotation axis and \(\theta\) is the rotation angle.

From the \(\theta {\bf u}\) representation it is possible to build the rotation matrix \({\bf R}\) using the Rodrigues formula:

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

with \({\bf I}_{3}\) the identity matrix of dimension \(3\times3\) and \([{\bf u}]_{\times}\) the skew matrix:

\[\begin{split}[{\bf u}]_{\times} = \left( \begin{array}{ccc} 0 & -u_{z} & u_{y} \\u_{z} & 0 & -u_{x} \\-u_{y} & u_{x} & 0 \end{array} \right) \end{split}\]

From the implementation point of view, it is nothing more than an array of three floats with values in [rad].

You can set values [rad] accessing each element:

vpThetaUVector tu;
tu[0] = M_PI_4;
tu[1] = M_PI_2;
tu[2] = M_PI;

You can also initialize the vector using operator<<(double) :

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

tu = {M_PI_4, M_PI_2, M_PI};

To get the values [rad] use:

double tux = tu[0];
double tuy = tu[1];
double tuz = tu[2];

The code below shows first how to initialize a \(\theta {\bf u}\) vector, than how to construct a rotation matrix from a vpThetaUVector and finally how to extract the theta U angles from the build rotation matrix.

#include <iostream>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpRotationMatrix.h>
#include <visp3/core/vpThetaUVector.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpThetaUVector tu;

  // Initialise the theta U rotation vector
  tu[0] = vpMath::rad( 45.f);
  tu[1] = vpMath::rad(-30.f);
  tu[2] = vpMath::rad( 90.f);

  // Construct a rotation matrix from the theta U angles
  vpRotationMatrix R(tu);

  // Extract the theta U angles from a rotation matrix
  tu.buildFrom(R);

  // Print the extracted theta U angles. Values are the same than the
  // one used for initialization
  std::cout << tu;

  // Since the rotation vector is 3 values column vector, the
  // transpose operation produce a row vector.
  vpRowVector tu_t = tu.t();

  // Print the transpose row vector
  std::cout << tu_t << std::endl;
}

Overloaded function.

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

Default constructor that initialize all the 3 angles to zero.

  1. __init__(self: visp._visp.core.ThetaUVector, tu: visp._visp.core.ThetaUVector) -> None

Copy constructor.

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

  2. __init__(self: visp._visp.core.ThetaUVector, p: visp._visp.core.PoseVector) -> None

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

  4. __init__(self: visp._visp.core.ThetaUVector, rzyx: visp._visp.core.RzyxVector) -> None

  5. __init__(self: visp._visp.core.ThetaUVector, rzyz: visp._visp.core.RzyzVector) -> None

  6. __init__(self: visp._visp.core.ThetaUVector, rxyz: visp._visp.core.RxyzVector) -> None

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

  8. __init__(self: visp._visp.core.ThetaUVector, tu: visp._visp.core.ColVector) -> None

  9. __init__(self: visp._visp.core.ThetaUVector, tu: list[float]) -> None

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

Build a \(\theta {\bf u}\) vector from 3 angles in radians.

#include <visp3/core/vpThetaUVector.cpp>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpThetaUVector tu(0, M_PI_2, M_PI);
  std::cout << "tu: " << tu.t() << std::endl;
}

It produces the following printings:

tu: 0  1.570796327  3.141592654

Methods

__init__

Overloaded function.

buildFrom

Overloaded function.

extract

Extract the rotation angle \(\theta\) and the unit vector \(\bf u\) from the \(\theta {\bf u}\) representation.

getTheta

Get the rotation angle \(\theta\) from the \(\theta {\bf u}\) representation.

getU

Get the unit vector \(\bf u\) from the \(\theta {\bf u}\) representation.

Inherited Methods

insert

Overloaded function.

numpy

Numpy view of the underlying array data.

toStdVector

return:

The corresponding std::vector<double>.

resize

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

getRows

Return the number of rows of the 2D array.

getCols

Return the number of columns of the 2D array.

conv2

Overloaded function.

insertStatic

save

Overloaded function.

reshape

getMinValue

saveYAML

size

Return the number of elements of the 2D array.

sumSquare

Return the sum square of all the elements \(r_{i}\) of the rotation vector r(m).

getMaxValue

hadamard

t

Overloaded function.

Operators

__doc__

__init__

Overloaded function.

__module__

__mul__

Perform rotation chaining / rotation multiplication using the theta.u rotation representation.

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.PoseVector, arg0: int) -> float

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

__init__(*args, **kwargs)

Overloaded function.

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

Default constructor that initialize all the 3 angles to zero.

  1. __init__(self: visp._visp.core.ThetaUVector, tu: visp._visp.core.ThetaUVector) -> None

Copy constructor.

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

  2. __init__(self: visp._visp.core.ThetaUVector, p: visp._visp.core.PoseVector) -> None

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

  4. __init__(self: visp._visp.core.ThetaUVector, rzyx: visp._visp.core.RzyxVector) -> None

  5. __init__(self: visp._visp.core.ThetaUVector, rzyz: visp._visp.core.RzyzVector) -> None

  6. __init__(self: visp._visp.core.ThetaUVector, rxyz: visp._visp.core.RxyzVector) -> None

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

  8. __init__(self: visp._visp.core.ThetaUVector, tu: visp._visp.core.ColVector) -> None

  9. __init__(self: visp._visp.core.ThetaUVector, tu: list[float]) -> None

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

Build a \(\theta {\bf u}\) vector from 3 angles in radians.

#include <visp3/core/vpThetaUVector.cpp>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpThetaUVector tu(0, M_PI_2, M_PI);
  std::cout << "tu: " << tu.t() << std::endl;
}

It produces the following printings:

tu: 0  1.570796327  3.141592654
__mul__(self, tu_b: visp._visp.core.ThetaUVector) visp._visp.core.ThetaUVector

Perform rotation chaining / rotation multiplication using the theta.u rotation representation. See: this answer for some details about the maths.

__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.PoseVector, arg0: int, arg1: float) -> None

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

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

buildFrom(*args, **kwargs)

Overloaded function.

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

Converts an homogeneous matrix into a \(\theta {\bf u}\) vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, p: visp._visp.core.PoseVector) -> visp._visp.core.ThetaUVector

Converts a pose vector into a \(\theta {\bf u}\) vector copying the \(\theta {\bf u}\) values contained in the pose vector.

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

Converts a rotation matrix into a \(\theta {\bf u}\) vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, rzyx: visp._visp.core.RzyxVector) -> visp._visp.core.ThetaUVector

Build a \(\theta {\bf u}\) vector from an Euler z-y-x representation vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, zyz: visp._visp.core.RzyzVector) -> visp._visp.core.ThetaUVector

Build a \(\theta {\bf u}\) vector from an Euler z-y-z representation vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, xyz: visp._visp.core.RxyzVector) -> visp._visp.core.ThetaUVector

Build a \(\theta {\bf u}\) vector from an Euler x-y-z representation vector.

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

Build a \(\theta {\bf u}\) vector from a quaternion representation vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, tu: visp._visp.core.ColVector) -> visp._visp.core.ThetaUVector

Build a \(\theta {\bf u}\) vector from a 3-dim vector.

  1. buildFrom(self: visp._visp.core.ThetaUVector, tu: list[float]) -> visp._visp.core.ThetaUVector

Build a \(\theta {\bf u}\) vector from a 3-dim vectors.

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

Build a \(\theta {\bf u}\) vector from 3 angles in radian.

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

extract(self) tuple[float, visp._visp.core.ColVector]

Extract the rotation angle \(\theta\) and the unit vector \(\bf u\) from the \(\theta {\bf u}\) representation.

The following example shows how to use this function:

#include <visp3/core/vpThetaUVector.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30));

  double theta;
  vpColVector u;
  M.getRotationMatrix().getThetaUVector().extract(theta, u);
  std::cout << "theta: " << theta << std::endl;
  std::cout << "u    : " << u.t() << std::endl;
}

Note

See getTheta() , getU()

Returns:

A tuple containing:

  • theta: Rotation angle \(\theta\) in rad.

  • u: 3-dim unit vector \({\bf u} = (u_{x},u_{y},u_{z})^{\top}\) representing the rotation axis.

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

getTheta(self) float

Get the rotation angle \(\theta\) from the \(\theta {\bf u}\) representation.

The following example shows how to use this function:

#include <visp3/core/vpThetaUVector.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30));

  std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl;
  std::cout << "u    : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl;
}

Note

See getTheta() , extract()

Returns:

Rotation angle \(\theta\) in rad.

getU(self) visp._visp.core.ColVector

Get the unit vector \(\bf u\) from the \(\theta {\bf u}\) representation.

The following example shows how to use this function:

#include <visp3/core/vpThetaUVector.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), pMath::rad(30));

  std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl;
  std::cout << "u    : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl;
}

Note

See getTheta() , extract()

Returns:

3-dim unit vector \({\bf u} = (u_{x},u_{y},u_{z})^{\top}\) representing the rotation axis.

hadamard(self, m: visp._visp.core.ArrayDouble2D) visp._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._visp.core.ArrayDouble2D, B: visp._visp.core.ArrayDouble2D, C: visp._visp.core.ArrayDouble2D, r: int, c: int) None
numpy(self) numpy.ndarray[numpy.float64]

Numpy view of the underlying array data. This numpy view can be used to directly modify the array.

reshape(self, nrows: int, ncols: int) None
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.

  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.

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.

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

Return the transpose of the rotation vector.

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

toStdVector(self) list[float]
Returns:

The corresponding std::vector<double>.

__hash__ = None