ASF

Quaternions Are the Rotors of Space

July 11, 2026|
A
A

Introduction

On the sixteenth of October 1843, walking with his wife along the Royal Canal in Dublin, William Rowan Hamilton stopped at Broom Bridge and cut a formula into the stone with a knife. He had spent the better part of fifteen years trying to multiply triples of numbers the way the complex numbers multiply pairs, and failing, because there is no way to do it. What he carved was the escape: four numbers in place of three, with three square roots of minus one that refuse to commute,

The carving has worn away and a plaque now marks the spot, but the algebra it names, the quaternions , outlived every argument about it. For half a century quaternions were the language in which British physics was written, Maxwell's equations among it; then Gibbs and Heaviside split Hamilton's product into the separate dot and cross products of vector analysis, and the quaternion was left for dead. It returned in the late twentieth century through computer graphics and spacecraft attitude control, where it is now the standard way to store and compose a rotation, and where it is taught as a bag of rules that work for reasons the student is asked to take on faith: multiply like [eq:hamilton], sandwich a vector between and its conjugate, remember the mysterious half-angle, remember that and are the same rotation, and do not ask why.

This article answers the why. The answer is short. Hamilton's quaternions are the even subalgebra of the geometric algebra of space, the algebra built once and in full in the companion piece, Classical Mechanics from Zero in Two Languages. The three imaginaries are the three basis bivectors of that algebra, the oriented planes of space; a unit quaternion is a rotor, the object that turns a vector by the two-sided sandwich; quaternion conjugation is the rotor reverse; the unit-norm condition is the rotor normalisation . Once the identification is made every quaternion mystery is a fact already proved about rotors. The half-angle is the fingerprint of two reflections. The double cover is the statement that a rotor and its negative sandwich a vector identically. The freedom from gimbal lock is the smoothness of a single group element in place of three stacked angles. Hamilton had found the rotors of space thirty-five years before Clifford wrote down the algebra that contains them, and he found them without the vectors. So they arrived wrapped in a mystery that took a century and a half to unwrap.

The plan runs in five parts. Part I rebuilds Hamilton's quaternions on their own nineteenth-century terms: the failed triples, the leap to four, the conjugate and the norm, and the rotation formula of Hamilton and Cayley. Part II reinterprets them. It exhibits the even subalgebra , matches its multiplication table to [eq:hamilton] term by term, and proves the isomorphism . Part III settles the half-angle, the two-to-one cover, the axis and the storage conventions. Part IV treats interpolation between rotations and the recovery of a quaternion from a rotation matrix. Part V is the code: native rotation expressions in a data engine, whose behaviour the mathematics determines.

The reader needs the parts of the companion article that build and its rotors. The geometric product, the bivector, the pseudoscalar and the sandwich are used as established and cross-referenced where they enter. No prior acquaintance with quaternions is presumed. We begin where Hamilton began, with the wish to multiply in three dimensions and the discovery that one cannot.


Part I

1. Hamilton's algebra on its own terms

1.1. Triples without a product

The complex numbers do two jobs at once. As an algebra they are pairs with a multiplication, and as geometry they are the plane, in which multiplication by a unit complex number is rotation by . Hamilton wanted the same coincidence one dimension up: a multiplication on triples , understood as points of space, that would compose rotations the way the complex numbers compose rotations of the plane. He required the multiplication to distribute over addition, to respect lengths in the sense that the modulus of a product is the product of the moduli, and to admit division with an inverse for every non-zero triple.

The modulus requirement is what fails. Writing a triple as with , the product of two such objects throws up a term in , and there is no consistent value for it. Setting or breaks the modulus law; setting and computing the modulus of a product leaves a residue that has nowhere to go inside the triples. The modern statement of the impasse is a pair of theorems. By Hurwitz the only real normed division algebras, those with a multiplicative modulus, are the reals, the complexes, the quaternions and the octonions. By Bott, Milnor and Kervaire every finite-dimensional real division algebra has dimension one, two, four or eight. Three is absent from both lists. A division algebra on triples does not exist, and Hamilton spent years discovering by hand what the theorem states in one line.

