feat: quaternion operations, and transforms that mean the same in 4x4 and 4x3

- A 4-vector doubles as a unit quaternion in (x, y, z, w) order:
  QuanternionMultiply, QuanternionConjugate, QuanternionFromAxisAngle,
  QuanternionFromUnitVectors (shortest arc), QuanternionNlerp and
  QuanternionSlerp, next to the existing QuanternionFromBasis.
- MatrixRowMajor gains Rotation (from a quaternion), TRS, InverseAffine,
  Transpose and Decompose. The 4x4 transforms row vectors and the 4x3
  column vectors (the VkTransformMatrixKHR layout); each of these means the
  same transform in both. The 4x3 Rotation copied the 4x4's rows, which
  rotated by the inverse.
- The static Normalize no longer assumes three components.
- Tests: Quaternion, and Matrix extended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-20 19:06:47 +02:00
commit 087c8b32c3
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
6 changed files with 533 additions and 8 deletions

View file

@ -58,7 +58,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
const bool isX86 = target.starts_with("x86_64") || target.starts_with("i686");
const bool isRiscv = target.starts_with("riscv");
const bool isArm = target.starts_with("aarch64");
for (std::string_view name : { "Vector", "Intersection", "Matrix" }) {
for (std::string_view name : { "Vector", "Intersection", "Matrix", "Quaternion" }) {
if (isX86) cfg.AddMarchVariants(name, mathInterfaces, x86Tiers);
if (isRiscv) cfg.AddMarchVariants(name, mathInterfaces, riscvTiers);
if (isArm) cfg.AddMarchVariants(name, mathInterfaces, armTiers);