← Back to the knowledge system
03 Geometric foundations 3D Vision SLAM Robotics

Rotation & Orientation Representations

Rotation and
Orientation Representations

Rotation has only 3 degrees of freedom but can use 3, 4, 6, or 9 numbers. The geometric object belongs to SO(3); Euler angles, quaternions, and matrices encode it with different singularities, constraints, and ambiguities.

Geometric Object

Start with relationships between coordinate axes

Under the site's column-vector convention, R's columns are the rotated object x, y, and z axes expressed in the reference frame. Rotation preserves length, angle, and handedness, without translation, scale, or reflection.

ORIENTATION

Orientation is a state

Orientation describes how object axes are arranged relative to reference axes. It is always frame-relative.

ROTATION

Rotation is a mapping

R rotates vectors or basis axes into new directions. Composition and inversion give the relative rotation between orientations.

REPRESENTATION

Representations encode numbers

Matrices, Euler angles, rotvecs, quaternions, and 6D vectors encode the same geometry for storage and computation.

Special orthogonal group
SO(3)={R∈R3×3∣RTR=I, det⁡(R)=+1}\mathrm{SO}(3)=\left\{\mathbf R\in\mathbb R^{3\times3}\mid \mathbf R^{\mathsf T}\mathbf R=\mathbf I,\ \det(\mathbf R)=+1\right\}
Orthogonality makes columns perpendicular and unit length; det = +1 excludes reflections. SO(3) is a three-dimensional manifold, not an ordinary R³ vector space.

Column interpretation

R = [ r1   r2   r3 ]

r1

Object +x direction expressed in the reference frame

r2

Object +y direction expressed in the reference frame

r3

Object +z direction expressed in the reference frame, with r₃ = r₁ × r₂

Representation Atlas

Why encode the same R in different ways?

No representation simultaneously optimizes readability, unconstrained parameters, global continuity, uniqueness, composition efficiency, and neural regression. Choose suitable representations for interfaces and convert explicitly at boundaries.

3×3 MATRIX

Rotation matrix

A common language for geometry: rotate vectors and compose orientations directly; columns are rotated basis axes.

9 numbers · 6 constraints
3 ANGLES

Euler / Tait–Bryan

Three ordered rotations about axes. Convenient for interfaces, but admits multiple solutions and gimbal lock.

order + frame + unit
AXIS × ANGLE

Axis–angle / rotation vector

Rotate by θ around unit axis u. Rotvec combines them as θu, matching OpenCV rvec semantics.

r = θu ∈ R³
UNIT 4-VECTOR

Quaternion

Unit quaternions lie on S³ and support efficient composition and SLERP, while q and −q map to one rotation.

xyzw ≠ wxyz
NEURAL EMBEDDING

Continuous 6D representation

Predict the first two matrix columns and decode a valid R through Gram–Schmidt, commonly used for deep regression.

a₁, a₂ → b₁, b₂, b₃
LOCAL COORDINATES

so(3) / Lie algebra

Small 3D tangent-vector increments near the current rotation map back to SO(3) through exp, supporting optimization and filtering.

R ← Exp(δφ) R
RepresentationStorage shapeUniquenessSingularity / continuityStrengthsMain pitfalls
Rotation matrix3×3 · 9 valuesUnique matrixNo parameter singularityDirect composition and vector transformation; clear geometry6 constraints; raw network outputs must be projected onto SO(3)
Euler / RPY3 valuesNot uniqueGimbal lockReadable controls and mechanical-joint semanticsRecord axis order, intrinsic/extrinsic convention, angle units, and ranges
Axis–angle / rotvec3 axis + 1 angle / 3 valuesPeriodic and boundary equivalencesArbitrary axis at zero angle; discontinuity near πCommon in Rodrigues, PnP, local optimization, and Lie-algebra updatesRotvec magnitude is the angle, not three Euler angles
Unit quaternion4 values + unit constraintq and −q are equivalentNo gimbal lockEfficient composition and interpolation; common in robotics and SLAMHandle xyzw / wxyz order and double cover
Continuous 6D representation2×3 · 6 valuesUnique after decodingDegenerate when predicted columns are collinearSuitable for neural regression; avoids low-dimensional global discontinuity6 is the embedding dimension, not extra degrees of freedom; requires Gram–Schmidt
9D + SVD3×3 · 9 valuesUnique after projectionUnstable under singular-value degeneracySimple outputs with SVD / polar projection onto SO(3)Correct reflections where det = −1

Interactive Lab

Connect every representation to the same rotation

The first view converts yaw–pitch–roll to matrices, quaternions, axis–angle, rotvec, and 6D. The second separates object-center rays from object orientation to explain allocentric / egocentric and in-plane / out-of-plane rotation.

Interactive · SO(3)

Rotation Representation and Viewpoint Lab

Explore different encodings of one physical rotation, then compare egocentric, allocentric, and in-plane / out-of-plane decompositions.
Right-handed frames Column vectors R = RzRyRx
ref Yref Zref x y z Rotation preserves lengths and angles Solid colors: object frame · translucent lines: reference frame
+X +Y +Z Fixed viewpoint · nonperspective projection

9 numbers · 6 constraints

Rotation matrix R

SO(3)
[
0.0000.0000.0000.0000.0000.0000.0000.0000.000
]
det(R)
+1.000000
‖RᵀR−I‖F
0.00e+0
Geodesic angle from I
0.00°

4 numbers · unit sphere

Unit quaternion

q ≡ −q

Display order: [x, y, z, w](scalar-last)

scalar-first:

Axis × angle

Axis–angle and rotation vector

Rodrigues
Unit axis u
Angle θ
Rotation vector θu

Learning-friendly embedding

Continuous 6D representation

Gram–Schmidt
First two columns of R

The network predicts two 3D vectors, then orthogonalizes them into a rotation matrix. Output dimension differs from rotational degrees of freedom.

Euler Angles

Euler angles require a complete convention

Three angles define reproducible rotation only with axis order, fixed or moving reference axes, action direction, and angle units. Roll/Pitch/Yaw names alone do not resolve these choices.

Site convention

The matrix formula is the final definition here

  • Right-handed, active rotation, column vectors
  • roll = α about x, pitch = β about y, yaw = γ about z
  • R = Rz(γ) Ry(β) Rx(α)
  • Degrees in the interface; radians internally
Yaw–Pitch–Roll matrix
R=Rz(γ)Ry(β)Rx(α)\mathbf R=\mathbf R_z(\gamma)\mathbf R_y(\beta)\mathbf R_x(\alpha)
This product represents active fixed-axis rotations applied x, then y, then z; equivalently, moving-axis rotations described in reverse order. Libraries differ in case and sequence naming, so use the actual formula and test vectors.
01

Extrinsic · fixed axes

Axes stay in the reference frame

Each step rotates about an original world axis. For action order x → y → z, column vectors yield Rz Ry Rx.
02

Intrinsic · moving axes

Axes move with the object

Each step uses updated local axes. Equivalent fixed-axis rotations use the reverse order, which verbal descriptions can easily confuse.
03

Euler vs. Tait–Bryan

Repeated axes

ZXZ and ZYZ repeat the first/last axis and are proper Euler sequences. XYZ and ZYX use three distinct axes and are Tait–Bryan sequences, as RPY usually is.
Gimbal lock at pitch = +90°
Rz(γ)Ry ⁣(π2)Rx(α)=Rz(γ−α)Ry ⁣(π2)\mathbf R_z(\gamma)\mathbf R_y\!\left(\frac{\pi}{2}\right)\mathbf R_x(\alpha)=\mathbf R_z(\gamma-\alpha)\mathbf R_y\!\left(\frac{\pi}{2}\right)
Orientation depends only on γ−α: yaw and roll cannot be identified independently. The rotation remains valid; the local Euler parameterization fails.

Axis–Angle & Quaternion

