Advertisement

Simple trigonometry problem

Started by March 12, 2003 05:20 AM
14 comments, last by CyberGhost 21 years, 11 months ago
Im trying to calculate the angle of a right angle triangle using the opposite and adjacent which can be done using the following equation in maths. angle = tan(-1) opp/adj that is tan to the power of -1. I cant seem to find such a function for this in C/C++ or DirectX. So how do you go about calculating it. I tried using the following angle = D3DXToDegree(tan(opp/adj)); given that: opp = 10 adj = 10 then angle = 45 however with the above code angle = 89.232887 So where am I going wrong, what function should I be using?
use atan(), eg angle = atan(opp/adj)
Advertisement
quote:
Original post by CyberGhost
angle = tan(-1) opp/adj

that is tan to the power of -1.



nope...it''s the inverse of tan, not tan to the power of -1, which would be cot()
Or you can just write your own inverse tan function for the heck of it ; )

atan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 + .... lol
Did you guys know that tangent to the -1 power is equal to

1/tangent


just a tip
Mecha Engineer (Making Real Humanoid Suits)
Yes.. atan should be used.. it''s short for arctangent which is the alternate name for inverse tangent (inverse tangent, not cotangent).. on many calculators the inverse tangent is represented by a tan-1... 1/tan(x) is the same as cot(x)..
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
Advertisement
use tan(x)-1. This is not the same as 1/tan(x).

Where are you guys getting this information? Why don't you guys try finding the tan of some number and then take the tan^-1 of the result. You get the number you put in the original equation. If tan^-1 was equal to 1/tan then tan*tan^-1 would equal 1 always(except for when is o)... and it doesn't. tan-1 represents the inverse of the function. Not its actually mathamatical shorthand, a common misconseption, which is that F(x)^-1=1/f(x).

1/tan(x) = cot(x)
tan(tan(x)^-1) = x
tan(x)^-1 != cot(x)
tan(x)-1 != 1/tan(x)

to see for yourself:

find tan(pi/3)
it equals sqrt(3)
fins tan(sqrt(3))^-1
it equals pi/3

there is no cot on most calculators because the makers assume that if you know what the tan does, you should also know that cot is just 1/tan(x).

hope this help clear up some confusion.

If people here want me to, i can do a small little graphical proof which would makes things easier to 'see'. I wouldn't mind at all.

Dwiel

[edited by - Tazzel3d on March 16, 2003 1:12:08 AM]
quote:
Original post by Tazzel3D
use tan(x)-1. This is not the same as 1/tan(x).



yeah...and whoever doesn''t know the difference between the inverse of f(x) and 1/f(x), I don''t really know how they passed HS algebra.
You guys still talking about it >(:oP
The function I wanted was infact atan()
But still hasn’t solved my problem for which i was intending to use it.

I don’t know if this is the right place to ask this, but hey I''m going to anyhow.

I’m trying to make a 3D first person game. So far I am generating a terrain using 10x10 grid matrix (X,Z) then for each vertices I randomly generate a height (Y).
My difficulty is moving my camera over the scene maintaining the same height has it passes over hills etc.

My current system is locating which cell your standing in then working which triangle the cameras in (using DirectX so squares consist of 2 triangles). After this I get the 3 relevant vertices and do a bit of trigonometry and calculate new opposites
for the current position. I do this 3 times. One each for the 2 pendicular vertices and another across the 2, to determine if there’s a slope across.

Which on paper works, but in the system does not.

There must be a real easy way to do this sort of thing, someone out there must have previously done it.
If so how?

Thanks in advance.
Anyway whats the differents between inverse n power of -1.
From little I did atend school, I thought da lickle number ment power of. O well.

This topic is closed to new replies.

Advertisement