Request: methods for converting between different precisions
See original GitHub issueThere are a few methods for converting between -f
and -d
types, but the coverage is inconsistent. For example, Quaternionf#setAxisAngle(float, float, float, float)
and Quaternionf#setAxisAngle(double, double, double, double)
both exist, but even though there is a method Quaternionf#set(AxisAngle4d)
and Quaternionf#set(AxisAngle4f)
, and a Quaternionf#set(float, float, float, float)
, there is no Quaternionf#set(double, double, double, double)
.
In general there is no simple way to convert directly from Quaternionf
to Quaterniond
or vice versa, or Vector3f
to Vector3d
or vice versa.
It would also be nice to be able to call Quaterniond#transform(Vector3f)
, since you generally want to keep quaternion math as accurate as possible (-d
), but you may want to save space in storing vertices (-f
). Having to convert from Vector3f
to Vector3d
to transform by a Quaterniond
(or transforming the Quaterniond
to a Quaternionf
) makes the API harder to use. (Probably for Quaterniond#transform(Vector3f)
, the return type should be a Vector3f
, not a Vector3d
, to save on yet another conversion the user would need to perform on return, to get the transformed coordinates back to the same precision type that they’re already working with.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
Thanks for your input! It’s very appreciated. I’ll add method name and parameter (order) consistency to the list of things for JOML 2. 😃
In general I have found it hard to find methods, I have had to just guess at names until I figured out a method existed, or was pretty sure it didn’t. Maybe JOML docs should have a table or graph saying “if you have X and want Y, call this method”, for all combinations. Actually producing that in graph form would help find places where methods were missing, due to broken symmetry.
On my last point a couple of comments ago – I know it’s way too late to change the parameter order for quaternions, or to change
AxisAngle
toAngleAxis
, but if you ever do a JOML 2.0, I strongly recommend making names and parameter orders consistent, and making angle/axis representation parallel quaternion parameter order. (setFromAngleAxis
is another example of naming and parameter order inconsistency, vs.AxisAngle
…) If you have a list of JOML 2.0 ideas, maybe add those things to your list!