Skip to content

Compute sin(acos(qdot)) as sqrt(1 - qdot*qdot), which is faster. #2037

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmlarsen
Copy link

@rmlarsen rmlarsen commented Apr 24, 2025

Notice that despite the subtraction "1-qdot*qdot" there is no significant loss of accuracy here, even for small angles where "qdot" is near 1. This is because our knowledge of the angle from "qdot" (i.e. cos(theta) for some theta) is already limited by the floating point representation error near 1, which is 2^-23 (~1.1e-7) for single and 2^-52 (~2.2e-16) for double precision.

The following program tabulates the relative error of the two formulas, evaluated in single precision, compared to evaluating the original formula in double precision:

https://godbolt.org/z/qrzWcd43c

@rmlarsen rmlarsen requested a review from kmuseth as a code owner April 24, 2025 23:49
Copy link

linux-foundation-easycla bot commented Apr 24, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@rmlarsen
Copy link
Author

Friendly ping.

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.

1 participant