Advertisement

Inverse Tan?

Started by March 10, 2002 01:15 PM
3 comments, last by Fundy Glostna 22 years, 11 months ago
MY PROBLEM IN A NUTSHELL: Does any one know how to find the inverse tan, in radians or degrees? (I can convert between the two) IF YOU NEED COMPLEX DETAIL: I have an object that''s supposed to move at an angle above the EAST axis. I have the change in ''y'' distance and change in ''x'' distance of the movement, so I can easily get the tan ratio of theta angle as y/x, but I need to convert this to degrees so I can find the resultant velocity''s components (the x and y velocities): y = magnitude*sin(theta) x = magnitude*cos(theta)
No, Canadians DON'T all live in igloos. They live in one BIG igloo!
Assuming you''re using C/C++: look up the atan and atan2 functions.

Advertisement
Okay, it says atan2() calculates the arctangent of y/x; is this the angle in radians?
No, Canadians DON'T all live in igloos. They live in one BIG igloo!
The ANSI C trig. functions only use radians. So, in short: yes .

The Ansi C function
double atan(double m)
takes the gradient m of a line and returns an angle between (-PI/2,+PI/2). It is not particularly well behaved near the boundaries.

The Ansi C function
double atan2(double y, double x)
takes the values of the orthogonal displacements x and y and returns an angle between (-PI,PI]. It is well behaved near -PI/2 and PI/2.

These functions are implemented in this form in many maths packages for other languages.

Regards,

Timkin

This topic is closed to new replies.

Advertisement