hi, it seems that a lot of unity’s built in functions take degrees as input and do stuff with them. but i believe this involves an extra conversion step, especially where rotation math is concerned. functions that can take radians as input directly would be more effective, no?
i figure by now someone must have rewritten all the degree-input functions into versions that take radians. Anyone got such a code library that i could use? maybe a static class with static functions
if you’re using C#, all of the basic .net Math functions (System.Math.cos() for example) use radians. Other than that, if you’re not afraid of source code, there’s always Math.NET Team · GitHub
You’ll be primarily interested in mathnet-spatial. But if you go down that road, you’ll have to evaluate which is the cheaper conversion? Your code converting Unity Vectors/Matrices to your library’s Vectors/Matrices, or Unity doing the deg2rad conversion?
It’s only really Vector3.Angle, a couple of angular velocity things, and a few Quaternion functions that deal in degrees, and it doesn’t make great sense to be dealing with quats in radians.
All of the Mathf trig functions are in radians
I have a few methods in my VectorUtil that can take radians.
I haven’t gone through and written any radian versions of existing functions. Though I wouldn’t mind doing it.
You will notice though that I default to degrees in my VectorUtil. This is because despite my preferring radians to do math, I display everything as degrees in the editor for the benefit of the designer.
NOTE - the unity methods that take degrees just do an extra multiplication step, and that’s it. The overhead isn’t that intense.
Tell you what though… if you go out and seek down all the functions that take degrees and would benefit from radians, organize it into a list with name, inputs, and output. I’ll write the implementations for them. I have no problem writing the code, I just don’t want to hunt down all the functions.