Avoiding gimbal lock does not remove all boundaries

Axis–angle has an arbitrary axis at θ = 0 and a sign boundary near θ = π. Unit quaternions lie on the unit sphere in four-dimensional space, with q and −q representing the same rotation. Adjacent trajectory quaternions are usually aligned to one hemisphere before interpolation.

Rodrigues formula
R=exp⁡([ϕ]×)=I+sin⁡θθ[ϕ]×+1−cos⁡θθ2[ϕ]×2,ϕ=θu\mathbf R=\exp([\boldsymbol\phi]_\times)=\mathbf I+\frac{\sin\theta}{\theta}[\boldsymbol\phi]_\times+\frac{1-\cos\theta}{\theta^2}[\boldsymbol\phi]_\times^2,\quad \boldsymbol\phi=\theta\mathbf u
[·]× is the cross-product matrix. For small θ, use stable series expansions or library routines to avoid division by near-zero values.
ORDER

Check xyzw / wxyz first

SciPy defaults to scalar-last; many robotics libraries and papers use scalar-first. Both have shape 4, allowing dangerous silent ordering errors.

NORM

Maintain unit length

Normalize network outputs and integrated states; a zero vector cannot be normalized into a valid quaternion.

DOUBLE COVER

Treat q and −q as equivalent

Losses can use min(‖q̂−q‖, ‖q̂+q‖); trajectories use adjacent dot products to decide sign flips.

SLERP

Interpolate along the short spherical arc

Normalized linear interpolation does not give constant angular velocity; prefer SLERP for large-angle interpolation.

View-Space Decomposition

Egocentric, Allocentric, and In-Plane / Out-of-Plane Rotation

These terms concern camera viewpoints and orientation decomposition, distinct from intrinsic/extrinsic Euler angles. They appear in cropped-object learning, template-view sampling, and category-level rotation estimation.

EGOCENTRIC

Rotation relative to the actual camera frame

This is R in the final object → camera pose. Even with similar local appearance, moving from image center to edge changes the object-center ray and thus egocentric values.

ALLOCENTRIC

Normalize the viewing ray to a virtual central viewpoint

Imagine a virtual camera looking along the object-center ray, then align that ray with the principal optical axis. This reduces coupling between image position and rotation labels for RoI/crop feature learning.

IN-PLANE

Rotation around the viewing ray

Mainly appears as contour rotation in the image plane. Near the principal point, it is often approximated by camera-z rotation; strictly, the axis is the camera-to-object-center ray.

OUT-OF-PLANE

Changes viewing direction and visible surfaces

Tilting or turning around an object changes occlusion, foreshortening, and visible surfaces. Template methods usually sample viewpoints on a sphere and in-plane angles separately.

One common allocentric lifting convention
Rego=RrayRallo,Rray: [0,0,1]T↦[x,y,z]Tx2+y2+z2\mathbf R_{\mathrm{ego}}=\mathbf R_{\mathrm{ray}}\mathbf R_{\mathrm{allo}},\qquad \mathbf R_{\mathrm{ray}}:\ [0,0,1]^{\mathsf T}\mapsto \frac{[x,y,z]^{\mathsf T}}{\sqrt{x^2+y^2+z^2}}
The lab defines Rray as the minimum rotation from the principal optical axis to the object-center ray. Papers may use the inverse or another multiplication side; check implementation conventions.

Learning & Optimization

Network outputs may lie in Rⁿ; losses and evaluation must respect rotation geometry

Networks need regressable vectors, optimizers stable local increments, interfaces efficient composition, and evaluation symmetry equivalence. Choose representations for the full chain rather than output dimension alone.

