---
kind: concept
slug: unit-quaternion-rotation
title: Unit-quaternion rotation
summary: >-
  A unit quaternion q represents a 3D rotation as q v q-bar. The papers use it in different roles: the unknown of a closed-form fit to vector pairs (smallest eigenvector of a 4x4 matrix), of a penalised non-linear fit with translation, or of a dual-quaternion pose fit solved by a trust region; or a network output renormalised after each step. Author-reported results do not compare across roles.
tags: [quaternions, rotation, optimization]
papers: ["2102.04942", "2102.12400", "2311.12655", "2610.19734"]
related: [hand-eye-calibration, error-state-kalman-filter, lidar-inertial-odometry, dual-quaternion, perspective-n-point]
status: draft
updated_at: 2026-10-18
---

## Overview

A unit quaternion q, with q-bar its conjugate, rotates a 3-vector v to
q v q-bar [arxiv:2311.12655 §5.1]. Given pairs of vectors (v, v'), the task is
to find the unit q that makes v' close to q v q-bar. The residual is
||v' - q v q-bar||^2 [arxiv:2311.12655 §5.1]. The unit-length condition is the
part that makes the problem non-trivial: the residual rewrites as a quadratic
form only when q has unit length [arxiv:2311.12655 app. B].

The papers use the quaternion in different roles. In hand-eye
calibration it is the unknown of a fitting problem [arxiv:2311.12655 §4]
[§5]. In motion synthesis it is a per-joint pose output that a network
renormalises [arxiv:2102.04942 §3.1] [§3.2]. In a LiDAR-inertial-visual
estimator the rotation is a filter state updated on a manifold, and the card
does not show a unit quaternion for it [arxiv:2102.12400 §IV-A]. In 2-D to 3-D
object pose, the unit quaternion is the real part of a dual-number quaternion
that also carries the translation [arxiv:2610.19734 §2.1].

## Variants

Three solvers fit a unit quaternion to data. They differ in how the
unit-length condition is handled: exactly by construction in the closed form,
and by a penalty in the two non-linear fits. A fourth use treats the
quaternion as a network output.

### Closed form: smallest eigenvector

The residual over all pairs becomes q^T A q, where A is a 4x4 symmetric matrix.
It is the sum of (Q(v') - W(v))^T (Q(v') - W(v)) over the pairs, with Q and W
the left and right quaternion-product matrices [arxiv:2311.12655 §5.1]
[eq. 29] [app. A]. The minimising unit q is the eigenvector of A for its
smallest eigenvalue [arxiv:2311.12655 §5.1]. The eigenvector is defined only
up to sign, and q and -q give the same rotation [arxiv:2311.12655 §5.1].

The rewrite to q^T A q multiplies the residual by ||q||^2 and then drops that
factor. This is exact only for unit q [arxiv:2311.12655 §5.1] [app. B]. The
closed form does not add a penalty; the paper gives the penalty only for the
joint method [arxiv:2311.12655 §5.2]. The paper credits the closed-form
rotation to Faugeras and Hebert (1986) and to Horn (1987). Those works are
named only here [arxiv:2311.12655 §5.1] [app. A].

Card: [Hand-Eye Calibration](/papers/2311.12655).

### Joint penalised non-linear

The unit quaternion is one of seven unknowns, with the translation. The cost
adds a penalty λ(1 - q^T q)^2 that keeps q near unit length
[arxiv:2311.12655 §5.2] [eq. 30]. The paper sets λ = 2 × 10^6 in all its
experiments [arxiv:2311.12655 §5.2]. The minimisation uses Levenberg-Marquardt,
and the paper says a trust-region method would also suit it [arxiv:2311.12655
§5.2]. The starting value q0 is not stated, and the stopping rule is not
stated [arxiv:2311.12655 §5.2].

Because the penalty only encourages unit length, the optimiser's q is not
guaranteed to be unit length. The paper keeps q near unit length only through
this penalty [arxiv:2311.12655 §5.2] [eq. 30] [eq. 31].

Card: [Hand-Eye Calibration](/papers/2311.12655).

### Dual-quaternion pose, penalised, trust region

Here the unit quaternion is the real part r of a dual-number quaternion r + ε s,
with ε² = 0. The rotation is read from r, and the translation from s
[arxiv:2610.19734 §2.1] [eq. 6] [eq. 7]. The constraints are r·r = 1 and
r·s = 0 [arxiv:2610.19734 §2.1]. Both are enforced by penalties, with
λ(r·r − 1)² and λ(r·s)², and λ = 50 in the experiments [arxiv:2610.19734 §2.2]
[eq. 13]. The paper says a too-large λ slows convergence [arxiv:2610.19734 §2.2].
Its λ is not comparable to the 2 × 10^6 used in the joint solver above (see
Contradictions).

The minimiser is a trust-region method. The paper names Levenberg-Marquardt as
the alternative and says it is poorly conditioned when its damping is near zero
[arxiv:2610.19734 §4.2]. A split variant first minimises a rotation-only error
in r [eq. 14], then solves a linear least-squares problem for s [eq. 15]
[arxiv:2610.19734 §2.2]. The paper does not say whether r is re-estimated
jointly with s afterwards [arxiv:2610.19734 §2.2]. The initial pose and the
trust radius are not stated [arxiv:2610.19734 §4.1]. The paper does not state
the residual vector for the penalty terms [arxiv:2610.19734 §4]. It does not
discuss that r and −r give the same rotation [arxiv:2610.19734 §2.1].

Card: [Dual-quaternion object pose](/papers/2610.19734).

### Normalised network output

Robust Motion In-betweening stores each joint's rotation as a quaternion of
4 values [arxiv:2102.04942 §3.1]. Its generator predicts quaternion velocities,
adds them to the state, and then normalises the quaternions to unit length
before forward kinematics [arxiv:2102.04942 §3.2]. Here unit length is enforced
by a projection after each step, not by a penalty. The paper does not state how
the velocity is added to the previous quaternion [arxiv:2102.04942 §3.2].
The paper does not discuss the sign ambiguity (q and -q are the same rotation)
in its losses [arxiv:2102.04942 §3.6.1].

Card: [Robust Motion In-betweening](/papers/2102.04942).

## When to use which

Pick by where the rotation lives: an unknown in a one-off fit, a network output
that must stay valid, or a filter state updated on each sensor event.

| Situation | Use | Why |
|---|---|---|
| No starting guess is available, or a single non-iterative solve is needed | Closed form | It needs no q0. The closed-form rotation-then-translation method takes 0.06 to 0.08 s on the paper's third data set, on a Sparc-10 [arxiv:2311.12655 tab. 3]. |
| Noisy measurements, a few motions, and an iterative solve is affordable | Joint penalised | In simulation with two motions and 1% to 6% noise, it is the most accurate in all reported settings [arxiv:2311.12655 §6]. On the third data set it takes 0.21 to 0.25 s [arxiv:2311.12655 tab. 3]. |
| Pose of a known 3-D object from 2-D point or line matches, with a trust-region solver affordable | Dual-quaternion, penalised, trust region | Author-reported: with 100 points and noise amplitude 1.00 (pixels, per the table caption), translation error is 0.0002 cm, against 11.4770 cm for the linear Faugeras-Toscani method [arxiv:2610.19734 tab. 2] [tab. 8]. The paper gives no Levenberg-Marquardt or Newton numbers [arxiv:2610.19734 §4.2] [§6]. It reports 4.83 s for 460 points, and the hardware of that table is not stated [arxiv:2610.19734 tab. 7]. |
| Rotation error is the main concern on real data | Check per data set | On the third data set, classical Tsai-Lenz has the lowest rotation error (0.014). The closed form has 0.036 and the joint method 0.258 [arxiv:2311.12655 tab. 3]. The paper says linear methods can give better rotation on real data [arxiv:2311.12655 §7]. |
| A learned model outputs rotations that must be valid after every step | Normalised output | The paper renormalises each predicted quaternion before forward kinematics [arxiv:2102.04942 §3.2]. The card's result tables do not isolate this step. |
| A filter tracks orientation between sensor events | Manifold update | The error state is 21-dimensional and updated on the tangent space [arxiv:2102.12400 §IV-A]. The paper runs the IMU propagation at IMU rate and corrects it at LiDAR and camera frames [arxiv:2102.12400 §IV-I]. |

The paper's results are author-reported. Its simulations use a 157 mm nominal
translation norm for normalisation, and its real data sets are three robot
setups [arxiv:2311.12655 §6] [§7]. The rankings above come from those setups
and do not transfer to other robots without a test.

## Implementation sketch

The closed-form rotation and the joint cost share the same residual. The
pseudocode below gives the rotation part only. The joint cost in the paper also
has translation residuals, which the [hand-eye calibration](/concepts/hand-eye-calibration)
concept page covers.

```pseudocode
# Closed-form unit quaternion from vector pairs  [arxiv:2311.12655 §5.1]
# Input:  pairs v[i], v_prime[i] of 3-vectors, with v_prime ~ q v q-bar
# Output: unit quaternion q, defined up to sign

def closed_form_rotation(v, v_prime):
    # 1. Sum the 4x4 symmetric matrices  [eq. 29]
    A = zeros(4, 4)
    for i in range(len(v)):
        # Q, W: left and right quaternion-product matrices  [app. A]
        D = Q(v_prime[i]) - W(v[i])
        A = A + transpose(D) @ D
    # 2. Eigenvector of A for its smallest eigenvalue  [§5.1]
    return smallest_eigenvector(A)
```

```pseudocode
# Joint penalised rotation fit  [arxiv:2311.12655 §5.2]  [eq. 30]
# Input:  pairs as above, starting value q0 (not stated in the paper)
# Output: quaternion q, unit length only approximately

def joint_rotation(v, v_prime, q0):
    def cost(q):
        total = 0
        for i in range(len(v)):
            # rotation residual, weight lambda_1 = 1  [§5.2]
            total += norm2(v_prime[i] - rotate(q, v[i]))
        # penalty towards unit length, lambda = 2e6  [§5.2]
        total += 2e6 * (1 - dot(q, q)) ** 2
        return total
    # Levenberg-Marquardt  [§5.2]
    return levenberg_marquardt(cost, q0)
```

```pseudocode
# Renormalise a predicted quaternion after an update  [arxiv:2102.04942 §3.2]
# Input:  q, the quaternion after adding the predicted velocity
# Output: the same rotation direction with unit length

def normalize_unit(q):
    # Divide by the norm; the paper's exact integration rule is not stated
    return q / norm(q)
```

Here `rotate(q, x)` is q x q-bar [arxiv:2311.12655 app. A].

## Contradictions

No direct disagreement across papers. The papers use the quaternion in different
roles and report different quantities, so their numbers do not compare.

The penalty weights differ by orders of magnitude: 2 × 10^6 on (1 − q^T q)^2
for the joint hand-eye solver [arxiv:2311.12655 §5.2], and 50 on (r·r − 1)^2
for the dual-quaternion pose solver [arxiv:2610.19734 §2.2]. The two penalties
sit on different residuals, and the second also has an orthogonality term, so
the weights are not interchangeable.

Within one paper: the text says the joint non-linear method gives
"sometimes slightly less accurate rotation" on real data [arxiv:2311.12655 §7].
In [arxiv:2311.12655 tab. 3], the classical joint method has a rotation error
of 0.258, against 0.014 for the classical Tsai-Lenz baseline. The paper does not
comment on this gap.

## Papers

- [Hand-Eye Calibration](/papers/2311.12655): a closed-form unit-quaternion
  rotation solver and a joint penalised non-linear solver, applied to
  hand-eye calibration.
- [Robust Motion In-betweening](/papers/2102.04942): unit quaternions as the
  per-joint pose output of a generator, renormalised to unit length.
- [R2LIVE](/papers/2102.12400): an error-state filter that updates orientation
  on the manifold. The card lists this concept, but the rotation is not written
  as a unit quaternion there.
- [Dual-quaternion object pose](/papers/2610.19734):
  a dual-number quaternion pose fit from point and line correspondences, with a
  penalised unit-length term and a trust-region solver.
