quat2mat3: Quaternion to Matrix Transformation
Mathematical Foundation of Spatial Orientation
Quaternions represent rotations in 4D space using unit vectors on the complex hypersphere. This function converts the quaternion representation into its equivalent 3×3 rotation matrix form.
The transformation follows the mathematical relationship:
This conversion preserves orthogonality and determinant properties essential for rigid body transformations.
Hypersphere Navigation Through Quaternion Space
The quaternion-to-matrix transformation reveals the geometric relationship between 4D unit sphere coordinates and 3D rotational manifolds. Each point on the quaternion hypersphere maps to a unique rotation in 3D space.
ライブエディター
const fragment = () => { const angle = uv.y.atan2(uv.x) const radius = uv.length() const q = vec4( angle.add(iTime).sin(), angle.mul(2).cos(), radius.mul(3).add(iTime.mul(0.7)).sin(), radius.mul(2).sub(iTime.mul(0.3)).cos() ).normalize() const matrix = quat2mat3(q) const basePattern = vec3(0, 0, 1) const rotated = matrix.mul(basePattern) const color = rotated.mul(0.5).add(0.5) return vec4(color, 1) }
The mathematical beauty lies in how quaternion multiplication preserves rotation composition, while the matrix form enables direct geometric transformations in Euclidean space.