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

slerp: investigate accuracy of slerp #1

Open
myfreeer opened this issue Apr 29, 2023 · 2 comments
Open

slerp: investigate accuracy of slerp #1

myfreeer opened this issue Apr 29, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@myfreeer
Copy link
Collaborator

myfreeer commented Apr 29, 2023

The current used impl of slerp uses sinTheta = sqrtf(1.0f - cosTheta * cosTheta); to approximate sine from cosine, accuracy is fine for runtime interpolation, but futher investigation is needed that would the accuracy match the needed of resampling?
Also, how much would this impact the performance?
Code here: https://github.com/recp/cglm/blob/44268d24f93f65d280a20ead64d96035cf91f765/include/cglm/quat.h#L727
Discussion about this on stackoverflow: https://stackoverflow.com/a/2683608

Some third-patry math libs that uses acos + sin:

Some third-party math libs that uses this algorithm:

Some uses other algorithm:

Extra:
Vectorized sin might be used to accelerate the sinf, maybe something like:

@myfreeer myfreeer added the enhancement New feature or request label Apr 29, 2023
myfreeer added a commit that referenced this issue May 1, 2023
@myfreeer
Copy link
Collaborator Author

myfreeer commented May 1, 2023

It shows ~11% slower on wasm, ~10% slower on simd, ~3% less frames.

before:
image

after:
image

@kzhsw
Copy link
Owner

kzhsw commented Jul 21, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants