Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
numeric::HomogeneousTransform< T > Class Template Reference

#include <HomogeneousTransform.hh>

Public Types

typedef T value_type
 

Public Member Functions

 HomogeneousTransform ()
 Default constructor: axis aligned with the global coordinate frame and the point located at the origin. More...
 
 HomogeneousTransform (xyzVector< T > const &p1, xyzVector< T > const &p2, xyzVector< T > const &p3)
 Construct the coordinate frame from the points defined such that. More...
 
 HomogeneousTransform (xyzVector< T > const &xaxis, xyzVector< T > const &yaxis, xyzVector< T > const &zaxis, xyzVector< T > const &point)
 Constructor from xyzVectors: trust that the axis are indeed orthoganol. More...
 
 HomogeneousTransform (xyzMatrix< T > const &axes, xyzVector< T > const &point)
 Constructor from an xyzMatrix and xyzVectors: trust that the axis are indeed orthoganol. More...
 
value_type xx () const
 
value_type xy () const
 
value_type xz () const
 
value_type yx () const
 
value_type yy () const
 
value_type yz () const
 
value_type zx () const
 
value_type zy () const
 
value_type zz () const
 
value_type px () const
 
value_type py () const
 
value_type pz () const
 
xyzVector< Txaxis () const
 
xyzVector< Tyaxis () const
 
xyzVector< Tzaxis () const
 
xyzVector< Tpoint () const
 
xyzMatrix< Trotation_matrix () const
 
void set_identity_rotation ()
 Mutators. More...
 
void set_identity_transform ()
 
void set_identity ()
 
void set_xaxis_rotation_deg (T angle)
 
void set_yaxis_rotation_deg (T angle)
 
void set_zaxis_rotation_deg (T angle)
 
void set_xaxis_rotation_rad (T angle)
 
void set_yaxis_rotation_rad (T angle)
 
void set_zaxis_rotation_rad (T angle)
 
void set_transform (xyzVector< T > const &t)
 Set this HT to describe a transformation along the three axes. This has the size effect of setting the axes to the global axes. More...
 
void set_point (xyzVector< T > const &p)
 Set the point that this HT is centered at. This leaves the axes untouched. More...
 
void walk_along_x (T delta)
 Right multiply this coordinate frame by the frame 1 0 0 delta 0 1 0 0 0 0 1 0. More...
 
void walk_along_y (T delta)
 Right multiply this coordinate frame by the frame 1 0 0 0 0 1 0 delta 0 0 1 0. More...
 
void walk_along_z (T delta)
 Right multiply this coordinate frame by the frame 1 0 0 0 0 1 0 0 0 0 1 delta. More...
 
HomogeneousTransform< Toperator* (HomogeneousTransform< T > const &rmat) const
 Multiplication. More...
 
xyzVector< Toperator* (xyzVector< T > const &vect) const
 Transform a point. The input point is a location in this coordinate frame the output point is the location in global coordinate frame. More...
 
HomogeneousTransform< Tinverse () const
 Invert this matrix. More...
 
xyzVector< Tto_local_coordinate (xyzVector< T > const &v) const
 Convert a point in the global coordinate system to a point in this coordinate frame. If this frame is F and the point is p, then this solves for x st: F x = p. Equivalent to computing (F.inverse() * p).point(). More...
 
xyzVector< Teuler_angles_rad () const
 Return the three euler angles (in radians) that describe this HomogeneousTransform as the series of a Z axis rotation by the angle phi (returned in position 1 of the output vector), followed by an X axis rotation by the angle theta (returned in position 3 of the output vector), followed by another Z axis rotation by the angle psi (returned in position 2 of the output vector). This code is a modified version of Alex Z's code from r++. More...
 
xyzVector< Teuler_angles_deg () const
 
void from_euler_angles_rad (xyzVector< T > const &euler)
 Construct the coordinate frame from three euler angles that describe the frame. Keep the point fixed. See the description for euler_angles_rad() to understand the Z-X-Z transformation convention. More...
 
void from_euler_angles_deg (xyzVector< T > const &euler)
 
