Mail Archives: djgpp/1997/03/25/22:13:40
eab AT salnet DOT org wrote:
>
> > I'm trying to write a routine that spins a pixel around in a circle.
> > That works ok so far, except that the X and Y points are never next
> > to each other - I think I have narrowed it down to the results I am
> > getting from using COS and SIN.
>
> [snip]
>
> > result = sin(theta);
> > printf ("Sin of %i is %f\n",theta,result);
>
> [snip]
>
> > Am I using the wrong variable types to hold the results ? Do I need
> > to do something special in DJGPP to get the magic numbers ?
>
> This isn't specific to DJGPP, but applies to most programming
> languages--you need to convert the angle from degrees to radians,
> because that's what the trig functions take. In radians, pi equals
> 180 degrees, so to convert it to radians, you multiply it by 180/PI.
That have to be PI/180 to be correct, no? If You multiply by 180/PI the
angle would be be about 57 times greater instead of 57 times smaller.
(1 radian equals about 57,3 degrees).
> This changes the line from your example to
>
> result = sin(theta*180/PI)
^^^^^^ should be : PI/180
>
> (PI is a predefined value in math.h)
>
> > dberry AT dca DOT gov DOT au
>
> Ethan
> "The world beneath us spins in circles,
> And this life makes us twist and turn and sway,
> But we were made for more than rhythm with no reason
> By the One who moves with passion and with grace
> As He dances over all that He has made."
> --Steven Curtis Chapman
> This message sent via TRI-RIVERS INTERNET, Inc. - Salina, KS. !
- Raw text -