Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigonometry

Status
Not open for further replies.

jvff

Programmer
Apr 1, 2001
64
BR
Hello,
The int sin(int) function isn't working. If I put sin(90) it returns 0. If I put use double cos(double) with cos(90) it returns -0.043. Is there an alternative to the default functions? ThanX,

JVFF

ThanQ, ;-)

JVFF (Janito Vaqueiro Ferreira Filho)
 
I think it assumes radians instead of degrees. A quick fix is to convert to radians before the call.
 
Actually, cos is a function included in math.h, and uses radians, so it would be prototyped with int.

To convert degrees to radians, just multiply degrees by pi, then divide by 180. Or, to save processing time, multiply it by a constant you make called PI180, than holds pi/180

-----------------------
Soon to come - a QBasic contest forum!
-----------------------
 
The prototype is double

For example:

double cos (double x);
// x is the angle in radians

What do you mean:
" Is there an alternative to the default functions?"?

One alternative is sin/cos tables, a sliderule, paper and pencil.

JUST JOKING!!!

In theory, there is no difference between practice and theory.

In practice, there is.
Yogi Berra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top