No tan/atan/atan2 functions in Mathf class?

The Mathf class has sin, cos, asin and acos methods but doesn’t appear to have tan, atan or atan2. Have they been left out deliberately or is this just an oversight? I know you can synthesise them using the other functions and a bit of arithmetic but they are convenient (atan2 is especially useful for converting a position to an angle).

Or maybe they are in another class and I can’t find them?

It is an oversight. Will be fixed with 1.1.

You can use the System.Math.Atan2 for now.

1 Like

Here’s the doc on that, if you’re interested:

http://dotgnu.org/pnetlib-doc/System/Math.html

Note that most of these are double precision math functions. What that means to you is that you’ll have to explicitly typecast back to float… at least in C#

so at least in C#,

using System;
float myValue = (float)Math.Atan2(0.4, 0.5);

-Jon

… and here’s how you would do it from js:

import System;

myValue = Math.Atan2(0.4, 0.5);

… note: no type casting and generally no worrying about types at all. :wink: