Debug Rolling

This commit is contained in:
2026-07-08 19:49:44 +10:00
parent d26628d20b
commit 9b181f7674
+8 -11
View File
@@ -69,17 +69,15 @@ function centredCorners(m, w, h) {
} }
// Build the marker->camera matrix (POS-IT), converting js-aruco axes to three.js. // Build the marker->camera matrix (POS-IT), converting js-aruco axes to three.js.
// POS-IT frame is right-handed (X right, Y up, Z toward viewer). To bring the // js-aruco POS-IT gives the marker pose in a camera frame with X right, Y up,
// full RIGID transform into three.js we must CONJUGATE by F = diag(1,-1,-1): // Z toward viewer. Three.js's camera looks down -Z with Y up, so we convert by
// M_three = F * M_pose * F // premultiplying F = diag(1,-1,-1) (flip Y and Z). This is the SAME conversion
// Premultiplying by F alone flips the translation but leaves the rotation's // the working ar-head.js uses, and it is correct for pitch AND roll: tilting the
// pitch inverted -> "camera up/down moves the ghost the wrong way". The second // phone up moves an anchored ghost down-screen, and rolling the phone rotates the
// (right) multiply by F fixes the rotation handedness while keeping translation // ghost the same way. (An earlier F*M*F "fix" inverted both — don't reintroduce it.)
// correct (F*M*F's translation column is F*t, i.e. flipped exactly once).
const flipYZ = new THREE.Matrix4().makeScale(1, -1, -1); const flipYZ = new THREE.Matrix4().makeScale(1, -1, -1);
// Convert one POS-IT (R,t) solution into a three.js marker->camera matrix via // Convert one POS-IT (R,t) solution into a three.js marker->camera matrix.
// the F*M*F conjugation (see note above).
function poseToMatrix(R, t) { function poseToMatrix(R, t) {
const M = new THREE.Matrix4().set( const M = new THREE.Matrix4().set(
R[0][0], R[0][1], R[0][2], t[0], R[0][0], R[0][1], R[0][2], t[0],
@@ -87,8 +85,7 @@ function poseToMatrix(R, t) {
R[2][0], R[2][1], R[2][2], t[2], R[2][0], R[2][1], R[2][2], t[2],
0, 0, 0, 1 0, 0, 0, 1
); );
M.premultiply(flipYZ); // F * M M.premultiply(flipYZ); // F * M (flip Y & Z: POS-IT frame -> three.js frame)
M.multiply(flipYZ); // F * M * F
return M; return M;
} }