Quaternion Algebra

SkillDev tools

Abstract math for quaternion algebra (hypercomplex numbers ℍ). USE FOR: implementing quaternion multiplication (Hamilton product, non-commutative); conjugate, norm, and inverse; unit quaternions on S³ as double cover of SO(3); rotating 3D vectors with quaternions; understanding why q and −q represent the same rotation; normalizing after operations; constructing rotation quaternions from axis-angle. DO NOT USE FOR: converting between rotation representations (use 3d-rotation-theory); slerp/lerp interpolation (use interpolation-on-manifolds); basic vector cross/dot products (use vector-algebra).

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Quaternion Algebra skill

What this skill tells your AI

The instructions your AI receives, as published by netfabric/netfabric.numerics in .agents/skills/quaternion-algebra/SKILL.md and read by ahel’s review.

Structure

A quaternion q = (x, y, z, w) = xi + yj + zk + w where i, j, k are imaginary units.

Also written as q = (v, w) with vector part v = (x, y, z) and scalar part w.

i² = j² = k² = ijk = −1
ij = k,  jk = i,  ki = j
ji = −k, kj = −i, ik = −j

Core Operations

OperationFormula
Addition(x₁+x₂, y₁+y₂, z₁+z₂, w₁+w₂) — component-wise
Conjugateq* = (−x, −y, −z, w)
Normq‖ = √(x²+y²+z²+w²)
Norm squaredq‖² = x²+y²+z²+w²
Scalar multiplykq = (kx, ky, kz, kw)

Hamilton Product (Non-Commutative)

q₁ · q₂ = (w₁w₂ − x₁x₂ − y₁y₂ − z₁z₂,
            w₁x₂ + x₁w₂ + y₁z₂ − z₁y₂,
            w₁y₂ − x₁z₂ + y₁w₂ + z₁x₂,
            w₁z₂ + x₁y₂ − y₁x₂ + z₁w₂)

q₁q₂ ≠ q₂q₁ in general. Order matters for composed rotations.

Inverse & Division

q⁻¹ = q* / ‖q‖²

For unit quaternions: q⁻¹ = q* (conjugate = inverse).

Unit Quaternions

q‖ = 1. Lives on S³ ⊂ ℝ⁴. Every unit quaternion represents a 3D rotation. Map S³ → SO(3) is 2-to-1: q and −q encode the same rotation.

Rotating a Vector

p' = q · (0, p) · q⨉ (pure quaternion sandwich; extract x,y,z from result)

Reference Files

FileLoad When
references/formulas.mdFull Hamilton product derivation, double-cover proof, rotation construction
references/numerical-stability.mdNormalization drift, dot product sign, re-normalization strategies

Signals

GitHub stars
36
Forks
1
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
quaternion-algebra
Source
github.com/netfabric/netfabric.numerics