The leap on Broom Bridge was to stop insisting on three. If the stray product has nowhere to go among the triples, give it somewhere to go: a fourth basis element , defined as that product, . The number system becomes four-dimensional, a real part and three imaginary parts, and the modulus law is recovered. Giving up commutativity came first and cost him little. His letter to John Graves of 17 October 1843 records that he was "tempted for a moment to fancy that ij = 0", found this "odd and uncomfortable", and took instead what "seemed to me less harsh, namely that ji = −ij" (Wilkins edition).

1.2. Multiplication and its consequences

Definition (Quaternion algebra).

A quaternion is a real linear combination

of a scalar part and a vector part . The set of all quaternions is written . Addition is componentwise, and multiplication is the bilinear extension of Hamilton's relations

from which the products of distinct units follow,

The relations of [eq:cyclic] are read out of [eq:hamilton-2] with no further input. Multiplying on the right by and using gives ; multiplying on the left by gives ; and the third follows by the same move. Each unit is the product of the other two in cyclic order and minus that product in anticyclic order, the pattern that the cross product would later inherit and that Part II will trace to its source. The three imaginaries anticommute in pairs and each squares to . No two of them behave like the single commuting of the complex numbers.

A general product multiplies out. Writing a quaternion as a scalar-and-vector pair with read as an ordinary triple, the product of and collects into

where and are the dot and cross products of the vector parts. This single line is where Gibbs and Heaviside found their vector analysis: the scalar part of [eq:hamilton-product] gives the negative dot product, the vector part gives the cross product, and by keeping the two pieces apart they dispensed with the quaternion and kept its debris. That the one quaternion product already contains both the dot and the cross product is the first sign that it is more primitive than either. Part II makes this exact by identifying [eq:hamilton-product] with the geometric product restricted to the even grades.

1.3. Norm and inverse

The complex conjugate negates the imaginary part; the quaternion conjugate does the same to all three.

Definition (Conjugate and norm).

The conjugate of is

and the norm is the non-negative real number with

A quaternion is a unit quaternion when .

That is real and equal to the sum of squares is a direct computation from [eq:hamilton-product]: the vector part of is , and the scalar part is . The conjugate reverses the order of a product, , exactly as the transpose reverses a product of matrices, and from this the norm is multiplicative,

Multiplicativity is the length-respecting property Hamilton demanded. In coordinates the multiplicativity of [eq:norm-mult] is Euler's four-square identity: a product of two sums of four squares is again a sum of four squares.

Every non-zero quaternion has an inverse, and [eq:norm-def] hands it over: since ,

and for a unit quaternion this is . So the unit quaternions are closed under multiplication and inverse: they form a group that we shall shortly recognise. Because is the equation of the unit sphere in four dimensions, the unit quaternions are that sphere, with quaternion multiplication as a group law on it. Only the spheres of dimension zero, one and three admit a continuous group structure: the unit reals, the unit complexes and the unit quaternions. The coincidence is the same one that makes the division-algebra list stop where it does.

1.4. Rotation and an unexplained half-angle

Hamilton and Cayley found how a unit quaternion turns a vector. Identify the triple with the pure quaternion , the one with zero scalar part. The vector of space keeps the bold of the companion article throughout; the pure quaternion is set in plain since it is an element of , where no grade-one vector lives. Section 3.1 shows the two to be distinct objects joined by a duality. Then for a unit quaternion the map

sends pure quaternions to pure quaternions, preserves their norm, and is a rotation of the vector . Writing the unit quaternion in the form

the rotation of [eq:quat-sandwich] is the rotation through angle about the axis . The formula is exact and every graphics engine and attitude filter computes it. It has two features that are unexplained on the quaternion's own terms.

The first is the half-angle. To rotate by the quaternion is built from , and the angle is split once more by the two-sided sandwich, on the left and on the right. The halves recombine to the whole. The algebra of [eq:hamilton-2] does not say why the rotation is assembled from two half-turns. The second is the sign. Replacing by in [eq:quat-sandwich] leaves the map unchanged since the two sign flips cancel. So the quaternion for a rotation is determined only up to sign: the axis-angle form [eq:quat-axis-angle] at and at gives the two opposite quaternions for the one rotation. A rotation by a full turn returns every vector to where it started, yet it sends to . Both features are used and are opaque from inside . Part III reads them off the geometry once the quaternion is placed where it belongs.

