Skip to content

Commit eb409fc

Browse files
rocketmarkclaude
authored andcommitted
fix quattomatrix33 row/column-major mismatch
quattomatrix33 outputs column-major (comment says "opengl major") but quatfrommatrix33 reads row-major, and the 4x4 quattomatrix also outputs row-major. This means a quat->matrix33->quat roundtrip produces the conjugate (inverse rotation) instead of the original quaternion. Fix by swapping the three off-diagonal pairs so quattomatrix33 outputs row-major, consistent with the rest of the codebase. The only runtime caller is barycentric_svd.c which passes the result to cn_copy_in_row_major() — previously loading the transpose, now correct. This doesn't affect tracking results because it only needs an arbitrary valid rotation for control point initialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 477688f commit eb409fc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

redist/linmath.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,17 +546,17 @@ inline void quattomatrix33(FLT *matrix33, const LinmathQuat qin) {
546546
FLT zz = 2 * q[3] * q[3];
547547
FLT zw = 2 * q[3] * q[0];
548548

549-
// opengl major
549+
// row-major (matches quattomatrix 4x4 and quatfrommatrix33)
550550
matrix33[0] = 1 - yy - zz;
551-
matrix33[1] = xy + zw;
552-
matrix33[2] = xz - yw;
551+
matrix33[1] = xy - zw;
552+
matrix33[2] = xz + yw;
553553

554-
matrix33[3] = xy - zw;
554+
matrix33[3] = xy + zw;
555555
matrix33[4] = 1 - xx - zz;
556-
matrix33[5] = yz + xw;
556+
matrix33[5] = yz - xw;
557557

558-
matrix33[6] = xz + yw;
559-
matrix33[7] = yz - xw;
558+
matrix33[6] = xz - yw;
559+
matrix33[7] = yz + xw;
560560
matrix33[8] = 1 - xx - yy;
561561
}
562562

0 commit comments

Comments
 (0)