T xform_magnitude (T radius_of_gyration)
 Less accurate functions. More...
 
std::ostream & show (std::ostream &stream=std::cout) const
 

Private Member Functions

bool orthonormal () const
 
bool orthoganol () const
 Are the axis orthoganol. More...
 
bool normal () const
 Are the axis of unit length? More...
 

Private Attributes

value_type xx_
 For axis Q, the R component is named qr_; e.g. The Z component of the Y axis is yz_;. More...
 
value_type yx_
 
value_type zx_
 
value_type px_
 
value_type xy_
 
value_type yy_
 
value_type zy_
 
value_type py_
 
value_type xz_
 
value_type yz_
 
value_type zz_
 
value_type pz_
 

Member Typedef Documentation

Constructor & Destructor Documentation

template<class T>
numeric::HomogeneousTransform< T >::HomogeneousTransform ( )
inline

Default constructor: axis aligned with the global coordinate frame and the point located at the origin.

template<class T>
numeric::HomogeneousTransform< T >::HomogeneousTransform ( xyzVector< T > const &  p1,
xyzVector< T > const &  p2,
xyzVector< T > const &  p3 
)
inline

Construct the coordinate frame from the points defined such that.

  1. the point is at p3,
  2. the z axis points along p2 to p3.
  3. the y axis is in the p1-p2-p3 plane
  4. the x axis is the cross product of y and z.
template<class T>
numeric::HomogeneousTransform< T >::HomogeneousTransform ( xyzVector< T > const &  xaxis,
xyzVector< T > const &  yaxis,
xyzVector< T > const &  zaxis,
xyzVector< T > const &  point 
)
inline

Constructor from xyzVectors: trust that the axis are indeed orthoganol.

template<class T>
numeric::HomogeneousTransform< T >::HomogeneousTransform ( xyzMatrix< T > const &  axes,
xyzVector< T > const &  point 
)
inline

Constructor from an xyzMatrix and xyzVectors: trust that the axis are indeed orthoganol.

Note that variable naming scheme (e.g. xy) is oposite of that in the xyzMatrix.

Member Function Documentation

template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::euler_angles_deg ( ) const
inline
template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::euler_angles_rad ( ) const
inline

Return the three euler angles (in radians) that describe this HomogeneousTransform as the series of a Z axis rotation by the angle phi (returned in position 1 of the output vector), followed by an X axis rotation by the angle theta (returned in position 3 of the output vector), followed by another Z axis rotation by the angle psi (returned in position 2 of the output vector). This code is a modified version of Alex Z's code from r++.

The range of phi is [ -pi, pi ]; The range of psi is [ -pi, pi ]; The range of theta is [ 0, pi ];

The function pretends that this HomogeneousTransform is the result of these three transformations; if it were, then the rotation matrix would be

FIGURE 1: R = [ cos(psi)cos(phi)-cos(theta)sin(phi)sin(psi) cos(psi)sin(phi)+cos(theta)cos(phi)sin(psi) sin(psi)sin(theta) -sin(psi)cos(phi)-cos(theta)sin(phi)cos(psi) -sin(psi)sin(phi)+cos(theta)cos(phi)cos(psi) cos(psi)sin(theta) sin(theta)sin(phi) -sin(theta)cos(phi) cos(theta) ]

where each axis above is represented as a ROW VECTOR (to be distinguished from the HomogeneousTransform's representation of axes as COLUMN VECTORS).

The zz_ coordinate gives away theta. Theta may be computed as acos( zz_ ), or, as Alex does it, asin( sqrt( 1 - zz^2)) Since there is redundancy in theta, this function chooses a theta with a positive sin(theta): i.e. quadrants I and II. Assuming we have a positive sin theta pushes phi and psi into conforming angles.

NOTE on theta: asin returns a value in the range [ -pi/2, pi/2 ], and we have artificially created a positive sin(theta), so we will get a asin( pos_sin_theta ), we have a value in the range [ 0, pi/2 ]. To convert this into the actual angle theta, we examine the zz sign. If zz is negative, we chose the quadrant II theta. That is, asin( pos_sin_theta) returned an angle, call it theta'. Now, if cos( theta ) is negative, then we want to choose the positive x-axis rotation that's equivalent to -theta'. To do so, we reflect q through the y axis (See figure 2 below) to get p and then measure theta as pi - theta'.

FIGURE 2:

II | I | p. | .q (cos(-theta'), std::abs(sin(theta'))) . | .

theta'( . | . ) theta' = asin( std::abs(sin(theta))

| IV | The angle between the positive x axis and p is pi - theta'.

Since zx and zy contain only phi terms and a constant sin( theta ) term, phi is given by atan2( sin_phi, cos_phi ) = atan2( c*sin_phi, c*cos_phi ) = atan2( zx, -zy ) for c positive and non-zero. If sin_theta is zero, or very close to zero, we're at gimbal lock.

Moreover, since xz and yz contain only psi terms, psi may also be deduced using atan2.

There are 2 degenerate cases (gimbal lock)

  1. theta close to 0 (North Pole singularity), or
  2. theta close to pi (South Pole singularity) For these, we take: phi=acos(xx), theta = 0 (resp. Pi/2), psi = 0

Referenced by numeric::HomogeneousTransform< double >::euler_angles_deg().

template<class T>
void numeric::HomogeneousTransform< T >::from_euler_angles_deg ( xyzVector< T > const &  euler)
inline
template<class T>
void numeric::HomogeneousTransform< T >::from_euler_angles_rad ( xyzVector< T > const &  euler)
inline

Construct the coordinate frame from three euler angles that describe the frame. Keep the point fixed. See the description for euler_angles_rad() to understand the Z-X-Z transformation convention.

Referenced by numeric::HomogeneousTransform< double >::from_euler_angles_deg().

template<class T>
HomogeneousTransform< T > numeric::HomogeneousTransform< T >::inverse ( ) const
inline

Invert this matrix.

template<class T>
bool numeric::HomogeneousTransform< T >::normal ( ) const
inlineprivate

Are the axis of unit length?

Referenced by numeric::HomogeneousTransform< double >::orthonormal().

template<class T>
HomogeneousTransform< T > numeric::HomogeneousTransform< T >::operator* ( HomogeneousTransform< T > const &  rmat) const
inline

Multiplication.

the main operation of a homogeneous transform: matrix multiplication. Note: matrix multiplication is transitive, so rotation/translation matrices may be pre-multiplied before being applied to a set of points.

template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::operator* ( xyzVector< T > const &  vect) const
inline

Transform a point. The input point is a location in this coordinate frame the output point is the location in global coordinate frame.

template<class T>
bool numeric::HomogeneousTransform< T >::orthoganol ( ) const
inlineprivate

Are the axis orthoganol.

Referenced by numeric::HomogeneousTransform< double >::orthonormal().

template<class T>
bool numeric::HomogeneousTransform< T >::orthonormal ( ) const
inlineprivate
template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::point ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::px ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::py ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::pz ( ) const
inline
template<class T>
xyzMatrix< T > numeric::HomogeneousTransform< T >::rotation_matrix ( ) const
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_identity ( )
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_identity_rotation ( )
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_identity_transform ( )
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_point ( xyzVector< T > const &  p)
inline

Set the point that this HT is centered at. This leaves the axes untouched.

template<class T>
void numeric::HomogeneousTransform< T >::set_transform ( xyzVector< T > const &  t)
inline

Set this HT to describe a transformation along the three axes. This has the size effect of setting the axes to the global axes.

template<class T>
void numeric::HomogeneousTransform< T >::set_xaxis_rotation_deg ( T  angle)
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_xaxis_rotation_rad ( T  angle)
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_yaxis_rotation_deg ( T  angle)
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_yaxis_rotation_rad ( T  angle)
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_zaxis_rotation_deg ( T  angle)
inline
template<class T>
void numeric::HomogeneousTransform< T >::set_zaxis_rotation_rad ( T  angle)
inline
template<class T>
std::ostream& numeric::HomogeneousTransform< T >::show ( std::ostream &  stream = std::cout) const
inline
template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::to_local_coordinate ( xyzVector< T > const &  v) const
inline

Convert a point in the global coordinate system to a point in this coordinate frame. If this frame is F and the point is p, then this solves for x st: F x = p. Equivalent to computing (F.inverse() * p).point().

template<class T>
void numeric::HomogeneousTransform< T >::walk_along_x ( T  delta)
inline

Right multiply this coordinate frame by the frame 1 0 0 delta 0 1 0 0 0 0 1 0.

template<class T>
void numeric::HomogeneousTransform< T >::walk_along_y ( T  delta)
inline

Right multiply this coordinate frame by the frame 1 0 0 0 0 1 0 delta 0 0 1 0.

template<class T>
void numeric::HomogeneousTransform< T >::walk_along_z ( T  delta)
inline

Right multiply this coordinate frame by the frame 1 0 0 0 0 1 0 0 0 0 1 delta.

template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::xaxis ( ) const
inline
template<class T>
T numeric::HomogeneousTransform< T >::xform_magnitude ( T  radius_of_gyration)
inline

Less accurate functions.

Used to calculate no-alignment "RMSD" of two identical poses using transforms

For this to work, the two poses must be identical, but with different orientations. Here are the steps to use this:

  1. The radius of gyration of the pose must be calculated (see core/pose/util.hh )
  2. There must be an archetype pose with its center of mass at the origin (this can be imaginary)
  3. The relative transform of each of the two poses relative to the archetype must be calculated. (i.e. What transform you would apply to the archetype to move it to where the pose is.)
  4. RMSD = ( xform1.inverse() * xform2 ).xform_magnitude( radius_of_gyration )
template<class T>
value_type numeric::HomogeneousTransform< T >::xx ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::xy ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::xz ( ) const
inline
template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::yaxis ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::yx ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::yy ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::yz ( ) const
inline
template<class T>
xyzVector< T > numeric::HomogeneousTransform< T >::zaxis ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::zx ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::zy ( ) const
inline
template<class T>
value_type numeric::HomogeneousTransform< T >::zz ( ) const
inline

Member Data Documentation

template<class T>
value_type numeric::HomogeneousTransform< T >::px_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::py_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::pz_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::xx_
private

For axis Q, the R component is named qr_; e.g. The Z component of the Y axis is yz_;.

Variables below are allocated in an intentionally visually pleasing order for a code reader, not necessarily for performance. The homogenous matrix is a 4 x 3 matrix, with a pseudo row-major ordering of data. Naming scheme: Column 1 is the x axis as a column vector Column 2 is the y axis as a column vector Column 3 is the z axis as a column vector Column 4 is the location of the point, as a column vector. Row 1 is the x coordinate of the three axes and the point Row 2 is the y coordinate of the three axes and the point Row 3 is the z coordinate of the three axes and the point Row 4 is not explicitly represented, but is always [ 0, 0, 0, 1 ]Note: This naming scheme is different from the one that Stuart uses in the xyzMatrix class.

Referenced by numeric::HomogeneousTransform< double >::euler_angles_rad(), numeric::HomogeneousTransform< double >::from_euler_angles_rad(), numeric::HomogeneousTransform< double >::HomogeneousTransform(), numeric::HomogeneousTransform< double >::inverse(), numeric::HomogeneousTransform< double >::normal(), numeric::HomogeneousTransform< double >::operator*(), numeric::HomogeneousTransform< double >::orthoganol(), numeric::HomogeneousTransform< double >::rotation_matrix(), numeric::HomogeneousTransform< double >::set_identity_rotation(), numeric::HomogeneousTransform< double >::walk_along_x(), numeric::HomogeneousTransform< double >::xaxis(), numeric::HomogeneousTransform< double >::xform_magnitude(), and numeric::HomogeneousTransform< double >::xx().

template<class T>
value_type numeric::HomogeneousTransform< T >::xy_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::xz_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::yx_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::yy_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::yz_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::zx_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::zy_
private
template<class T>
value_type numeric::HomogeneousTransform< T >::zz_
private

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