OpenCV  4.9.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cv::Affine3< T > Class Template Reference

Affine transform. More...

#include <opencv2/core/affine.hpp>

Inheritance diagram for cv::Affine3< T >:
Collaboration diagram for cv::Affine3< T >:

Public Types

typedef T float_type
 
typedef Matx< float_type, 3, 3 > Mat3
 
typedef Matx< float_type, 4, 4 > Mat4
 
typedef Vec< float_type, 3 > Vec3
 

Public Member Functions

 Affine3 ()
 Default constructor. It represents a 4x4 identity matrix.
 
 Affine3 (const float_type *vals)
 From 16-element array.
 
 Affine3 (const Mat &data, const Vec3 &t=Vec3::all(0))
 
 Affine3 (const Mat3 &R, const Vec3 &t=Vec3::all(0))
 
 Affine3 (const Mat4 &affine)
 Augmented affine matrix.
 
 Affine3 (const Vec3 &rvec, const Vec3 &t=Vec3::all(0))
 
template<typename Y >
Affine3< Y > cast () const
 
Affine3 concatenate (const Affine3 &affine) const
 a.concatenate(affine) is equivalent to affine * a;
 
Affine3 inv (int method=cv::DECOMP_SVD) const
 
Mat3 linear () const
 
void linear (const Mat3 &L)
 
template<typename Y >
 operator Affine3< Y > () const
 
Affine3 rotate (const Mat3 &R) const
 a.rotate(R) is equivalent to Affine(R, 0) * a;
 
Affine3 rotate (const Vec3 &rvec) const
 a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;
 
Mat3 rotation () const
 
void rotation (const Mat &data)
 
void rotation (const Mat3 &R)
 
void rotation (const Vec3 &rvec)
 
Vec3 rvec () const
 
Affine3 translate (const Vec3 &t) const
 a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
 
Vec3 translation () const
 
void translation (const Vec3 &t)
 

Static Public Member Functions

static Affine3 Identity ()
 Create an 4x4 identity transform.
 

Public Attributes

Mat4 matrix
 

Detailed Description

template<typename T>
class cv::Affine3< T >

Affine transform.

It represents a 4x4 homogeneous transformation matrix \(T\)

\[T = \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \]

where \(R\) is a 3x3 rotation matrix and \(t\) is a 3x1 translation vector.

You can specify \(R\) either by a 3x3 rotation matrix or by a 3x1 rotation vector, which is converted to a 3x3 rotation matrix by the Rodrigues formula.

To construct a matrix \(T\) representing first rotation around the axis \(r\) with rotation angle \(|r|\) in radian (right hand rule) and then translation by the vector \(t\), you can use

If you already have the rotation matrix \(R\), then you can use

To extract the rotation matrix \(R\) from \(T\), use

cv::Matx33f R = T.rotation();

To extract the translation vector \(t\) from \(T\), use

cv::Vec3f t = T.translation();

To extract the rotation vector \(r\) from \(T\), use

cv::Vec3f r = T.rvec();

Note that since the mapping from rotation vectors to rotation matrices is many to one. The returned rotation vector is not necessarily the one you used before to set the matrix.

If you have two transformations \(T = T_1 * T_2\), use

cv::Affine3f T, T1, T2;
T = T2.concatenate(T1);
Affine3 concatenate(const Affine3 &affine) const
a.concatenate(affine) is equivalent to affine * a;

To get the inverse transform of \(T\), use

cv::Affine3f T, T_inv;
T_inv = T.inv();
Affine3 inv(int method=cv::DECOMP_SVD) const

Member Typedef Documentation

◆ float_type

template<typename T >
typedef T cv::Affine3< T >::float_type

◆ Mat3

template<typename T >
typedef Matx<float_type, 3, 3> cv::Affine3< T >::Mat3

◆ Mat4

template<typename T >
typedef Matx<float_type, 4, 4> cv::Affine3< T >::Mat4

◆ Vec3

template<typename T >
typedef Vec<float_type, 3> cv::Affine3< T >::Vec3

Constructor & Destructor Documentation

◆ Affine3() [1/6]

template<typename T >
cv::Affine3< T >::Affine3 ( )

Default constructor. It represents a 4x4 identity matrix.

◆ Affine3() [2/6]

template<typename T >
cv::Affine3< T >::Affine3 ( const Mat4 affine)

Augmented affine matrix.

◆ Affine3() [3/6]

template<typename T >
cv::Affine3< T >::Affine3 ( const Mat3 R,
const Vec3 t = Vec3::all(0) 
)

The resulting 4x4 matrix is

\[ \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \]

Parameters
R3x3 rotation matrix.
t3x1 translation vector.

