OpenCV  4.1.0
Open Source Computer Vision
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>

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 Mat4 &affine)
 Augmented affine matrix.
 
 Affine3 (const Mat3 &R, const Vec3 &t=Vec3::all(0))
 
 Affine3 (const Vec3 &rvec, const Vec3 &t=Vec3::all(0))
 
 Affine3 (const Mat &data, const Vec3 &t=Vec3::all(0))
 
 Affine3 (const float_type *vals)
 From 16-element array.
 
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
 
void linear (const Mat3 &L)
 
Mat3 linear () const
 
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;
 
void rotation (const Mat3 &R)
 
void rotation (const Vec3 &rvec)
 
void rotation (const Mat &data)
 
Mat3 rotation () const
 
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
 
void translation (const Vec3 &t)
 
Vec3 translation () const
 

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

cv::Vec3f r, t;
cv::Affine3f T(r, t);

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

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

cv::Affine3f T, T_inv;
T_inv = T.inv();

Member Typedef Documentation

template<typename T>
typedef T cv::Affine3< T >::float_type
template<typename T>
typedef Matx<float_type, 3, 3> cv::Affine3< T >::Mat3
template<typename T>
typedef Matx<float_type, 4, 4> cv::Affine3< T >::Mat4
template<typename T>
typedef Vec<float_type, 3> cv::Affine3< T >::Vec3

Constructor & Destructor Documentation

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

Default constructor. It represents a 4x4 identity matrix.

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

Augmented affine matrix.

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.
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.
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.
template<typename T>
cv::Affine3< T >::Affine3 ( const float_type vals)
explicit

From 16-element array.

Member Function Documentation

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

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

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

Create an 4x4 identity transform.

template<typename T>
Affine3 cv::Affine3< T >::inv ( int  method = cv::DECOMP_SVD) const
Returns
the inverse of the current matrix.
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.
template<typename T>
Mat3 cv::Affine3< T >::linear ( ) const
Returns
the upper left 3x3 part
template<typename T>
template<typename Y >
cv::Affine3< T >::operator Affine3< Y > ( ) const
template<typename T>
Affine3 cv::Affine3< T >::rotate ( const Mat3 R) const

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

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

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

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.
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).
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.
template<typename T>
Mat3 cv::Affine3< T >::rotation ( ) const
Returns
the upper left 3x3 part
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).
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

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.
template<typename T>
Vec3 cv::Affine3< T >::translation ( ) const
Returns
the upper right 3x1 part

Member Data Documentation

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

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