PDA

View Full Version : Using math.h in OpenGL



iNsaNEiVaN
10-02-2001, 11:40 AM
Ok, the opposite and adjacent sides of a right triangle i have drawn are 1. I want to use tan to find one of the angles. It never works. I have tried tana() and tanh() and they dont work either. I know the answer should be 45 degrees, what is wrong?

Tana() sounds like it is what I want. I call tanaf(1.0f) but it always returns 0.76 when it should be 45!

What is wrong?

pleopard
10-02-2001, 12:15 PM
The arc-tangent of 1.0 is 0.76 radians which is 45 degrees.

do this ...

static double R2D = 180.0/3.141592654;
double myAngleInRadians = atanf(1.0);
double myAngleInDegrees = myAngleInRadians*R2D;

The standard match libraries work with angles in radians. Note however that OpenGL works with angles in degrees.

Good luck http://www.opengl.org/discussion_boards/ubb/smile.gif

iNsaNEiVaN
10-02-2001, 01:09 PM
thanks