Advertisement

Trigonmetry

Started by April 10, 2000 08:38 AM
3 comments, last by Macke 24 years, 7 months ago
Hello! I''ve got a problem with trigonmetry. I have got to points on the screen like this (points = *) * // / / *--- and I need to know how many degrees the line between the points and the line at the bottom. I don''t know how to do that. I can''t find a function for the inverse of tan(). Thanks!!! Marcus Andersson
If your using C++. The function for the inverse of tan is
atan(); To avoid divide by zero errors use atan2(y, x);
Advertisement
If i understood well, you have two lines and you wish to know what is the angle they produce when they collide.

A simple approach would be to find the angle that both have with the x x'' coord, and then contract the two values.

A
/ C
//
B

Using the f'' you can find that angle (i dunno how they are named in english).

Actually, the hole concept is like this:
Line:
y-y0=L(x-x0)
(where L is the direction of the line)
L=(y-y0)/(x-x0)

To get the degrees you need to solve the expretion

L=tan(w)

Apply this to both lines to get their angle to the x x'' coord. Then subtract these two values to get the angle between ''em.

This is the mathematical concept. If you could explain what you need it for, people might manage to give you better solutions.

ps: What about the Polar system?
... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!...Could this be what we stand like before the mighty One?Are we LeMmIngS or WhAt!? ;)
Harvester: When he said "the line at the bottom", he meant the horizontal x axis. So in all, he wants to find the angle of rotation of a line defined by the two points (one being the origin) and the x-axis. Like Mr_Black said, atan2(y, x); works here.

P.S Theres no point in using the Polar system since you have to convert to polar to find r, and that might take more calculations, when atan2(y, x); is probably much faster.

Edited by - Zipster on 4/10/00 4:08:46 PM
Thanks You have all been very helpful.

I didn''t know that atan() was the name of the inverse of tan()

Thanks

This topic is closed to new replies.

Advertisement