Hi,
The sin(x) function in math.h expects a number in Radian Measurement as a
parameter. I believe you are giving sin(x) a number in Degree Measurement
instead. So you need to convert your number from Degree Measurement to
Radian Measurement before passing it to sin(x).
Radian Measurement is the idea of measuring in PI. There are 360 Degrees
in a circle, but only 2 * PI (or 6.28) radians in a circle. So 1 radian =
180/PI. To convert from Radian Measurement to Degree Measurement, multiply
the number in Radian Measurement by 180/PI. To convert from Degree
Measurement to Radian Measurement, multiply the number in Degree Measurement
by PI/180.
Therefore, 1 in Degree Measurement is really 1 * PI/180 in Radian
Measurement. So try:
//--Start
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535897932384626433832795
void main()
{
float f=1.0f;
printf("The sine for %f is %f",f,sin(f * PI / 180.0));
}
//--End
For more info, see http://www.cplusplus.com/ref/cmath/sin.html. Or see a
good trig tutorial that includes examples of how the Radian and Degree
measurements work. I Hope this did not thoroughly confuse you and you can
some use of this.
Sincerely,
Brian Becker
Shall we accept good from God, and not trouble?
---
Outgoing mail is certified Virus Free by AVG
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.282 / Virus Database: 150 - Release Date: 9/25/2001
----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97
|