question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: methods for converting between different precisions

See original GitHub issue

There 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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
httpdigestcommented, Nov 15, 2019

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. 😃

1reaction
lukehutchcommented, Nov 15, 2019

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 to AngleAxis, 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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 5. Conversions and Promotions
Casting conversion (§5.5) converts the type of an expression to a type explicitly specified by a cast operator (§15.16). It is more inclusive...
Read more >
How To: Manage Problem Behaviors: Precision Requests
The precision request structures communication with the student in a concise, predictable, respectful format that preserves adult authority and increases the ...
Read more >
Casting and type conversions - C# Programming Guide
Learn about casting and type conversions, such as implicit, explicit (casts), and user-defined conversions.
Read more >
HTTP request methods - MDN Web Docs
Chrome Edge CONNECT Full support. ChromeYes. Toggle history Full support. Edge12. Toggle history DELETE Full support. ChromeYes. Toggle history Full support. Edge12. Toggle history GET Full...
Read more >
How To Convert Data Types in Go - DigitalOcean
Converting between different sizes of numeric types can help ... you may want to convert the integer to a float to preserve the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found