Skip to content

Revert rotation order and document.#1514

Merged
elalish merged 2 commits into
elalish:masterfrom
tonious:spin_me_right_round
Feb 11, 2026
Merged

Revert rotation order and document.#1514
elalish merged 2 commits into
elalish:masterfrom
tonious:spin_me_right_round

Conversation

@tonious

@tonious tonious commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes changes made in #1505, and clarifies rotation order. Also, adds tests to ensure manifold rotation matches GLTFNode rotation.

Mentioned in #1507.

@codecov

codecov Bot commented Jan 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.41%. Comparing base (7475591) to head (71ff926).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1514   +/-   ##
=======================================
  Coverage   92.41%   92.41%           
=======================================
  Files          35       35           
  Lines        6024     6024           
=======================================
  Hits         5567     5567           
  Misses        457      457           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@elalish elalish left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - guess I reviewed that last one a little too quickly.

Comment thread bindings/wasm/lib/gltf-node.test.ts Outdated
const vCloseTo = (a: Vec3, b: Vec3, margin = 1): boolean =>
vdiff(a, b) <= margin;
const vContains = (haystack: Array<Vec3>, needle: Vec3): boolean =>
!!haystack.find(x => vCloseTo(needle, x));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I've seen this code before - is this fodder for a shared helper function somewhere?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Put the distance function in lib/math.ts, and the more test specific stuff in test/util.ts.

Comment thread bindings/wasm/lib/import-model.test.ts Outdated
// Some quick vector math to check our results.
const vdiff = (a: Vec3, b: Vec3): number =>
Math.sqrt(a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2;
Math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. Much as I enjoy JS, the utter lack of a decent vector library is annoying.

* Additionally, more efficient code paths are used to update the manifold
* when the transforms only rotate by multiples of 90 degrees. This operation
* can be chained. Transforms are combined and applied lazily.
* Applies an Euler or Tait-Bryan angle rotation to the manifold. This

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who are Tait and Bryan? I've only ever heard these called Euler angles.

const layFlat = new GLTFNode();
layFlat.rotation =
[0, 90-(Math.atan(1 / Math.sqrt(2)) * 180 / Math.PI), 135];
[45, -(Math.atan(1 / Math.sqrt(2)) * 180 / Math.PI), 120];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so this is back to how it was originally?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, yeah it is. 😭

* Rotations are applied in `XYZ` order.
* That is roll first, then pitch and finally yaw.
* From the reference frame of the model being rotated, rotations are applied
* in *z-y'-x"* order. That is yaw first, then pitch and finally roll.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow this. I agree it's global X,Y,Z (following OpenSCAD's convention), but I don't see how that relates to roll, pitch, and yaw. Those are defined when rotating by the transformed axes, rather than the global axes.

@tonious tonious force-pushed the spin_me_right_round branch from f2a6de9 to b3d5d2f Compare February 10, 2026 15:04
@elalish elalish merged commit 0bfc0d6 into elalish:master Feb 11, 2026
36 checks passed
@tonious

tonious commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator Author

Oh awesome. I was gonna back out a little more of the documentation stuff -- Going back over it, I must have gotten a little over-excited. There's a lot of potential for ambiguity in how this stuff is described.

Anyhow, Tait-Bryan angles are a subset of Euler angles where each rotation is about a different axis. E.g.: XYX is an Euler rotation, but not Tait-Bryan. What's cool about Tait-Bryan angles is that the rotation order is reversed going from intrinsic (local yaw, pitch, roll) to extrinsic (global X, Y, Z).

@pca006132 pca006132 mentioned this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants