IMP logo
Public Member Functions | Friends | Related Functions
IMP::algebra::Rotation3D Class Reference

Detailed Description

3D rotation class.

Rotations are currently represented using quaternions and a cached copy of the rotation matrix. The quaternion allows for fast and stable composition and the cached rotation matrix means that rotations are performed quickly. See http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation for a comparison of different implementations of rotations.

Currently the rotation can be initialized from either:

Note:
This class is a geometric primitive. Also, this class is not not initialized by its default constructor.

List of all members.

Public Member Functions

 Rotation3D (const VectorD< 4 > &v)
 Create a rotation from an unnormalized vector 4.
 Rotation3D ()
 Create an invalid rotation.
 Rotation3D (double a, double b, double c, double d)
 Create a rotation from a quaternion.
const Vector3D get_derivative (const Vector3D &o, unsigned int i) const
 Return the derivative of the position x with respect to internal variable i.
Rotation3D get_inverse () const
 Return the rotation which undoes this rotation.
const Vector4Dget_quaternion () const
 return the quaterion so that it can be stored
Vector3D get_rotated (const Vector3D &o) const
 Rotate a vector around the origin.
double get_rotated_one_coordinate (const Vector3D &o, unsigned int coord) const
 Gets only the requested rotation coordinate of the vector.
Vector3D get_rotation_matrix_row (int i) const
Vector3D operator* (const Vector3D &v) const
 Rotate a vector around the origin.
Rotation3D operator* (const Rotation3D &q) const
 multiply two rotations
Rotation3D operator/ (const Rotation3D &r) const
 Compute the rotation which when composed with r gives this.
const Rotation3Doperator/= (const Rotation3D &r)
void show (std::ostream &out=std::cout) const

Euler Angles

There are many conventions for how to define Euler angles, based on choices of which of the x,y,z axis to use in what order and whether the rotation axis is in the body frame (and hence affected by previous rotations) or in in a fixed frame. See http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles for a general description.

  • All Euler angles are specified in radians.
  • The names are all rotation_from_{fixed/body}_abc() where abc is the ordering of x,y,z.
Rotation3D get_rotation_from_fixed_zxz (double phi, double theta, double psi)
 Initialize a rotation from euler angles.

Friends

Rotation3D compose (const Rotation3D &a, const Rotation3D &b)

Related Functions

(Note that these are not member functions.)

Rotation3D compose (const Rotation3D &a, const Rotation3D &b)
std::pair< Vector3D, double > get_axis_and_angle (const Rotation3D &rot)
 Decompose a Rotation3D object into a rotation around an axis.
double get_distance (const Rotation3D &r0, const Rotation3D &r1)
 Return a distance between the two rotations.
Rotation3D get_identity_rotation_3d ()
 Return a rotation that does not do anything.
Rotation3D get_interpolated (const Rotation3D &a, const Rotation3D &b, double f)
 Interpolate between two rotations.
Rotation3D get_random_rotation_3d ()
 Pick a rotation at random from all possible rotations.
Rotation3D get_random_rotation_3d (const Rotation3D &center, double distance)
 Pick a rotation at random near the provided one.
Rotation3D get_rotation_about_axis (const Vector3D &axis, double angle)
 Generate a Rotation3D object from a rotation around an axis.
Rotation3D get_rotation_from_matrix (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 Generate a Rotation3D object from a rotation matrix.
Rotation3D get_rotation_from_vector4d (const VectorD< 4 > &v)
 Compute a rotatation from an unnormalized quaternion.
Rotation3D get_rotation_taking_first_to_second (const Vector3D &v1, const Vector3D &v2)
 Create a rotation from the first vector to the second one.

Constructor & Destructor Documentation

IMP::algebra::Rotation3D::Rotation3D ( const VectorD< 4 > &  v)

Create a rotation from an unnormalized vector 4.

IMP::algebra::Rotation3D::Rotation3D ( )

Create an invalid rotation.

IMP::algebra::Rotation3D::Rotation3D ( double  a,
double  b,
double  c,
double  d 
)

Create a rotation from a quaternion.

Exceptions:
base::ValueExceptionif the rotation is not a unit vector.

Member Function Documentation

const Vector3D IMP::algebra::Rotation3D::get_derivative ( const Vector3D o,
unsigned int  i 
) const

Return the derivative of the position x with respect to internal variable i.

Rotation3D IMP::algebra::Rotation3D::get_inverse ( ) const

Return the rotation which undoes this rotation.

const Vector4D& IMP::algebra::Rotation3D::get_quaternion ( ) const

return the quaterion so that it can be stored

Note that there is no guarantee on which of the two equivalent quaternions is returned.

Vector3D IMP::algebra::Rotation3D::get_rotated ( const Vector3D o) const

Rotate a vector around the origin.

double IMP::algebra::Rotation3D::get_rotated_one_coordinate ( const Vector3D o,
unsigned int  coord 
) const

Gets only the requested rotation coordinate of the vector.

Vector3D IMP::algebra::Rotation3D::operator* ( const Vector3D v) const

Rotate a vector around the origin.

Rotation3D IMP::algebra::Rotation3D::operator* ( const Rotation3D q) const

multiply two rotations

Rotation3D IMP::algebra::Rotation3D::operator/ ( const Rotation3D r) const

Compute the rotation which when composed with r gives this.


Friends And Related Function Documentation

std::pair< Vector3D, double > get_axis_and_angle ( const Rotation3D rot)
related

Decompose a Rotation3D object into a rotation around an axis.

Note:
http://en.wikipedia.org/wiki/Rotation_matrix
www.euclideanspace.com/maths/geometry/rotations/conversions/ angleToQuaternion/index.htm
double get_distance ( const Rotation3D r0,
const Rotation3D r1 
)
related

Return a distance between the two rotations.

The distance runs between 0 and 1. More precisely, the distance returned is distance between the two quaternion vectors properly normalized, divided by sqrt(2).

A vector with distance d from the unit vector represents a rotation of

$ \theta= \cos^{-1}\left(1-\sqrt{2}d\right)$

Rotation3D get_identity_rotation_3d ( )
related

Return a rotation that does not do anything.

Rotation3D get_interpolated ( const Rotation3D a,
const Rotation3D b,
double  f 
)
related

Interpolate between two rotations.

It f ==0, return b, if f==1 return a.

Rotation3D get_random_rotation_3d ( )
related

Pick a rotation at random from all possible rotations.

Rotation3D get_random_rotation_3d ( const Rotation3D center,
double  distance 
)
related

Pick a rotation at random near the provided one.

This method generates a rotation that is within the provided distance of center.

Parameters:
[in]centerThe center of the rotational volume
[in]distanceSee get_distance(const Rotation3D&,const Rotation3D&) for a full definition.
Note:
The cost of this operation increases as distance goes to 0.
Rotation3D get_rotation_about_axis ( const Vector3D axis,
double  angle 
)
related

Generate a Rotation3D object from a rotation around an axis.

Parameters:
[in]axisthe rotation axis passes through (0,0,0)
[in]anglethe rotation angle in radians in the clockwise direction
Note:
http://en.wikipedia.org/wiki/Rotation_matrix
www.euclideanspace.com/maths/geometry/rotations/conversions/ angleToQuaternion/index.htm
Rotation3D get_rotation_from_fixed_zxz ( double  phi,
double  theta,
double  psi 
)
related

Initialize a rotation from euler angles.

Parameters:
[in]phiRotation around the Z axis in radians
[in]thetaRotation around the X axis in radians
[in]psiRotation around the Z axis in radians
Note:
The first rotation is by an angle phi about the z-axis. The second rotation is by an angle theta in [0,pi] about the former x-axis , and the third rotation is by an angle psi about the former z-axis.
Rotation3D get_rotation_from_matrix ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12,
double  m20,
double  m21,
double  m22 
)
related

Generate a Rotation3D object from a rotation matrix.

Rotation3D get_rotation_from_vector4d ( const VectorD< 4 > &  v)
related

Compute a rotatation from an unnormalized quaternion.

Rotation3D get_rotation_taking_first_to_second ( const Vector3D v1,
const Vector3D v2 
)
related

Create a rotation from the first vector to the second one.


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

Generated on Tue May 22 2012 23:33:25 for IMP by doxygen 1.8.1