1.5. Matrix form of the algebra

The classical presentation closes with a matrix realisation, the form in which quaternions most often meet a linear-algebra course. Sending

with the ordinary complex unit, reproduces [eq:hamilton-2] under matrix multiplication, and identifies the unit quaternions with the group of unimodular unitary complex matrices. The three imaginaries of [eq:pauli] are the Pauli matrices multiplied by . Physicists know as a two-to-one cover of the rotation group. There is also a purely real face that sends each quaternion to a real matrix acting on by left multiplication. These faithful pictures confirm that the algebra is consistent and hand it to whatever tool multiplies matrices. They do not say what the imaginaries are. Part II does: an oriented plane of ordinary space, an element of the geometry that the matrices only encode.


Part II

2. Even subalgebra and identification

2.1. Even part of the algebra of space

The companion article builds the geometric algebra of three-dimensional space and lists its eight-dimensional basis by grade: one scalar, three vectors, three bivectors and one pseudoscalar,

in the cyclic bivector labelling with . The grades split the algebra into even and odd. The even subalgebra is the span of the elements of even grade, the scalar and the three bivectors,

and it is a subalgebra because the geometric product of two even-grade elements is again even: grade adds modulo two under the product, and even plus even is even. The subalgebra is four-dimensional over the reals. We now compute its multiplication table and compare it with Hamilton's.

Two facts from the companion article do the work. First, each basis bivector squares to ,

because, for instance, using the anticommutation and the contraction . Second, the product of two distinct basis bivectors is the third, with a sign fixed by the cyclic order. Computing one,

where the middle contracts. The other two follow by cycling the indices: and .

2.2. Hamilton's imaginaries are the basis bivectors

Equations [eq:bivector-square] and [eq:bivector-product] are Hamilton's relations wearing a minus sign. The sign is absorbed by identifying each imaginary with the negative of a basis bivector.

Proposition (Quaternions as the even subalgebra of space).

The real-linear map fixing the scalar and sending

is an isomorphism of real associative algebras. Under it the quaternion conjugate [eq:conj-def] is the reverse of the companion article, and the quaternion norm [eq:norm-def] is .

The map is a linear bijection between four-dimensional spaces by construction, and to be an algebra isomorphism it need only preserve the defining products. Take : it is by [eq:bivector-square], matching , and the same for and . Take the product :

using [eq:bivector-product] at the middle step and at the last. So , and cycling the indices gives and . The remaining relation is the triple product, and it follows at once: . Every relation of [eq:hamilton-2] is reproduced, so is an isomorphism.

The claim about conjugation is read off the grades. A quaternion maps to

a scalar plus a bivector. The reverse of the companion article reverses the order of the vector factors in every blade. It leaves the scalar untouched and flips the sign of every bivector. Hence . Reversion is conjugation. Then

so the rotor normalisation is exactly the unit-quaternion condition.

2.3. Consequences of the identification

Three things that were opaque in Part I are now transparent.

The non-commutativity of the imaginaries is the non-commutativity of oriented planes under the geometric product. Two distinct bivectors share a line and differ in a second direction. Swapping their order reflects that second direction and so changes a sign. Nothing remains to explain beyond the anticommutation of orthogonal vectors, which the companion article traces to the contraction axiom. Hamilton's choice of as the less harsh option was a discovery that planes do not commute.

The appearance of both the dot and the cross product in the single quaternion product [eq:hamilton-product] is the appearance of both grades in the single geometric product. When the companion article multiplies two vectors it gets a scalar plus a bivector, the inner and the outer part together; the even subalgebra inherits the same two-part output. The pure quaternions are bivectors and multiply to a scalar plus a bivector whose pieces are, up to the duality of the next paragraph, the dot and the cross of the corresponding vectors. Gibbs and Heaviside cut a bivector-valued product into a scalar and a normal vector and called the two halves separate; the quaternion had them joined because its imaginaries were planes all along.

