Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a function in C language to calculate degrees/radians?

Tags:

c

I need to calculate an angle in C programm. Here is a method from JAVA that I need to convert to C.

private static double calculateDirection(double x, double y) {     return Math.toDegrees(Math.atan2(y, x)); } 

Is there a function like toDegrees in C language so I don't have to write all the code by myself? Thank you

like image 569
Antun Tun Avatar asked Feb 17 '13 11:02

Antun Tun


People also ask

Which function is used to convert radians degree?

The formula used is: Radians = (Degrees × π)/180°. Radians = (60° × π)/180° = π/3. Hence, 60 degrees converted to radians is π/3.

Is C in radians or degrees?

The C language uses radians instead of degrees when calculating angles. Humans should use radians as well, as they're logical and easy to work with (radians, not humans).

How do you calculate degrees to radians?

How do we convert degrees to radians? To convert the value of the angle in degree, to its equivalent radians, we need to multiply the given value with π/180. For example, the value of 180 degrees is π in radians.


1 Answers

#include <math.h>  inline double to_degrees(double radians) {     return radians * (180.0 / M_PI); } 
like image 200
Emanuele Paolini Avatar answered Sep 19 '22 21:09

Emanuele Paolini