LowRad 234 Report post Posted July 20, 2000 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 0 Share this post Link to post Share on other sites

ByteMe95 122 Report post Posted July 20, 2000 What you''re looking for for is arctan(), that''s the inverse cosine function, as is arcsin, etc. ByteMe95::~ByteMe95() 0 Share this post Link to post Share on other sites

MindWipe 940 Report post Posted July 21, 2000 I too had the same problem. But it''s easy to solveuse 1/tan(Same with Sin, Cos). It''s the same as tan-1 0 Share this post Link to post Share on other sites

Poontardis 122 Report post Posted July 21, 2000 I beg to differ:cos(90 degrees) = 0cos-1(0) = 90 degrees1/cos(90 degrees) = divide by zero errorplus 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. 0 Share this post Link to post Share on other sites

ByteMe95 122 Report post Posted July 21, 2000 Mindwipe, that''s completely wrong, where did you come up with that???Just use arccos() ByteMe95::~ByteMe95() 0 Share this post Link to post Share on other sites

Guest Anonymous Poster Report post Posted July 21, 2000 I think mindwipe read "tan()-1" as "tan() to the -1 power" which is 1/tan() of course 0 Share this post Link to post Share on other sites

Blazter 122 Report post Posted July 21, 2000 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 0 Share this post Link to post Share on other sites

MindWipe 940 Report post Posted July 22, 2000 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 0 Share this post Link to post Share on other sites

Guest Anonymous Poster Report post Posted July 24, 2000 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 ... 0 Share this post Link to post Share on other sites

Blazter 122 Report post Posted July 24, 2000 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 0 Share this post Link to post Share on other sites

Guest Anonymous Poster Report post Posted July 24, 2000 If you''re in C/C++, use atan2(x,y). It automaticallydeals with special cases like x=0 y=1, whereregular atan(t) causes a divide by 0 error orreturns NaN, inf, or some other floating point code.I''m sure any other language you use will have asimilar function. 0 Share this post Link to post Share on other sites

remo 122 Report post Posted July 24, 2000 interestingly no-one seems to have mentioned that tan^-1 is how arctan is represented in mathematics. 0 Share this post Link to post Share on other sites

jumble 122 Report post Posted July 24, 2000 quote: Original post by remo interestingly no-one seems to have mentioned that tan^-1 is how arctan is represented in mathematics. Lets clear some things up here...tan(x) to the POWER of -1 is 1/tan(x) - which is the same as cotan(x) - in mathematics.tan(x) with -1 superscript in mathematics is the inverse of tan(x). Which is arctan(x) in C++.Now, if you ever need to do stuff with a non-right angled triangle, you can use either the sine rule or cosine rule, dependant on which is more useful. (these both work with right angled triangles too)this is where:a,b, and c are lengths of the sides of the triange.A, B and C are the angles opposite to its corresponding side. Doesnt matter what its measured in (degrees, radians or quadrants (sp?) if you're weird like that) as long as all they're all the same.sine rule:a/sin(A) = b/sin(B) = c/sin(C)cosine rule:a^2 = b^2 + c^2 - 2bc . cos(A)or b^2 = a^2 + c^2 - 2ac . cos(B)or c^2 = a^2 + b^2 - 2ab . cos(C)Of course, all of these can be rearranged to whatever you need it to do. jumble-----------Microsoft patents ones and zeroes - remind you of Hasbro?Edited by - jumble on July 24, 2000 2:45:06 PM 0 Share this post Link to post Share on other sites