The pure quaternion is a bivector, not a vector. Hamilton's identification of the triple with sends it, under , to the bivector , the oriented plane normal to the vector . The two are exchanged by the pseudoscalar, the Hodge duality of the companion article's Section 1.9: multiplication by takes the bivector to the vector normal to it, and so on. So a quaternion that stores a direction stores the plane perpendicular to that direction and reaches the direction only by taking the dual. That a rotation has an axis is the reading of a bivector as its normal vector. The companion article marks this reading as an accident of three dimensions, the one dimension in which planes and directions are equal in number.


Part III

3. Demystifying rotation

3.1. Unit quaternions as rotors

The companion article's Section 1.10 defines a rotor as an even-grade element , scalar part and bivector part , normalised so that , and it acts on a vector by the sandwich

By [eq:quat-as-rotor] a unit quaternion is such an element, scalar plus bivector with , and by [eq:norm-is-RRtilde] the reverse is the conjugate. So the unit quaternion is the rotor, and the quaternion rotation [eq:quat-sandwich] is the rotor sandwich [eq:rotor-sandwich], with one difference of dress that Section 2.3 already flagged.

The rotor sandwich [eq:rotor-sandwich] acts on a vector, a grade-one element . The quaternion sandwich [eq:quat-sandwich] acts on a pure quaternion, which shows to be a bivector , the dual of that same vector. The two actions are the one rotation seen through the duality, because the rotor commutes past the central pseudoscalar: for any rotor and vector ,

since is central and commutes with and . Rotating the vector and then dualising gives the same result as dualising and then rotating. So the rotor may sandwich the direction or the plane perpendicular to it. The quaternion sandwiches the plane because Hamilton's imaginaries were bivectors and he had no vectors. The rotor sandwiches the vector directly. Nothing in the rotation depends on the choice.

3.2. Half-angle from two reflections

The half-angle that Part I could not account for has a one-line explanation in the rotor language. The companion article builds every rotation as a product of two reflections, and a reflection is given by a single unit vector through the sandwich . Composing the reflection in with the reflection in gives

and the composite is a rotation in the plane of and , about the line the two mirrors share, through twice the angle between them. The rotor is a product of two unit vectors and hence a scalar plus a bivector. If the angle between the mirrors is the rotation is through . So the rotor has angle and produces in the world. Writing the shared plane as the unit bivector with , the rotor is the exponential

the series collapsing to cosine and sine because , exactly as collapses because . Set with the axis imaginary of [eq:quat-axis-angle] and [eq:rotor-exp] becomes , Hamilton's unit quaternion. The half-angle is the record that a rotation is two reflections, and the two-sided sandwich, on the left and on the right, is the record that there were two mirrors. The figure sets the rotor sandwich beside the reflections it is made of.

The exponential form [eq:rotor-exp] shows the plane as primary. The plane in the exponent generates the rotation and the axis is its dual. The companion article makes the plane the generator of rotations in every dimension, where an axis need not exist. The quaternion is tied to three dimensions and could only name the axis. Its construction therefore looked arbitrary.

3.3. Double cover

The sign ambiguity of Part I is the other reflex of the two-sided sandwich, and it is now a one-line computation. Replacing by in [eq:rotor-sandwich],

the two minus signs cancel and the rotation is unchanged. So and give the one rotation and the map from unit rotors to rotations is two-to-one. The unit rotors are the sphere of Section 1.3; the rotations are the group ; and the two-to-one map identifies antipodes. So is the sphere with each point glued to its opposite, the real projective space . That map is the double cover, and it is why appeared in the matrix face [eq:pauli]: the unit quaternions are , the spin group , the connected double cover of the rotations.

The half-angle and the double cover are the same fact told twice. Because the rotor turns through while the world turns through , taking the world once around, , takes the rotor only halfway, , and at the rotor has reached , the negative of where it began, though every vector is back home. Only at , the world twice around, does the rotor return to . The figure drives a frame through two full turns and shows the rotor's scalar part passing through at the first, the frame identical to its start while the rotor is at the far side of its own sphere.

