HomogeneousMatrix

class HomogeneousMatrix(*args, **kwargs)

Bases: ArrayDouble2D

Implementation of an homogeneous matrix and operations on such kind of matrices.

The class provides a data structure for the homogeneous matrices as well as a set of operations on these matrices.

The vpHomogeneousMatrix class is derived from vpArray2D<double> .

An homogeneous matrix is 4x4 matrix defines as

\[\begin{split}^a{\bf M}_b = \left(\begin{array}{cc} ^a{\bf R}_b & ^a{\bf t}_b \\{\bf 0}_{1\times 3} & 1 \end{array} \right) \end{split}\]

that defines the position of frame b in frame a

\(^a{\bf R}_b\) is a rotation matrix and \(^a{\bf t}_b\) is a translation vector.

There are different ways to initialize an homogeneous matrix. You can set each element of the matrix like:

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M;
  M[0][0] =  0; M[0][1] =  0; M[0][2] = -1; M[0][3] = 0.1;
  M[1][0] =  0; M[1][1] = -1; M[1][2] =  0; M[1][3] = 0.2;
  M[2][0] = -1; M[2][1] =  0; M[2][2] =  0; M[2][3] = 0.3;

  std::cout << "M:" << std::endl;
  for (unsigned int i = 0; i < M.getRows(); ++i) {
    for (unsigned int j = 0; j < M.getCols(); ++j) {
      std::cout << M[i][j] << " ";
    }
    std::cout << std::endl;
  }
}

It produces the following printings:

M:
0 0 -1 0.1
0 -1 0 0.2
-1 0 0 0.3
0 0 0 1

You can also use vpRotationMatrix::operator<< and vpTranslationVector::operator<< like:

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpTranslationVector t;
  vpRotationMatrix R;
  R << 0, 0, -1,
      0, -1, 0,
      -1, 0, 0;
  t << 0.1, 0.2, 0.3;
  vpHomogeneousMatrix M(t, R);
  std::cout << "M:\n" << M << std::endl;
}

If ViSP is build with c++11 enabled, you can do the same using:

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  {
    vpHomogeneousMatrix M( vpTranslationVector(0.1, 0.2, 0.3), vpRotationMatrix( {0, 0, -1, 0, -1, 0, -1, 0, 0} ) );
    std::cout << "M:\n" << M << std::endl;
  }
  {
    vpHomogeneousMatrix M { 0,  0, -1, 0.1,
                            0, -1,  0, 0.2,
                          -1,  0,  0, 0.3 };
    std::cout << "M:\n" << M << std::endl;
  }
}

JSON serialization

Since ViSP 3.6.0, if ViSP is build with soft_tool_json 3rd-party we introduce JSON serialization capabilities for vpHomogeneousMatrix . The following sample code shows how to save a homogeneous matrix in a file named homo-mat.json and reload the values from this JSON file.

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
#if defined(VISP_HAVE_NLOHMANN_JSON)
  std::string filename = "homo-mat.json";
  {
    vpHomogeneousMatrix M(vpTranslationVector(0.1, 0.2, 0.3), vpRotationMatrix({ 0, 0, -1, 0, -1, 0, -1, 0, 0 }));
    std::ofstream file(filename);
    const nlohmann::json j = M;
    file << j;
    file.close();
  }
  {
    std::ifstream file(filename);
    const nlohmann::json j = nlohmann::json::parse(file);
    vpHomogeneousMatrix M;
    M = j;
    file.close();
    std::cout << "Read homogeneous matrix from " << filename << ":\n" << M << std::endl;
  }
#endif
}

If you build and execute the sample code, it will produce the following output:

Read homogeneous matrix from homo-mat.json:
0  0  -1  0.1
0  -1  0  0.2
-1  0  0  0.3
0  0  0  1

The content of the homo-mat.json file is the following:

$ cat homo-mat.json
{"cols":4,"data":[0.0,0.0,-1.0,0.1,0.0,-1.0,0.0,0.2,-1.0,0.0,0.0,0.3,0.0,0.0,0.0,1.0],"rows":4,"type":"vpHomogeneousMatrix"}

Overloaded function.

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

Default constructor that initialize an homogeneous matrix as identity.

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

