6
To documentation says that the method input should be in radians and you are using degrees. It has to convert radian to degree before. The calculator is already in degrees, so it worked.
using static System.Console;
using static System.Math;
public class Program {
public static void Main() => WriteLine(Atan(5) * 180 / PI);
}
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
Maybe you want to create functions to make the conversion:
public static class MathUtil {
public static double DegreeToRadian(double angle) => PI * angle / 180.0;
public static double RadianToDegree(double angle) => angle * (180.0 / PI);
}
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
Raphael, take a look at the documentation https://msdn.microsoft.com/pt-br/library/system.math.atan(v=vs.110). aspx there shows that the function returns the Angle of the tangent and not the arc, I do not remember well about trigonometry, but I believe they are distinct things. And if you see the example, it has how to calculate the tangent arc.
– Pablo Tondolo de Vargas
@Pablovargas, they’re the same thing, basically. The angle returned is the one referring to the arc in question. The same problem was the disparity of the units, as the bigown replied. Just convert from radian to degrees.
– Woss