Skip to content

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

Merged
LyeZinho merged 2 commits intomainfrom
36-3d-math-extension
May 10, 2026
Merged

feat(math): 3D Math Extension — Quaternion (RF5.1)#67
LyeZinho merged 2 commits 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
@LyeZinho LyeZinho self-assigned this May 10, 2026
@LyeZinho LyeZinho added enhancement New feature or request planned-implementation Implementations planned according with roadmap labels May 10, 2026
@LyeZinho LyeZinho added this to the phase 5 milestone May 10, 2026
…ator assertions, CF_ASSERT signal handling

- Fix Quat::toEuler() pitch/yaw swap (ZYX extraction formulas were inverted)
- Replace .epsilon(0.001f) with .margin(0.001f) for FP comparisons near zero
- Fix PoolAllocator stress test: correct freeSlots() expectations based on maxSlots
- Fix CF_ASSERT debug test: use sigsetjmp/siglongjmp to catch SIGILL instead of try/catch
- Add mathematical documentation with formulas to all Quat functions
- Add FailureSummaryListener to test output
@LyeZinho LyeZinho merged commit 4209091 into main May 10, 2026
1 check passed
@LyeZinho LyeZinho deleted the 36-3d-math-extension branch May 10, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request planned-implementation Implementations planned according with roadmap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3D Math Extension

1 participant