Regina 7.4 Calculation Engine
|
Represents a rotation about the origin in real three-dimensional space. More...
#include <maths/3d.h>
Public Member Functions | |
Rotation3D ()=default | |
Creates the identity rotation. | |
constexpr | Rotation3D (const Rotation3D &)=default |
Creates a new copy of the given rotation. | |
constexpr | Rotation3D (Real a, Real b, Real c, Real d) |
Creates a new rotation from the given quaternion coordinates. | |
Rotation3D & | operator= (const Rotation3D &)=default |
Sets this to be a copy of the given rotation. | |
constexpr Real | operator[] (int index) const |
Returns the given quaternion coordinate for this rotation. | |
constexpr bool | operator== (const Rotation3D &other) const |
Determines if this and the given rotation have the same quaternion coordinates. | |
void | normalise () |
Rescales all four quaternion coordinates by the same positive constant so that the quaternion coordinates become normalised. | |
constexpr Rotation3D | operator* (const Rotation3D &rhs) const |
Returns the composition of this and the given rotation. | |
Rotation3D & | operator*= (const Rotation3D &rhs) |
Composes this with the given rotation, which is to be applied first. | |
constexpr Vector3D< Real > | operator* (const Vector3D< Real > &vector) const |
Returns the image of the given vector under this rotation. | |
constexpr Rotation3D | inverse () const |
Returns the inverse to this rotation. | |
constexpr Matrix3D< Real > | matrix () const |
Returns the 3-dimensional transformation matrix for this rotation. | |
Represents a rotation about the origin in real three-dimensional space.
Regina stores a rotation using a quaternion, which consists of four real numbers. We refer to these four numbers as the quaternion coordinates.
Specifically, suppose we rotate by an angle of θ around the axis pointing from the origin to the unit vector (x,y,z)
, and this rotation follows a right-hand rule (the thumb of the right hand points from the origin out towards (x,y,z)
, and the fingers follow the direction of the rotation). Then the four real numbers that make up the quaternion are (cos θ/2, x sin θ/2, y sin θ/2, z sin θ/2)
.
Some notes about the uniqueness of quaternions:
(1,0,0,0)
).Regarding normalisation:
(x,y,z)
is a unit vector in 3-D.(λa, λb, λc, λd)
to represent the same rotation as (a,b,c,d)
for any positive λ (and, if we ignore the direction of rotation and just consider its endpoint, then for any negative λ also).See Regina's notes on 3-D geometry for important information, including the inexact floating-point nature of the Vector3D class, and the right-handedness of Regina's coordinate system.
These objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.
double
.Real | the floating-point type to use for all storage and computation. |
|
default |
Creates the identity rotation.
This is the operation that does not rotate at all.
|
constexprdefault |
Creates a new copy of the given rotation.
|
inlineconstexpr |
Creates a new rotation from the given quaternion coordinates.
As described in the class notes, these coordinates do not need to be normalised.
a | the first quaternion coordinate; that is, the coordinate corresponding to cos θ/2 from the discussion in the class notes. |
b | the second quaternion coordinate; that is, the coordinate corresponding to x sin θ/2 from the discussion in the class notes. |
c | the third quaternion coordinate; that is, the coordinate corresponding to y sin θ/2 from the discussion in the class notes. |
d | the fourth quaternion coordinate; that is, the coordinate corresponding to z sin θ/2 from the discussion in the class notes. |
|
inlineconstexpr |
Returns the inverse to this rotation.
This rotates around the same axis by negative the original angle.
This function does not require the quaternion coordinates to be normalised. If this rotation has its coordinates scaled by λ, then the resulting rotation will have its coordinates scaled by λ also.
|
inlineconstexpr |
Returns the 3-dimensional transformation matrix for this rotation.
The result will be a 3-by-3 matrix M
, which can be used to rotate column vectors by matrix multiplication. Specifically, this rotation transforms the column vector v
into the vector M * v
.
This function does not require the quaternion coordinates to be normalised. The result will be the same as though normalise() had been called beforehand.
|
inline |
Rescales all four quaternion coordinates by the same positive constant so that the quaternion coordinates become normalised.
Specifically, after this operation:
(a,b,c,d)
will satisfy a^2 + b^2 + c^2 + d^2 = 1
.
|
inlineconstexpr |
Returns the composition of this and the given rotation.
Composition of 3-D rotations is not commutative. Here we follow the same convention as used elsewhere in Regina (e.g., by Regina's permutation classes): the product q * r
indicates that we should apply rotation r
first, followed by rotation q
. This is also consistent with the matrix() function, which produces matrices that act on column vectors (matrix * vector
), and which therefore compose using the same convention.
This function does not require the quaternion coordinates of either this or rhs to be normalised. If the two rotations have coordinates scaled by λ and μ respectively, then the resulting composition will have its coordinates scaled by λμ.
rhs | the rotation to apply before this. |
|
inlineconstexpr |
Returns the image of the given vector under this rotation.
vector | the 3-D vector to rotate. |
|
inline |
Composes this with the given rotation, which is to be applied first.
This rotation will be changed directly.
Composition of 3-D rotations is not commutative. Here we follow the same convention as used elsewhere in Regina (e.g., by Regina's permutation classes): writing q *= r
indicates that we should apply rotation r
first, followed by rotation q
, and then change q
to store the resulting composition. This is also consistent with the matrix() function, which produces matrices that act on column vectors (matrix * vector
), and which therefore compose using the same convention.
This function does not require the quaternion coordinates of either this or rhs to be normalised. If the two original rotations have coordinates scaled by λ and μ respectively, then the resulting composition will have its coordinates scaled by λμ.
rhs | the rotation to apply before this. |
|
default |
Sets this to be a copy of the given rotation.
|
inlineconstexpr |
Determines if this and the given rotation have the same quaternion coordinates.
other | the rotation to compare with this. |
true
if and only if the two rotations have the same quaternion coordinates.
|
inlineconstexpr |
Returns the given quaternion coordinate for this rotation.
index | indicates which coordinate to return; this must be between 0 and 3 inclusive. |