Copy constructor that initialize an homogeneous matrix from another homogeneous matrix.

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

Construct an homogeneous matrix from a translation vector and a rotation matrix.

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

Construct an homogeneous matrix from a translation vector and \(\theta {\bf u}\) rotation vector.

  1. __init__(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector, q: visp._visp.core.QuaternionVector) -> None

Construct an homogeneous matrix from a translation vector and quaternion rotation vector.

  1. __init__(self: visp._visp.core.HomogeneousMatrix, p: visp._visp.core.PoseVector) -> None

  2. __init__(self: visp._visp.core.HomogeneousMatrix, v: list[float]) -> None

  3. __init__(self: visp._visp.core.HomogeneousMatrix, v: list[float]) -> None

  4. __init__(self: visp._visp.core.HomogeneousMatrix, tx: float, ty: float, tz: float, tux: float, tuy: float, tuz: float) -> None

Construct an homogeneous matrix from a translation vector \({\bf t}=(t_x, t_y, t_z)^T\) and a \(\theta {\bf u}=(\theta u_x, \theta u_y, \theta u_z)^T\) rotation vector.

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

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

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

Parameters:
np_array

The numpy 1D array to copy.

Methods

__init__

Overloaded function.

buildFrom

Overloaded function.

compute3d3dTransformation

param p:

First point cloud.

convert

Converts an homogeneous matrix to a vector of 12 doubles.

extract

Overloaded function.

eye

Set transformation to identity.

getCol

The following example shows how to use this function:

getRotationMatrix

Return the rotation matrix from the homogeneous transformation matrix.

getThetaUVector

Return the \(\theta {\bf u}\) vector that corresponds to the rotation part of the homogeneous transformation.

getTranslationVector

Return the translation vector from the homogeneous transformation matrix.

insert

Overloaded function.

inverse

Overloaded function.

isAnHomogeneousMatrix

Test if the 3x3 rotational part of the homogeneous matrix is a valid rotation matrix and the last row is equal to [0, 0, 0, 1].

isValid

return:

true when no NaN found, false otherwise.

load

Overloaded function.

mean

Compute the Euclidean mean of the homogeneous matrices.

numpy

Numpy view of the underlying array data.

orthogonalizeRotation

Perform orthogonalization of the rotation part of the homogeneous transformation.

print

Print the matrix as a pose vector \(({\bf t}^T \theta {\bf u}^T)\) .

resize

Overloaded function.

save

Overloaded function.

Inherited Methods

insertStatic

getRows

Return the number of rows of the 2D array.

t

conv2

Overloaded function.

getMaxValue

saveYAML

getCols

Return the number of columns of the 2D array.

size

Return the number of elements of the 2D array.

getMinValue

hadamard

view

Overloaded function.

reshape

Operators

__doc__

__getitem__

Overloaded function.

__imul__

Operator that allow to multiply an homogeneous matrix by an other one.

__init__

Overloaded function.

__module__

__mul__

Overloaded function.

Attributes

__annotations__

__hash__

jsonTypeName

__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.HomogeneousMatrix, arg0: tuple[int, int]) -> float

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

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

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

__imul__(self, M: visp._visp.core.HomogeneousMatrix) visp._visp.core.HomogeneousMatrix

Operator that allow to multiply an homogeneous matrix by an other one.

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M1, M2;
  // Initialize M1 and M2...

  // Compute M1 = M1 * M2
  M1 *= M2;
}
__init__(*args, **kwargs)

Overloaded function.

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

Default constructor that initialize an homogeneous matrix as identity.

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

Copy constructor that initialize an homogeneous matrix from another homogeneous matrix.

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

Construct an homogeneous matrix from a translation vector and a rotation matrix.

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

Construct an homogeneous matrix from a translation vector and \(\theta {\bf u}\) rotation vector.

  1. __init__(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector, q: visp._visp.core.QuaternionVector) -> None

