• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Trigonmetry

This topic is 6854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
If your using C++. The function for the inverse of tan is
atan(); To avoid divide by zero errors use atan2(y, x);

##### Share on other sites
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?

##### Share on other sites
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

##### Share on other sites
Thanks You have all been very helpful.

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

Thanks

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015228
×