Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved quaternion application #14075

Merged
merged 1 commit into from
Jul 24, 2023
Merged

Improved quaternion application #14075

merged 1 commit into from
Jul 24, 2023

Conversation

infusion
Copy link
Contributor

I am the author of Quaternion.js ( https://github.com/infusion/Quaternion.js ) and thought it might be useful for a wider audience to benefit from an improvement to rotate vectors using quaternions I've derived here https://raw.org/proof/vector-rotation-using-quaternions/

I discussed this already with the fine folks from Three.js where I also proposed to add this improvement mrdoob/three.js#26456

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 23, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 23, 2023

@RaananW
Copy link
Member

RaananW commented Jul 24, 2023

Looks great, and it does pass the tests. Just wondering - why is it better? is it just the few less multiplications?

@infusion
Copy link
Contributor Author

Thanks :) Yes exactly. It needs less arithmetic operations to compute the same result. Since rotating stuff is the sole purpose of quaternions in the 3D world, this should be as fast as possible.

@EricEisaman
Copy link

Is it possible, at this stage @infusion , to see the benefit in a side by side comparison of two Babylon Playgrounds that push quaternion rotation computations to the limit?

@RaananW
Copy link
Member

RaananW commented Jul 24, 2023

I ran a few manual tests using this simple playground:

https://playground.babylonjs.com/#23GPBX#1
and
https://playground.babylonjs.com/?snapshot=refs/pull/14075/merge#23GPBX#1

I am not seeing any regression. I don't see a big difference in performance, with slight improvement in the new PR. if anyone else wants to test it - would be great :-)

@Popov72
Copy link
Contributor

Popov72 commented Jul 24, 2023

I'm not seeing any measurable difference in the two PGs (javascript optimization can be frustrating...), but the new method is not slower and we say in the comment of the method that the quaternion must be a unit quaternion, so I think we can approve the new calculation?

@sebavan sebavan merged commit cbc43ef into BabylonJS:master Jul 24, 2023
8 checks passed
@RaananW
Copy link
Member

RaananW commented Jul 24, 2023

I am totally fine with that. Merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants