IMP logo

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.

Public Member Functions

const VectorD< 3 > get_derivative (const VectorD< 3 > &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 VectorD< 4 > get_quaternion (const VectorD< 4 > &q) const
 return the quaterion so that it can be stored
const VectorD< 4 > & get_quaternion () const
 return the quaterion so that it can be stored
VectorD< 3 > get_rotated (const VectorD< 3 > &o) const
 Rotate a vector around the origin.
double get_rotated_one_coordinate (const VectorD< 3 > &o, unsigned int coord) const
 Gets only the requested rotation coordinate of the vector.
Rotation3D operator* (const Rotation3D &q) const
 multiply two rotations
VectorD< 3 > operator* (const VectorD< 3 > &v) const
 Rotate a vector around the origin.
Rotation3D operator/ (const Rotation3D &r) const
 Compute the rotation which when composed with r gives this.
const Rotation3Doperator/= (const Rotation3D &r)
 Rotation3D (double a, double b, double c, double d)
 Create a rotation from a quaternion.
 Rotation3D ()
 Create an invalid rotation.
 Rotation3D (const VectorD< 4 > &v)
 Create a rotation from an unnormalized vector 4.

Friends

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

Related Functions

(Note that these are not member functions.)

std::pair< VectorD< 3 >, 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_random_rotation_3d (const Rotation3D &center, double distance)
 Pick a rotation at random near the provided one.
Rotation3D get_random_rotation_3d ()
 Pick a rotation at random from all possible rotations.
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_in_radians_about_axis (const VectorD< 3 > &axis, double angle)
 Generate a Rotation3D object from a rotation around an axis.
Rotation3D get_rotation_taking_first_to_second (const VectorD< 3 > &v1, const VectorD< 3 > &v2)
 Create a rotation from the first vector to the second one.
Rotation3D interpolate (const Rotation3D &a, const Rotation3D &b, double f)
 Interpolate between two rotations.
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.

Constructor & Destructor Documentation

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

Create a rotation from a quaternion.

Exceptions:
ValueException if the rotation is not a unit vector.


Member Function Documentation

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

return the quaterion so that it can be stored

This quaternion has it sign chosen so as to be interoperable with q (that is, they are in the same hemisphere). Use this when writing code to average or clustering rotations.


Friends And Related Function Documentation

std::pair< VectorD< 3 >, 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 the angle from the origin of the two quaternion vectors (with signs chosen appropriately), divided by pi/2.

Rotation3D get_identity_rotation_3d (  )  [related]

Return a rotation that does not do anything.

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] center The center of the rotational volume
[in] distance See get_distance(const Rotation3D&,const Rotation3D&) for a full definition.
Note:
The cost of this operation increases as distance goes to 0.

Rotation3D get_random_rotation_3d (  )  [related]

Pick a rotation at random from all possible rotations.

Rotation3D get_rotation_from_fixed_zxz ( double  phi,
double  theta,
double  psi 
) [related]

Initialize a rotation from euler angles.

Parameters:
[in] phi Rotation around the Z axis in radians
[in] theta Rotation around the X axis in radians
[in] psi Rotation 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_vector4d ( const VectorD< 4 > &  v  )  [related]

Compute a rotatation from an unnormalized quaternion.

Rotation3D get_rotation_in_radians_about_axis ( const VectorD< 3 > &  axis,
double  angle 
) [related]

Generate a Rotation3D object from a rotation around an axis.

Parameters:
[in] axis the rotation axis passes through (0,0,0)
[in] angle the rotation angle in radians
Note:
http://en.wikipedia.org/wiki/Rotation_matrix

www.euclideanspace.com/maths/geometry/rotations/conversions/ angleToQuaternion/index.htm

Rotation3D interpolate ( const Rotation3D a,
const Rotation3D b,
double  f 
) [related]

Interpolate between two rotations.

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


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

Generated on Mon Mar 8 23:08:47 2010 for IMP by doxygen 1.5.8