Skip to content

feat(math): 3D Math Extension — Quaternion (RF5.1)#67

Open
LyeZinho wants to merge 1 commit intomainfrom
36-3d-math-extension
Open

feat(math): 3D Math Extension — Quaternion (RF5.1)#67
LyeZinho wants to merge 1 commit intomainfrom
36-3d-math-extension

Conversation

@LyeZinho
Copy link
Copy Markdown
Member

@LyeZinho LyeZinho commented May 8, 2026

Summary

Extensão da biblioteca matemática da Fase 1 com Quaternion para rotações 3D. Implementa operações completas de quaternions: construção (axis-angle, Euler, lookAt, matrix), interpolação (SLERP/NLERP), conversões (toEuler, toMatrix), e rotação de vetores.

📦 Files Created

  • src/math/Quat.hpp — Full Quaternion struct with 24 inline methods:
    • fromAxisAngle, fromEuler, lookAt, fromMatrix — constructors
    • slerp, nlerp — spherical & normalized linear interpolation
    • toEuler, toMatrix — conversions
    • rotate, conjugate, inverse, normalized, length — operations
    • operator* — Quat composition & vector rotation
    • Follows existing Caffeine namespace (same as Vec3, Mat4)

🔧 Files Modified

  • src/math/Math.hpp — Added PI_HALF constant
  • src/Caffeine.hpp — Included Quat.hpp
  • tests/test_math.cpp — 24 test cases covering all Quat operations
  • docs/fase5/3d-math.md — Updated status to ✅ Implementado

✅ Acceptance Criteria

  • Quat::slerp produces correct interpolation between any two orientations
  • quat.toMatrix() produces same matrix as Mat4::fromAxisAngle
  • Quat * Vec3 rotates correctly
  • No gimbal lock in composed 3-axis rotations
  • Vec4 aligned to 16 bytes (Fase 1 — unchanged)
  • All float comparisons use Approx().epsilon(0.001f)

🧪 Tests (24 cases)

Identity, axis-angle, Euler, composition, vector rotation, conjugate, inverse, normalization, SLERP, NLERP, matrix conversion, lookAt, roundtrip conversion.

@LyeZinho LyeZinho linked an issue May 8, 2026 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3D Math Extension

1 participant