splines.quaternion§
Quaternions and unit-quaternion splines.
Functions
|
Iterator adapter to ensure minimal angles between quaternions. |
|
Spherical linear interpolation. |
Classes
|
Rotation spline using Barry–Goldman algorithm. |
|
Catmull–Rom-like rotation spline. |
|
Spline using De Casteljau’s algorithm with |
|
Kochanek–Bartels-like rotation spline. |
|
Piecewise Slerp. |
|
A very simple quaternion class. |
Unit quaternion. |
-
class
splines.quaternion.
Quaternion
(scalar, vector)[source]§ Bases:
object
A very simple quaternion class.
This is the base class for the more relevant
UnitQuaternion
class.-
property
scalar
§
-
property
vector
§
-
dot
(other)[source]§ Dot product of two quaternions.
This is the 4-dimensional dot product, yielding a scalar result. This operation is commutative.
Note that this is different from the quaternion multiplication (
q1 * q2
), which produces another quaternion (and is non-commutative).
-
property
norm
§
-
property
xyzw
§
-
property
wxyz
§
-
property
-
class
splines.quaternion.
UnitQuaternion
[source]§ Bases:
splines.quaternion.Quaternion
Unit quaternion.
-
classmethod
from_axis_angle
(axis, angle)[source]§ Create a unit quaternion from a rotation axis and angle.
- Parameters
axis – Three-component rotation axis. This will be normalized.
angle – Rotation angle in radians.
-
classmethod
from_unit_xyzw
(xyzw)[source]§ Create a unit quaternion from another unit quaternion.
- Parameters
xyzw – Components of a unit quaternion (scalar last). This will not be normalized, it must already have unit length.
-
inverse
()§ Multiplicative inverse.
For unit quaternions, this is the same as
conjugate()
.
-
classmethod
exp_map
(value)[source]§ Exponential map from \(R^3\) to quaternions.
This is the inverse operation to
log_map()
.- Parameters
value – Element of the tangent space at the quaternion identity.
type – 3-tuple
- Returns
Corresponding unit quaternion.
-
log_map
()[source]§ Logarithmic map from quaternions to \(R^3\).
- Returns
Corresponding vector in the tangent space at the quaternion identity.
-
property
axis
§
-
property
angle
§
-
classmethod
-
splines.quaternion.
slerp
(one, two, t)[source]§ Spherical linear interpolation.
See Spherical Linear Interpolation (Slerp).
- Parameters
one – Start quaternion.
two – End quaternion.
t – Parameter value(s) between 0 and 1.
-
splines.quaternion.
canonicalized
(quaternions)[source]§ Iterator adapter to ensure minimal angles between quaternions.
-
class
splines.quaternion.
PiecewiseSlerp
(quaternions, *, grid=None, closed=False)[source]§ Bases:
object
Piecewise Slerp.
See Piecewise Slerp.
- Parameters
quaternions – Sequence of rotations to be interpolated. The quaternions will be
canonicalized()
.grid (optional) – Sequence of parameter values. Must be strictly increasing. Must have the same length as quaternions, except when closed is
True
, where it must be one element longer. If not specified, a uniform grid is used (0, 1, 2, 3, …).closed (optional) – If
True
, the first quaternion is repeated at the end.
-
class
splines.quaternion.
DeCasteljau
(segments, grid=None)[source]§ Bases:
object
Spline using De Casteljau’s algorithm with
slerp()
.See the corresponding notebook for details.
- Parameters
segments – Sequence of segments, each one consisting of multiple control quaternions. Different segments can have different numbers of control points.
grid (optional) – Sequence of parameter values corresponding to segment boundaries. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
-
class
splines.quaternion.
KochanekBartels
(quaternions, grid=None, *, tcb=(0, 0, 0), alpha=None, endconditions='natural')[source]§ Bases:
splines.quaternion.DeCasteljau
Kochanek–Bartels-like rotation spline.
- Parameters
quaternions – Sequence of rotations to be interpolated. The quaternions will be
canonicalized()
.grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
tcb (optional) – Sequence of tension, continuity and bias triples. TCB values can only be given for the interior quaternions. If only two quaternions are given, TCB values are ignored.
alpha (optional) – TODO
endconditions (optional) –
Start/end conditions. Can be
'closed'
,'natural'
or pair of tangent vectors (a.k.a. “clamped”).TODO: clamped
If
'closed'
, the first rotation is re-used as last rotation and an additional grid time has to be specified.
-
class
splines.quaternion.
CatmullRom
(quaternions, grid=None, *, alpha=None, endconditions='natural')[source]§ Bases:
splines.quaternion.KochanekBartels
Catmull–Rom-like rotation spline.
This is just
KochanekBartels
without TCB values.