PDA

View Full Version : how do I calculate correct angles to an object ?



04-19-2000, 11:11 PM
My problem is,
I`ve got some hemispheres and in order to rotate them correct I need to calculate the x, y and z angle from my viewpoint to the object, so that I`m able to rotate the hemisphere according to these angles. I already know how to get the correct distance and the relative coordinates from viewp. to object, but if I rotate the sphere these angles should change. I know Ive got to use the modelview matrix, but not how.
Thanks...

ribblem
04-20-2000, 11:16 AM
If I understand your problem correctly all that is needed is a little bit of trig. There may be a better way to do what you want but the following way should work.

ASSUMING the camera is at the origin and
x, y, and z are the distance to object in the respective direction

theta.x = arctan(z/y)
theta.y = arctan(z/x)
theta.z = arctan(x/y)

Hope that helps.

Dan
04-20-2000, 02:15 PM
hhmmmm, when i try to use the arctan() function, the compiler cant find it, and i cant find the funtion in any help files, what do i have to include to use that function?

Dan
04-20-2000, 02:16 PM
hhmmmm, when i try to use the arctan() function, the compiler cant find it, and i cant find the funtion in any help files, what do i have to include to use that function?

Gorg
04-20-2000, 04:24 PM
you have to include math.h.

but the syntax is atan. arctan is the french symbol.