Open Imberflur opened 4 years ago
Hi, thanks for reporting this.
I think we want these methods to clamp the dot product to the [-1; 1] range. We probably don't mind the extra overhead if it prevents broken results.
Another concern with slerp_unclamped is that it doesn't handle the case where the two vectors are not linearly independent.
IIRC I just copied GLM's implementation which is widely used. I do not think they handle what you described properly.
Robustness remains desirable, however, but I do not know what would be the best way to handle the "not linearly independant" case.
For slerping I mentioned the issue with two vectors pointing in the same or opposite directions because I realized while writing that this coincides with the case where the dot product needs to be clamped. If they are pointing in almost the same direction I think returning to
would be the best solution. However, if they are in the opposite direction then we have to choose from an infinite selection of planes to rotate through.
The two affected methods:
Due to floating point error the magnitude of normalized vecs can be slightly over 1.0 so when the two input vecs are near identical it is possible for the dot product to be over 1 (or under -1 if they are opposite). Unfortunately,
acos
returns NaN outside the range [-1, 1]Is it intended for the user to handle this case or should it be handled in these methods?
Another concern with
slerp_unclamped
is that it doesn't handle the case where the two vectors are not linearly independent.