IMP Reference Guide
2.11.1
The Integrative Modeling Platform
|
3D rotation class. More...
#include <IMP/algebra/Rotation3D.h>
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:
See geometric primitives for more information.
Definition at line 46 of file Rotation3D.h.
Public Member Functions | |
Rotation3D (const Rotation3D &rot) | |
Rotation3D copy constructor. More... | |
Rotation3D (const VectorD< 4 > &v, bool assume_normalized=false) | |
Rotation3D () | |
Create an invalid rotation. More... | |
Rotation3D (double a, double b, double c, double d) | |
Create a rotation from a quaternion. More... | |
Vector3D | get_derivative (const Vector3D &v, unsigned int i, bool projected=true) const |
Return the derivative of rotated vector wrt the ith quaternion element. More... | |
Eigen::MatrixXd | get_gradient (const Eigen::Vector3d &v, bool projected=true) const |
Return the gradient of rotated vector wrt the quaternion. More... | |
Rotation3D | get_inverse () const |
Return the rotation which undoes this rotation. More... | |
bool | get_is_valid () const |
const Vector4D & | get_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. More... | |
double | get_rotated_one_coordinate (const Vector3D &o, unsigned int coord) const |
Get only the requested rotation coordinate of the vector. More... | |
Vector3D | get_rotation_matrix_row (int i) const |
Vector3D | operator* (const Vector3D &v) const |
Rotate a vector around the origin. More... | |
Rotation3D | operator* (const Rotation3D &q) const |
Multiply two rotations. More... | |
Rotation3D | operator/ (const Rotation3D &r) const |
Compute the rotation which when composed with r gives this. More... | |
const Rotation3D & | operator/= (const Rotation3D &r) |
Rotation3D & | operator= (const Rotation3D &rot) |
void | show (std::ostream &out=std::cout) const |
Friends | |
Rotation3D | compose (const Rotation3D &a, const Rotation3D &b) |
IMP::algebra::Rotation3D::Rotation3D | ( | const Rotation3D & | rot | ) |
Rotation3D copy constructor.
Definition at line 86 of file Rotation3D.h.
|
explicit |
Create a rotation from a vector of 4 quaternion coefficients.
Definition at line 99 of file Rotation3D.h.
IMP::algebra::Rotation3D::Rotation3D | ( | ) |
Create an invalid rotation.
Definition at line 105 of file Rotation3D.h.
IMP::algebra::Rotation3D::Rotation3D | ( | double | a, |
double | b, | ||
double | c, | ||
double | d | ||
) |
Create a rotation from a quaternion.
ValueException | if the rotation is not a unit vector. |
Definition at line 109 of file Rotation3D.h.
Vector3D IMP::algebra::Rotation3D::get_derivative | ( | const Vector3D & | v, |
unsigned int | i, | ||
bool | projected = true |
||
) | const |
Return the derivative of rotated vector wrt the ith quaternion element.
Given the rotation \(x = R(q) v\), where \(v\) is a vector, \(q=(q_0,q_1,q_2,q_3)\) is the quaternion of the rotation with elements \(q_i\), and \(R(q)\) is the corresponding rotation matrix, the function returns the derivative \(\frac{d x}{d q_i}\).
This function just returns a single column from get_gradient(), so it is more efficient to call that function if all columns are needed.
[in] | v | vector to be rotated by rotation \(R(q)\) |
[in] | projected | project derivative onto tangent space to \(q\). Equivalent to differentiating wrt \(\frac{q_i}{\|q\|}\) instead of \(q_i\). |
Eigen::MatrixXd IMP::algebra::Rotation3D::get_gradient | ( | const Eigen::Vector3d & | v, |
bool | projected = true |
||
) | const |
Return the gradient of rotated vector wrt the quaternion.
Given the rotation \(x = R(q) v\), where \(v\) is a vector, \(q\) is the quaternion of the rotation, and \(R(q)\) is the corresponding rotation matrix, the function returns the 3x4 matrix \(M = \nabla_q x\) with elements \(M_{ij}=\frac{d x_i}{d q_j}\).
[in] | v | vector to be rotated by rotation \(R(q)\) |
[in] | projected | project gradient onto tangent space to \(q\). Equivalent to differentiating wrt \(\frac{q_i}{\|q\|}\) instead of \(q_i\). |
Rotation3D IMP::algebra::Rotation3D::get_inverse | ( | ) | const |
Return the rotation which undoes this rotation.
Definition at line 196 of file Rotation3D.h.
bool IMP::algebra::Rotation3D::get_is_valid | ( | ) | const |
Return true is the rotation is valid, false if invalid or not initialized (e.g., only initialized by the empty constructor)
Definition at line 267 of file Rotation3D.h.
const Vector4D& IMP::algebra::Rotation3D::get_quaternion | ( | ) | const |
Return the quaternion so that it can be stored.
Note that there is no guarantee on which of the two equivalent quaternions is returned.
Definition at line 207 of file Rotation3D.h.
Rotate a vector around the origin.
Definition at line 173 of file Rotation3D.h.
double IMP::algebra::Rotation3D::get_rotated_one_coordinate | ( | const Vector3D & | o, |
unsigned int | coord | ||
) | const |
Get only the requested rotation coordinate of the vector.
Definition at line 179 of file Rotation3D.h.
Rotate a vector around the origin.
Definition at line 186 of file Rotation3D.h.
Rotation3D IMP::algebra::Rotation3D::operator* | ( | const Rotation3D & | q | ) | const |
Multiply two rotations.
Definition at line 214 of file Rotation3D.h.
Rotation3D IMP::algebra::Rotation3D::operator/ | ( | const Rotation3D & | r | ) | const |
Compute the rotation which when composed with r gives this.
Definition at line 221 of file Rotation3D.h.
|
friend |
Definition at line 448 of file Rotation3D.h.