Construct an homogeneous matrix from a translation vector and quaternion rotation vector.

  1. __init__(self: visp._visp.core.HomogeneousMatrix, p: visp._visp.core.PoseVector) -> None

  2. __init__(self: visp._visp.core.HomogeneousMatrix, v: list[float]) -> None

  3. __init__(self: visp._visp.core.HomogeneousMatrix, v: list[float]) -> None

  4. __init__(self: visp._visp.core.HomogeneousMatrix, tx: float, ty: float, tz: float, tux: float, tuy: float, tuz: float) -> None

Construct an homogeneous matrix from a translation vector \({\bf t}=(t_x, t_y, t_z)^T\) and a \(\theta {\bf u}=(\theta u_x, \theta u_y, \theta u_z)^T\) rotation vector.

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

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

Construct a homogeneous matrix by copying a 2D numpy array. This numpy array should be of dimensions \(4 \times 4\) and be a valid homogeneous matrix. If it is not a homogeneous 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.HomogeneousMatrix, M: visp._visp.core.HomogeneousMatrix) -> visp._visp.core.HomogeneousMatrix

Operator that allow to multiply an homogeneous matrix by an other one.

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix aMb, bMc;
  // Initialize aMb and bMc...

  // Compute aMc * bMc
  vpHomogeneousMatrix aMc = aMb * bMc;
}
  1. __mul__(self: visp._visp.core.HomogeneousMatrix, v: visp._visp.core.ColVector) -> visp._visp.core.ColVector

Operator that allow to multiply an homogeneous matrix by a 4-dimension column vector.

  1. __mul__(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector) -> visp._visp.core.TranslationVector

Since a translation vector could be seen as the origin point of a frame, this function computes the new coordinates of a translation vector after applying an homogeneous transformation.

Parameters:
t

Translation vector seen as the 3D coordinates of a point.

Returns:

A translation vector that contains the new 3D coordinates after applying the homogeneous transformation.

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

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

The following snippet shows how to use this method:

vpHomogeneousMatrix c1_M_c2;
vpRotationMatrix c2_R_c3;
vpHomogeneousMatrix c1_M_c3 = c1_M_c2 * c2_R_c3;
Parameters:
R

Rotation matrix.

Returns:

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

  1. __mul__(self: visp._visp.core.HomogeneousMatrix, bP: visp._visp.core.Point) -> visp._visp.core.Point

From the coordinates of the point in camera frame b and the transformation between camera frame a and camera frame b computes the coordinates of the point in camera frame a.

Parameters:
bP

3D coordinates of the point in camera frame bP.

Returns:

A point with 3D coordinates in the camera frame a. The coordinates in the world or object frame are set to the same coordinates than the one in the camera frame.

__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.HomogeneousMatrix, t: visp._visp.core.TranslationVector, R: visp._visp.core.RotationMatrix) -> visp._visp.core.HomogeneousMatrix

Build an homogeneous matrix from a translation vector and a rotation matrix.

  1. buildFrom(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector, tu: visp._visp.core.ThetaUVector) -> visp._visp.core.HomogeneousMatrix

Build an homogeneous matrix from a translation vector and a \(\theta {\bf u}\) rotation vector.

  1. buildFrom(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector, q: visp._visp.core.QuaternionVector) -> visp._visp.core.HomogeneousMatrix

Build an homogeneous matrix from a translation vector and a quaternion rotation vector.

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

Build an homogeneous matrix from a pose vector.

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

Build an homogeneous matrix from a vector of float.The following example shows how to use this function:

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  std::vector<float> v(12, 0);
  v[1]  = -1.; // ry=-90
  v[4]  =  1.; // rx=90
  v[10] = -1.; // rz=-90
  v[3]  = 0.3; // tx
  v[7]  = 0.4; // ty
  v[11] = 0.5; // tz

  std::cout << "v: ";
  for(unsigned int i=0; i<v.size(); ++i)
    std::cout << v[i] << " ";
  std::cout << std::endl;

  vpHomogeneousMatrix M;
  M.buildFrom(v);
  std::cout << "M:\n" << M << std::endl;
}

It produces the following printings:

v: 0 -1 0 0.3 1 0 0 0.4 0 0 -1 0.5
M:
0  -1  0  0.3000000119
1  0  0  0.400000006
0  0  -1  0.5
0  0  0  1
Parameters:
v

Vector of 12 or 16 values corresponding to the values of the homogeneous matrix.

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