◆ Affine3() [4/6]

template<typename T >
cv::Affine3< T >::Affine3 ( const Vec3 rvec,
const Vec3 t = Vec3::all(0) 
)

Rodrigues vector.

The last row of the current matrix is set to [0,0,0,1].

Parameters
rvec3x1 rotation vector. Its direction indicates the rotation axis and its length indicates the rotation angle in radian (using right hand rule).
t3x1 translation vector.

◆ Affine3() [5/6]

template<typename T >
cv::Affine3< T >::Affine3 ( const Mat data,
const Vec3 t = Vec3::all(0) 
)
explicit

Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix.

The last row of the current matrix is set to [0,0,0,1] when data is not 4x4.

Parameters
data1-channel matrix. when it is 4x4, it is copied to the current matrix and t is not used. When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used. When it is 3x3, it is copied to the upper left 3x3 part of the current matrix. When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used to compute a 3x3 rotation matrix.
t3x1 translation vector. It is used only when data is neither 4x4 nor 3x4.

◆ Affine3() [6/6]

template<typename T >
cv::Affine3< T >::Affine3 ( const float_type vals)
explicit

From 16-element array.

Member Function Documentation

◆ cast()

template<typename T >
template<typename Y >
Affine3< Y > cv::Affine3< T >::cast ( ) const

◆ concatenate()

template<typename T >
Affine3 cv::Affine3< T >::concatenate ( const Affine3< T > &  affine) const

a.concatenate(affine) is equivalent to affine * a;

◆ Identity()

template<typename T >
static Affine3 cv::Affine3< T >::Identity ( )
static

Create an 4x4 identity transform.

◆ inv()

template<typename T >
Affine3 cv::Affine3< T >::inv ( int  method = cv::DECOMP_SVD) const
Returns
the inverse of the current matrix.

◆ linear() [1/2]

template<typename T >
Mat3 cv::Affine3< T >::linear ( ) const
Returns
the upper left 3x3 part

◆ linear() [2/2]

template<typename T >
void cv::Affine3< T >::linear ( const Mat3 L)

Copy the 3x3 matrix L to the upper left part of the current matrix

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters
L3x3 matrix.

◆ operator Affine3< Y >()

template<typename T >
template<typename Y >
cv::Affine3< T >::operator Affine3< Y > ( ) const

◆ rotate() [1/2]

template<typename T >
Affine3 cv::Affine3< T >::rotate ( const Mat3 R) const

a.rotate(R) is equivalent to Affine(R, 0) * a;

◆ rotate() [2/2]

template<typename T >
Affine3 cv::Affine3< T >::rotate ( const Vec3 rvec) const

a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;

◆ rotation() [1/4]

template<typename T >
Mat3 cv::Affine3< T >::rotation ( ) const
Returns
the upper left 3x3 part

◆ rotation() [2/4]

template<typename T >
void cv::Affine3< T >::rotation ( const Mat data)

Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix.

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters
data1-channel matrix. When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix. When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix.

◆ rotation() [3/4]

template<typename T >
void cv::Affine3< T >::rotation ( const Mat3 R)

Rotation matrix.

Copy the rotation matrix to the upper left 3x3 part of the current matrix. The remaining elements of the current matrix are not changed.

Parameters
R3x3 rotation matrix.

◆ rotation() [4/4]

template<typename T >
void cv::Affine3< T >::rotation ( const Vec3 rvec)

Rodrigues vector.

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters
rvec3x1 rotation vector. The direction indicates the rotation axis and its length indicates the rotation angle in radian (using the right thumb convention).

◆ rvec()

template<typename T >
Vec3 cv::Affine3< T >::rvec ( ) const

Rodrigues vector.

Returns
a vector representing the upper left 3x3 rotation matrix of the current matrix.
Warning
Since the mapping between rotation vectors and rotation matrices is many to one, this function returns only one rotation vector that represents the current rotation matrix, which is not necessarily the same one set by rotation(const Vec3& rvec).

◆ translate()

template<typename T >
Affine3 cv::Affine3< T >::translate ( const Vec3 t) const

a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix

◆ translation() [1/2]

template<typename T >
Vec3 cv::Affine3< T >::translation ( ) const
Returns
the upper right 3x1 part

◆ translation() [2/2]

template<typename T >
void cv::Affine3< T >::translation ( const Vec3 t)

Copy t to the first three elements of the last column of the current matrix

It sets the upper right 3x1 part of the matrix. The remaining part is unaffected.

Parameters
t3x1 translation vector.

Member Data Documentation

◆ matrix

template<typename T >
Mat4 cv::Affine3< T >::matrix

The documentation for this class was generated from the following file: