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:
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 Vector4D & | get_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 Rotation3D & | operator/= (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.
| |
| 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 ¢er, 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. | |
| 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.
| base::ValueException | if the rotation is not a unit vector. |
| 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.
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.
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.
|
related |
Decompose a Rotation3D object into a rotation around an axis.
|
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
|
related |
Return a rotation that does not do anything.
|
related |
Interpolate between two rotations.
It f ==0, return b, if f==1 return a.
|
related |
Pick a rotation at random from all possible rotations.
|
related |
Pick a rotation at random near the provided one.
This method generates a rotation that is within the provided distance of center.
| [in] | center | The center of the rotational volume |
| [in] | distance | See get_distance(const Rotation3D&,const Rotation3D&) for a full definition. |
|
related |
Generate a Rotation3D object from a rotation around an axis.
| [in] | axis | the rotation axis passes through (0,0,0) |
| [in] | angle | the rotation angle in radians in the clockwise direction |
|
related |
Initialize a rotation from euler angles.
| [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 |
|
related |
Generate a Rotation3D object from a rotation matrix.
|
related |
Compute a rotatation from an unnormalized quaternion.
|
related |
Create a rotation from the first vector to the second one.