Build an homogeneous matrix from a vector of double.The following example shows how to use this function:

#include <visp3/core/vpHomogeneousMatrix.h>

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  std::vector<double> v(12, 0);
  v[1]  = -1.; // ry=-90
  v[4]  =  1.; // rx=90
  v[10] = -1.; // rz=-90
  v[3]  = 0.3; // tx
  v[7]  = 0.4; // ty
  v[11] = 0.5; // tz

  std::cout << "v: ";
  for(unsigned int i=0; i<v.size(); ++i)
    std::cout << v[i] << " ";
  std::cout << std::endl;

  vpHomogeneousMatrix M;
  M.buildFrom(v);
  std::cout << "M:\n" << M << std::endl;
}

It produces the following printings:

v: 0 -1 0 0.3 1 0 0 0.4 0 0 -1 0.5
M:
0  -1  0  0.3
1  0  0  0.4
0  0  -1  0.5
0  0  0  1
Parameters:
v

Vector of 12 or 16 values corresponding to the values of the homogeneous matrix.

  1. buildFrom(self: visp._visp.core.HomogeneousMatrix, tx: float, ty: float, tz: float, tux: float, tuy: float, tuz: float) -> visp._visp.core.HomogeneousMatrix

Build an homogeneous matrix from a translation vector \({\bf t}=(t_x, t_y, t_z)^T\) and a \(\theta {\bf u}=(\theta u_x, \theta u_y, \theta u_z)^T\) rotation vector.

static compute3d3dTransformation(p: list[visp._visp.core.Point], q: list[visp._visp.core.Point]) visp._visp.core.HomogeneousMatrix
Parameters:
p: list[visp._visp.core.Point]

First point cloud.

q: list[visp._visp.core.Point]

Second point cloud.

Returns:

The homogeneous transformation \({^p}{\bf M}_q\) .

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

convert(self) list[float]

Converts an homogeneous matrix to a vector of 12 doubles.

Returns:

A tuple containing:

  • M: Converted matrix.

extract(*args, **kwargs)

Overloaded function.

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

Extract the rotational matrix from the homogeneous matrix.

Parameters:
R

rotational component as a rotation matrix.

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

Extract the rotation as a \(\theta \bf u\) vector.

  1. extract(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector) -> None

Extract the translation vector from the homogeneous matrix.

  1. extract(self: visp._visp.core.HomogeneousMatrix, q: visp._visp.core.QuaternionVector) -> None

Extract the rotation as a quaternion.

eye(self) None

Set transformation to identity.

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

The following example shows how to use this function:

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

#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif

int main()
{
  vpHomogeneousMatrix M;

  vpColVector t = M.getCol(3);
  std::cout << "Last column: \n" << t << std::endl;
}

It produces the following output:

Last column:
0
0
1
0
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
getRotationMatrix(self) visp._visp.core.RotationMatrix

Return the rotation matrix from the homogeneous transformation matrix.

getRows(self) int

Return the number of rows of the 2D array.

Note

See getCols() , size()

getThetaUVector(self) visp._visp.core.ThetaUVector

Return the \(\theta {\bf u}\) vector that corresponds to the rotation part of the homogeneous transformation.

getTranslationVector(self) visp._visp.core.TranslationVector

Return the translation vector from the homogeneous transformation matrix.

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

Overloaded function.

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

Insert the rotational component of the homogeneous matrix.

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

Insert the rotational component of the homogeneous matrix from a \(theta {\bf u}\) rotation vector.

  1. insert(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.TranslationVector) -> None

Insert the translational component in a homogeneous matrix.

  1. insert(self: visp._visp.core.HomogeneousMatrix, t: visp._visp.core.QuaternionVector) -> None

Insert the rotational component of the homogeneous matrix from a quaternion rotation vector.

  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
inverse(*args, **kwargs)

Overloaded function.

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

Invert the homogeneous matrix

Returns:

\(\left[\begin{array}{cc} {\bf R} & {\bf t} \\{\bf 0}_{1\times 3} & 1 \end{array} \right]^{-1} = \left[\begin{array}{cc} {\bf R}^T & -{\bf R}^T {\bf t} \\{\bf 0}_{1\times 3} & 1 \end{array} \right]\)

  1. inverse(self: visp._visp.core.HomogeneousMatrix, Mi: visp._visp.core.HomogeneousMatrix) -> None