The same mathematics lies behind the plate trick and the belt trick, the physical demonstrations that a twist of a strap cannot be undone without moving the ends, while a twist can: objects whose orientation is tied to their surroundings track the rotor. The rotation closes after one turn and the rotor needs two. The spin-one-half of the electron is the same statement in quantum mechanics, that the wavefunction changes sign under a rotation and returns only after .

3.4. Composition and absence of gimbal lock

Two rotations compose by composing their rotors, and the composite rotor is the geometric product of the two,

The composite is the quaternion product : associative, sixteen real multiplications against the twenty-seven of a matrix product, and with no orthogonality to drift. That is the engineering case for quaternions.

A rotation stored as three Euler angles, a yaw then a pitch then a roll about successive axes, has a configuration in which two of the three axes align and a degree of freedom is lost: at pitch a quarter turn, yaw and roll act in the same plane and only their difference is recoverable (their sum at minus a quarter turn). A smooth motion of the body can then demand an unbounded rate in the angles or freeze one entirely. That loss is gimbal lock. Its cause is topological. Three periodic angles define a map from the three-torus onto , and were it a local diffeomorphism everywhere it would be a covering map and would embed in . No such embedding exists, so every three-angle chart of the whole group has singular points. A rotor is a single element of the group and moves smoothly wherever the group moves. The composition [eq:compose] never meets a coordinate edge because there are no coordinates. The figure runs a rotor and an Euler parameterisation side by side into the locked configuration. The rotor turns freely while the angle path stalls.

Smoothness requires the double cover. Since is and is no sphere, no continuous choice of a single rotor for each rotation exists over the whole group. Any global storage either doubles the rotations, as the unit quaternions do, or tears somewhere, as the Euler angles do. The quaternion must track a sign and has a parameterisation with no seam. The engineering habit of "flipping the sign to the near hemisphere" before interpolating is the bookkeeping of that doubling.

3.5. Storage order

Because the scalar and the three imaginary parts are stored as four numbers, and because two communities filled the array in opposite orders, a unit quaternion in memory is ambiguous until its convention is named. The scalar-first order places the cosine of the half-angle first and is used by the Eigen constructor, by MuJoCo and by Isaac Sim. The scalar-last order places it last and is used by SciPy's rotation module and by the ROS and tf2 robotics stack. The mathematics is indifferent to the order since the isomorphism involves no array indices. A pipeline that reads one order as the other permutes the four components and silently applies a different rotation: read as scalar-last, the scalar-first identity is a half-turn about . No length check catches the error since both readings are unit. The only defence is to make the order explicit at every boundary. Part V takes up this decision in code.


Part IV

4. Interpolation and recovery from a matrix

4.1. Interpolating on the sphere

A rotation is often wanted part-way between two others: a camera easing from one orientation to another or a joint blending two poses. Averaging the two matrices entrywise leaves the orthogonal group, and averaging the two Euler-angle triples moves through the gimbal singularities; the quaternion offers the correct path, the one that turns at constant rate about a fixed plane. Since unit quaternions are the sphere , the natural interpolation runs along the great circle joining them: spherical linear interpolation or slerp.

Let and be unit quaternions and let be the angle between them as points of , with their four-dimensional dot product. The great-circle interpolant is

which at is , at is , and in between traces the great circle at constant speed . The rotor language gives [eq:slerp] its meaning. The relative rotor is a rotation through some angle in some plane , so by [eq:rotor-exp] it is , and the interpolant is that relative rotor raised to the fraction ,

scaling the angle of the single relative turn linearly from zero to . Written this way the interpolation is a rotation at constant rate about a fixed plane, the motion a rigid body with equal principal moments of inertia makes when it turns from one attitude to another with nothing pushing it off. The chord interpolation, the straight average , cuts inside the sphere. Renormalised it returns to the surface but speeds up in the middle. The slerp stays on the surface and turns at constant rate.

