RTCQuater...mposition(3)

πŸ’– RTCQuaternionDecomposition β€” a whole vibe (section 3, bestie) πŸ’–

okay so bestie, welcome to the Embree Ray Tracing Kernels 4 manual, section 3. today we're talking about RTCQuaternionDecomposition, and ngl it's giving ✨math girlie✨ but I promise it's not that deep. sit with me 🫢


🌸 NAME 🌸

RTCQuaternionDecomposition β€” a struct that represents a quaternion decomposition of an affine transformation. no cap, that's literally the whole thing πŸ’…


✨ SYNOPSIS ✨

struct RTCQuaternionDecomposition
{
  float scale_x, scale_y, scale_z;
  float skew_xy, skew_xz, skew_yz;
  float shift_x, shift_y, shift_z;
  float quaternion_r, quaternion_i, quaternion_j, quaternion_k;
  float translation_x, translation_y, translation_z;
};

like. look at her. fifteen floats living their best lives. she's iconic, she's organized, she's the blueprint πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so struct RTCQuaternionDecomposition represents an affine transformation that's been decomposed into three parts. three! like a lil trio. main character energy fr fr πŸ‘‘

part one is an upper triangular scaling/skew/shift matrix, and she looks like this:

$$ S = \left( \begin{array}{cccc} scale_x & skew_{xy} & skew_{xz}
& shift_x \\ 0 & scale_y & skew_{yz} & shift_y \\ 0 & 0 & scale_z
& shift_z \\ 0 & 0 & 0 & 1 \\ \end{array} \right), $$

part two is a translation matrix, and she's giving:

$$ T = \left( \begin{array}{cccc} 1 & 0 & 0 & translation_x \\ 0
& 1 & 0 & translation_y \\ 0 & 0 & 1 & translation_z \\ 0 & 0 & 0
& 1 \\ \end{array} \right), $$

part three is a rotation matrix R, but she's represented as a quaternion:

quaternion~r~ + quaternion~i~ i + quaternion~j~ i + quaternion~k~ k

where i, j, k are the imaginary quaternion units. (iykyk 🧚) and listen β€” the quaternion you pass in? it gets normalized internally. so don't stress about it, she handles herself πŸ’…

so the affine transformation matrix corresponding to a RTCQuaternionDecomposition is TRS, and a point

p = (p~x~, p~y~, p~z~, 1)^T^

will be transformed as:

pβ€² = T R S p.

periodt. that's the whole transformation. slay πŸ’–

now, setting all those fields by hand is lowkey a lot, so these functions exist to make it convenient:

  • rtcInitQuaternionDecomposition
  • rtcQuaternionDecompositionSetQuaternion
  • rtcQuaternionDecompositionSetScale
  • rtcQuaternionDecompositionSetSkew
  • rtcQuaternionDecompositionSetShift
  • rtcQuaternionDecompositionSetTranslation

they let you set the fields of the structure more conveniently. use them bestie, your future self will thank you 🫢


πŸ’€ EXIT STATUS πŸ’€

no error code is set by this function. that's it. that's the tea. nothing to report, everything's chill 😌


🌈 SEE ALSO 🌈

  • rtcSetGeometryTransformQuaternion
  • rtcInitQuaternionDecomposition

okay that's the whole page bestie, go forth and decompose those transformations βœ¨πŸ¦‹πŸŒΈ

signing off from the RTCQuater...mposition(3) footer β€” brought to you by Embree Ray Tracing Kernels 4 πŸ’– mwah, stay iconic πŸ’…

πŸ“¦ where this page comes from