Invert the homogeneous matrix.

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

Test if the 3x3 rotational part of the homogeneous matrix is a valid rotation matrix and the last row is equal to [0, 0, 0, 1].

Returns:

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

isValid(self) bool
Returns:

true when no NaN found, false otherwise.

load(*args, **kwargs)

Overloaded function.

  1. load(self: visp._visp.core.HomogeneousMatrix, f: std::basic_ifstream<char, std::char_traits<char> >) -> None

Read an homogeneous matrix from an input file stream. The homogeneous matrix is considered as a 4 by 4 matrix.

The code below shows how to get an homogeneous matrix from a file.

vpHomogeneousMatrix M;

std::ifstream f("homogeneous.dat");
M.load(f);

Note

See load(const std::string &) , save(std::ifstream &)

Parameters:
f

Input file stream.

  1. load(self: visp._visp.core.HomogeneousMatrix, filename: str) -> None

Read an homogeneous matrix from an input file. The homogeneous matrix is considered as a 4 by 4 matrix.

The code below shows how to get an homogeneous matrix from a file.

vpHomogeneousMatrix M;

M.load("homogeneous.dat");

Note

See load(std::ifstream &) , save(const std::string &)

Parameters:
filename

Input file name.

static mean(vec_M: list[visp._visp.core.HomogeneousMatrix]) visp._visp.core.HomogeneousMatrix

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

Note

See vpTranslationVector::mean() , vpRotationMatrix::mean()

Parameters:
vec_M: list[visp._visp.core.HomogeneousMatrix]

Set of homogeneous matrices.

Returns:

The Euclidean mean of the homogeneous 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.

orthogonalizeRotation(self) None

Perform orthogonalization of the rotation part of the homogeneous transformation.

print(self) None

Print the matrix as a pose vector \(({\bf t}^T \theta {\bf u}^T)\) .

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

Overloaded function.

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

This function is not applicable to an homogeneous matrix that is always a 4-by-4 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.

save(*args, **kwargs)

Overloaded function.

  1. save(self: visp._visp.core.HomogeneousMatrix, f: std::basic_ofstream<char, std::char_traits<char> >) -> None

Save an homogeneous matrix in an output file stream.

The code below shows how to save an homogeneous matrix in a file.

// Construct an homogeneous matrix
vpTranslationVector t(1,2,3);
vpRxyzVector r(M_PI, 0, -M_PI/4.);
vpRotationMatrix R(r);
vpHomogeneousMatrix M(t, R);

// Save the content of the matrix in "homogeneous.dat"
std::ofstream f("homogeneous.dat");
M.save(f);

The content of “homogeneous.dat” is the following:

\* 0.7071067812  0.7071067812  0  1
\* 0.7071067812  -0.7071067812  -1.224646799e-16  2
\* -8.659560562e-17  8.659560562e-17  -1  3
\* 0  0  0  1
\*

Note

See save(const std::string &), load(std::ifstream &)

Parameters:
f

Output file stream. The homogeneous matrix is saved as a 4 by 4 matrix.

  1. save(self: visp._visp.core.HomogeneousMatrix, filename: str) -> None

Save an homogeneous matrix in a file.

The code below shows how to save an homogeneous matrix in a file.

// Construct an homogeneous matrix
vpTranslationVector t(1,2,3);
vpRxyzVector r(M_PI, 0, -M_PI/4.);
vpRotationMatrix R(r);
vpHomogeneousMatrix M(t, R);

// Save the content of the matrix in "homogeneous.dat"
M.save("homogeneous.dat");

The content of “homogeneous.dat” is the following:

\* 0.7071067812  0.7071067812  0  1
\* 0.7071067812  -0.7071067812  -1.224646799e-16  2
\* -8.659560562e-17  8.659560562e-17  -1  3
\* 0  0  0  1
\*

Note

See save(std::ofstream &), load(const std::string &)

Parameters:
filename

Output file name. The homogeneous matrix is saved as a 4 by 4 matrix.

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