The double cover matters here. The points and are the same rotation, one at angle from and the other at , so one of the two great-circle arcs is the short way round and the other is the long way. Interpolating without care can send a camera the long way about, three-quarters of a turn to reach an orientation a quarter turn away. The remedy is to test the sign of and negate when it is negative, choosing the representative in the near hemisphere before applying [eq:slerp]. That single sign test is the "quaternion interpolation gotcha" of the graphics literature: the double cover of [eq:sign-cancel] resolved by hand since no global choice resolves it once for all.

4.2. Recovering the quaternion from a rotation matrix

A rotation often arrives as a orthogonal matrix from a solver, a sensor fusion or a file format, and the quaternion has to be recovered from it. The naive route reads the scalar part from the trace. Since the rotor [eq:rotor-exp] rotates by and an orthogonal matrix has trace , and since , the half-angle identity gives

the off-diagonal differences picking out the antisymmetric part, the bivector that contains the axis. The formula is correct and treacherous. As the rotation approaches a half-turn, , the trace approaches , the scalar approaches zero, and the three divisions by approach division by nothing; the recovered axis, which is real and well defined at exactly a half-turn, is computed as a ratio of two vanishing quantities and loses its significant digits. The rotation is regular at . The instability lies in the division by the one component that vanishes there.

Shepperd's cure is never to divide by a small number. The four quantities

are, up to a factor of four, the squares of respectively, and they sum to , so at least one of them is at least and has a square root that is safe to use as a divisor. Shepperd's method computes whichever of corresponds to the largest of [eq:shepperd-quantities] from its own square root, then obtains the other three from the off-diagonal sums and differences, each divided by the large component found first. Branching on the largest of the four keeps every division well conditioned across the whole rotation group, the half-turn included. Shepperd's method is the standard robust conversion and a library should use it in place of [eq:trace-formula].

4.3. Input outside the rotation group

The conversion of Section 4.2 presumes its input is a rotation. Real data does not always oblige. A matrix may arrive scaled, sheared, reflected or filled with arbitrary numbers, and the conversion needs a defined behaviour.

One tempting answer is wrong. The quantities [eq:shepperd-quantities] sum to four and each recovered component is built from a square root of one of them. It seems that a matrix outside must yield four numbers off the sphere and that the norm of the output is a complete test of membership. The sum to four is an identity. Expanding it gives for every matrix, with no orthogonality used anywhere: a scaling by seven, a reflection and a matrix of random numbers each satisfy it exactly. An identity that holds for all matrices distinguishes none of them, so a test built on it separates nothing.

The method also reads only part of the matrix. On the branch taken when is the largest of the four, Shepperd's method sees the trace and the three off-diagonal differences , , . These differences are the antisymmetric part, the bivector of Section 4.2, and the method sees nothing else. Add to a rotation any symmetric matrix of zero trace and neither the trace nor the antisymmetric part moves. So the recovered quaternion stays fixed and so does its norm. The matrix

is the identity plus such a perturbation. Its determinant is : in the plane it acts in it stretches the diagonal direction by six and the antidiagonal direction by four with a reversal, so it reverses orientation. Shepperd's method hands back the identity quaternion, of unit norm, which the norm test then accepts. The conversion reports no rotation at all and reports it confidently.

The test that works is the definition, and Part II has already named it. A rotation is the sandwich of a unit rotor, and such a map sends an orthonormal right-handed frame to an orthonormal right-handed frame. Read the three columns of the matrix as the images of the basis vectors and the condition is exactly that: the columns are orthonormal () and right-handed (). Both halves are needed: orthonormality alone admits the reflections and the determinant alone admits any shear that preserves volume. The matrix [eq:not-a-rotation] is caught by the first. Six inner products and one determinant per row are tested against a tolerance. A matrix that is not a rotation returns null, and nothing is coerced into a plausible rotation it was never near. Part V records this null policy. Its predicate is is_rotation in pull request #7251, with [eq:not-a-rotation] among its test cases.


Part V

5. Implementation in code

5.1. Native rotation expressions in a data engine