6D decode by Gram–Schmidt
b1=a1∥a1∥,b2=a2−(b1Ta2)b1∥a2−(b1Ta2)b1∥,b3=b1×b2\mathbf b_1=\frac{\mathbf a_1}{\|\mathbf a_1\|},\quad \mathbf b_2=\frac{\mathbf a_2-(\mathbf b_1^{\mathsf T}\mathbf a_2)\mathbf b_1}{\|\mathbf a_2-(\mathbf b_1^{\mathsf T}\mathbf a_2)\mathbf b_1\|},\quad \mathbf b_3=\mathbf b_1\times\mathbf b_2
R = [b₁ b₂ b₃]. If a₁ is near zero or a₂ nearly collinear with a₁, denominators become small; use epsilon safeguards and invalid-input checks.
Geodesic rotation error
dSO(3)(R^,R)=cos⁡−1 ⁣(clamp⁡ ⁣(tr⁡(R^TR)−12,−1,1))d_{\mathrm{SO}(3)}(\hat{\mathbf R},\mathbf R)=\cos^{-1}\!\left(\operatorname{clamp}\!\left(\frac{\operatorname{tr}(\hat{\mathbf R}^{\mathsf T}\mathbf R)-1}{2},-1,1\right)\right)
The shortest relative angle lies in [0, π]. Clamping handles floating-point error; this respects rotation geometry better than subtracting Euler angles.
01

Network output

6D / quat / 9D
→
02

Valid rotation decoding

normalize / GS / SVD
→
03

Geometric loss

geodesic / point loss
→
04

Symmetry reduction

min over equivalence
→
05

Downstream use

projection / control

Project 9D onto SO(3)

Correct reflections during SVD

M = UΣVᵀ
R = U diag(1, 1, det(UVᵀ)) Vᵀ
Using UVᵀ directly can produce a reflection with det = −1.

Rotation error for symmetric objects

Labels need not define a unique pose

dsym(R̂, R) = minS∈G d(R̂, RS)Discrete or continuous symmetries enter losses and evaluation through equivalent-rotation sets G.

Across Domains

How the same rotation appears across tasks

POSE

6D object pose estimation

Networks may regress 6D representations, quaternions, or rotvecs, but geometric estimation, projection, and evaluation usually use rotation matrices. Symmetric objects require comparing equivalent rotations.

SLAM

Visual SLAM and state estimation

Optimizers often update rotations in the local tangent space of SO(3), while storing states as quaternions. Quaternion components must not be added as independent Euclidean variables.

ROBOT

Robotics and calibration

Controls often use RPY, kinematic chains use matrices / homogeneous transforms, and interpolation and messages use quaternions. Interfaces are common sources of order and frame errors.

GRASP

Robotic Grasping

Grasp orientation includes approach and closing axes and roll about the approach axis. Gripper symmetry can make multiple rotations represent the same executable grasp.

Debug Protocol

Diagnose rotations with falsifiable tests

Use identity, single-axis 90°, near-π, gimbal-lock, and q/−q cases specifically designed to reveal convention errors.

  1. 01

    Identity test

    All representations should recover I; quaternions are [0,0,0,±1] and rotvec is 0.

  2. 02

    Single-axis +90° test

    For example, Rz(+90°)[1,0,0]ᵀ must give [0,1,0]ᵀ, exposing handedness, active/passive, and transpose errors.

  3. 03

    Check SO(3) invariants

    Verify RᵀR≈I and det(R)≈+1. A determinant near −1 usually indicates reflection or missing SVD correction.

  4. 04

    Round-trip conversions

    For Euler→R→quat→R, compare matrices or geodesic angles rather than requiring identical final Euler components.

  5. 05

    Cover boundary cases

    Test pitch=±90°, θ≈π, q and −q, crossings of ±180°, and nearly collinear 6D columns.

  6. 06

    Finally project model axes

    Project object xyz axes, CAD contours, and asymmetric features into the image to confirm agreement between numerical conventions and visual results.

Sources for conventions, formulas, and papersExpand official documentation and original papers

Next topic · 04

Camera Models & Imaging Geometry

Next, follow 3D camera coordinates into 2D pixels through intrinsics, extrinsics, perspective projection, distortion, depth back-projection, and RGB-D alignment.
Locate this topic on the knowledge map