Jump to content
  • Advertisement

Archived

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

Macke

Trigonmetry

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

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!