The occasion for this article was a set of rotation expressions contributed to Daft, the open-source distributed engine for multimodal data. Daft reads the datasets of robotics and embodied AI, DROID, LeRobot, EgoDex and the MCAP logs of the ROS ecosystem, in which a camera extrinsic or a gripper pose is stored as a bare list of floating-point numbers, a quaternion or a rotation matrix with no operations attached. Turning one into the other, composing two or measuring the angle between two meant leaving the engine for a per-row Python function on every such dataset. The contribution adds the operations as native columnar expressions: build a rotation matrix from a quaternion or from a six-dimensional representation, recover a quaternion from a matrix, compose, invert and apply quaternions, and measure the geodesic angle between two rotations. The proposal and its rationale are in issue #7250 and the implementation in pull request #7251.

Such a dataset records the object of this article. A logged motion is a sequence of frames, and each frame is a tuple of orientations, one rotor per joint, with nothing dynamical attached: no force, torque or mass. The figure below plays one gait cycle of a biped assembled from nothing but its per-joint rotors, the forward kinematics composing them down each limb by the geometric product and placing every segment by the sandwich. At each joint sits the rotation bivector that generates that joint's rotor, the oriented plane of turning: the hip, knee, ankle, shoulder and elbow flex in the sagittal plane and the pelvis and the shoulder girdle yaw in the different plane . So the discs sit at visibly different tilts. The girdle rotor is the one the arms hang from and runs opposite in sign to the pelvis. So the trunk untwists in the transverse plane what the legs twist: two rotors share a plane and cancel most of each other's turn. Read in pose, each disc tracks its joint angle; read in rate, it tracks the angular speed. The walk is a path through the product of the joint rotor groups, and the pose data is that path sampled.

The mathematics of Parts II to IV is the specification the code implements. Three decisions make the article executable.

5.2. Decisions fixed by the algebra

The matrix-to-quaternion conversion uses Shepperd's method for the reason of Section 4.2: a data engine cannot know that no row of a billion contains a half-turn and the trace formula loses precision there. Branching on the largest of the four quantities [eq:shepperd-quantities] keeps the conversion accurate across the whole group. The columnar loop absorbs the few comparisons per row.

The null policy is one rule across the module, the rule of Section 4.3: a matrix that is not a rotation returns null and never a fabricated quaternion, tested as with against a tolerance set above floating-point rounding and above the roughly error of widening a single-precision rotation to double. Zero quaternions, degenerate six-dimensional frames, and non-finite inputs fall under the same policy, as does a row with a null component: a columnar engine stores a number under a null slot, usually a zero, and reading it without the validity mask would turn the quaternion into a half-turn about . The engine returns a rotation only where a rotation was given, and marks the rest absent. A malformed row propagates as missing data and never as a plausible wrong orientation that no downstream check would flag.

The quaternion component order is an explicit argument, defaulting to scalar-last to match SciPy and the robotics stack, with scalar-first available for the Eigen and simulator convention. The reason is that of Section 3.5: the choice is made once at the boundary of the system, where reading an array in the wrong order produces a unit quaternion that is silently the wrong rotation. A named parameter prevents the silent failure and puts the decision where the data's provenance is known.

5.3. Scope of the identification

This article follows a single identification and its consequences. Hamilton's quaternions are the even subalgebra , the scalar and the three bivectors of ordinary space; a unit quaternion is a rotor; and the sandwich, the half-angle, the double cover, the axis, the freedom from gimbal lock and the interpolation sign test are facts about rotors.

The identification also shows where the quaternion stops. The rotor is defined in every dimension: the even subalgebra of generates the rotations of -space by the same sandwich, with the plane of rotation as the generator and no axis assumed. The quaternion is the appearance of that construction at , where the even subalgebra happens to be four-dimensional and to close on itself as a division algebra. The companion article files this coincidence under the accidents of three dimensions, alongside the cross product and the axis of a rotation. In three dimensions the quaternion is the rotor, and using the name the engineering world settled on does no harm and often gains speed and stability. Above three dimensions the rotor continues and the quaternion does not. The rotor, the even-grade element turning a vector by a two-sided product, is the thing itself. Hamilton cut the right algebra into the bridge; it took the vectors he did without, and the century that added them, to see which algebra it was.