IMP  2.0.0
The Integrative Modeling Platform
IMP::algebra::Rotation3D Class Reference

3D rotation class. More...

#include <IMP/algebra/Rotation3D.h>

+ Inheritance diagram for IMP::algebra::Rotation3D:

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. More...
 
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 quaternion so that it can be stored. More...
 
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
 

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. More...
 
double get_distance (const Rotation3D &r0, const Rotation3D &r1)
 Return a distance between the two rotations. More...
 
Rotation3D get_identity_rotation_3d ()
 Return a rotation that does not do anything. More...
 
Rotation3D get_interpolated (const Rotation3D &a, const Rotation3D &b, double f)
 Interpolate between two rotations. More...
 
Rotation3D get_random_rotation_3d ()
 Pick a rotation at random from all possible rotations. More...
 
Rotation3D get_random_rotation_3d (const Rotation3D &center, double distance)
 Pick a rotation at random near the provided one. More...
 
Rotation3D get_rotation_about_axis (const Vector3D &axis, double angle)
 Generate a Rotation3D object from a rotation around an axis. More...
 
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. More...
 
Rotation3D get_rotation_taking_first_to_second (const Vector3D &v1, const Vector3D &v2)
 Create a rotation from the first vector to the second one.
 

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. More...
 

Detailed Description

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:

  • XYZ Euler angles
  • Rotation Matrix
  • Quaternion
  • angle/axis representation
Note
This class is a geometric primitive. Also, this class is not not initialized by its default constructor.

Definition at line 46 of file Rotation3D.h.

Constructor & Destructor Documentation

IMP::algebra::Rotation3D::Rotation3D ( double  a,
double  b,
double  c,
double  d 
)
Exceptions
base::ValueExceptionif the rotation is not a unit vector.

Definition at line 87 of file Rotation3D.h.

Member Function Documentation

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

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

Definition at line 191 of file Rotation3D.h.

Friends And Related Function Documentation

std::pair< Vector3D, double > get_axis_and_angle ( const Rotation3D rot)
related
Note
http://en.wikipedia.org/wiki/Rotation_matrix
www.euclideanspace.com/maths/geometry/rotations/conversions/ angleToQuaternion/index.htm
Returns
axis direction and rotation about the axis in Radians
double get_distance ( const Rotation3D r0,
const Rotation3D r1 
)
related

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

Definition at line 241 of file Rotation3D.h.

Rotation3D get_identity_rotation_3d ( )
related

Definition at line 225 of file Rotation3D.h.

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

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

Definition at line 509 of file Rotation3D.h.

Rotation3D get_random_rotation_3d ( )
related
Rotation3D get_random_rotation_3d ( const Rotation3D center,
double  distance 
)
related

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
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
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_vector4d ( const VectorD< 4 > &  v)
related

Definition at line 326 of file Rotation3D.h.


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