Jump to content
  • Advertisement

Archived

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

LowRad

Simple math question about Sin, Cos, Tan

This topic is 6540 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

Hi, That''s a pretty easy question. I have a triangle, i got the two lenght of the sides, but not the hypotenuse. I try to find the angle. Like this: The formula : tan (ang) = long1 / long2 The answer : ang = tan-1 (long1 / long2) It''s tan at power -1... So i can i code this Line in c/c++ ?! c dont have any tan-1 fnc. Thanks for your help ?! LowRad

Share this post


Link to post
Share on other sites
Advertisement
What you''re looking for for is arctan(), that''s the inverse cosine function, as is arcsin, etc.



ByteMe95::~ByteMe95()

Share this post


Link to post
Share on other sites
I too had the same problem. But it''s easy to solve
use 1/tan(Same with Sin, Cos). It''s the same as tan-1

Share this post


Link to post
Share on other sites
I beg to differ:

cos(90 degrees) = 0
cos-1(0) = 90 degrees
1/cos(90 degrees) = divide by zero error



plus it''s not right non-general rule anyway. Where did you study maths? And don''t claim it works in radians because it doesn''t.

Share this post


Link to post
Share on other sites
Mindwipe, that''s completely wrong, where did you come up with that???

Just use arccos()



ByteMe95::~ByteMe95()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think mindwipe read "tan()-1" as "tan() to the -1 power" which is 1/tan() of course

Share this post


Link to post
Share on other sites
arctan(x) isn't the same as 1/tan(x). arctan(x) means: "the inverse function of tan", it's not the "inverse result of tan(x)".
To find the angle use:

theta = arctan(length_y/length_x);
Result in radians.

Do not invert the sides. length_y is the opposite side, and length_x is the adjacent side.

Edited by - blazter on July 21, 2000 5:43:38 PM

Share this post


Link to post
Share on other sites
Anonymous Poster> Yup that was what I ment. I''ve actally used it. And it works. Well, I no master on math. Due to lack of knowledge.

Just wanted to try to help

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Umm, are we assuming this is a right triangle? Those trig identities only work for a right triangle, don''t they? I''ve almost got an AA in Math on accident ...

Share this post


Link to post
Share on other sites
I don't know what is a right triangle in English. Do you mean that one of the angles must be 90 degrees ?
If so, yes it's right. These trig. functions only work on orthogonal coord. and on right triangles. By the way only a triangle with a angle of 90 degrees can have a hypotenuse.

Edited by - blazter on July 24, 2000 1:20:30 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!