Skip to content

Double precision float threshold value for checking if quat is near identity #242

@dimvoly

Description

@dimvoly

Issue

The single precision default threshold value is float threshold_angle = 0.00284714461F. There is commentary about the logic used to arrive at that value. This assumes an "error threshold" of 1.e-6.

The double precision default threshold value is the same value double threshold_angle = 0.00284714461. The comments reference the single precision case, but no comment is made on the possible differences.

It would seem, that if you follow similar logic for the double precision version, you'll arrive at an "error threshold" of 1.e-15, and thus a threshold_angle of 8.940696716308595e-8. This is just above the presumably smallest detectable angle of

0.99999999999999988897769753748434595763683319091796875.acos() * 2.0_f64 = 2.9802322387695313e-8

Alternatively, if that's too close for comfort, you could use an "error threshold" of 1.e-14 and get a threshold_angle of 2.8272965492323474e-7.

Caveats

The above calculation was done in rust (I don't know cpp), so I'm not sure on what the acos() would actually give me if using the scalar_acos() from this library. Also, mathematically, I'm not too knowledgeable on how these operations came about, I'm merely comparing the logic in the single precision case vs the double precision case. Commenting on this library, as the glam library uses similar logic and references this library.

Summary Question

Should the double precision version follow a tighter threshold? And if so, should it be based on the "error threshold" of 1.e-14, yielding a threshold_angle of 2.8272965492323474e-7?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions