[−][src]Module ultraviolet::rotor
A rotor can be thought of in multiple ways, the first of which
is that a rotor is the result of the 'geometric product' of two vectors,
denoted for two vectors u
and v
as simply uv
. This operation is
defined as
uv = u · v + u ∧ v
As can be seen, this operation results in the addition of two different types of values: first, the dot product will result in a scalar, and second, the exterior (wedge) product will result in a bivector. The addition of these two different types is not defined, but can be understood in a similar way as complex numbers, i.e. as a 'bundle' of two different kinds of values.
The reason we call this type of value a 'rotor' is that if you both left- and
right-multiply (using the geometric product) a rotor with a vector, you will
rotate the sandwiched vector. For example, if you start with two vectors,
a
and b
, and create a rotor ab
from them, then rotate a vector u
with this
rotor by doing ba u ab
, you will end up rotating the vector u
by in the plane
that corresponds to a ∧ b
(i.e. the plane which is parallel with both vectors), by
twice the angle between a
and b
, in the opposite direction of the one that would
bring a
towards b
within that plane.
In ultraviolet
, the Mul
trait is implemented for Rotors such that doing
rotor * vec
will rotate the Vector vec
by the Rotor rotor
.
To compose rotations, simply left-multiply the rotor by another one in the same way that matrix composition works. For example,
rotor_ab = rotor_b * rotor_a
Will result in the composition of rotor_b
and rotor_a
such that rotor_ab
encodes
a rotation as though rotor_a
was applied and then rotor_b
was applied.
Note that composition of rotors is more efficient
than composition of matrices, however, the operation of rotating a vector by a rotor, i.e. the
rotor * vec
product, is more expensive to
compute than the matrix * vec
product. So, rotors are excellent for building and interpolating
rotations, but it may be preferrable to convert them into matrices before applying them to
vectors/points, if the same rotation will be applied to many vectors.
Structs
Rotor2 | A Rotor in 2d space. |
Rotor3 | A Rotor in 3d space. |
WRotor2 | A Rotor in 2d space. |
WRotor3 | A Rotor in 3d space. |