Mail Archives: djgpp/1997/03/12/23:12:04
In article <857645423 DOT 321128 AT red DOT parallax DOT co DOT uk>, johne AT parallax DOT co DOT uk (John Eccleston) wrote:
>In article <331E6B93 DOT 3B63 AT comports DOT com>, j AT comports DOT com wrote:
>Try the standard C header math.h which defines quite a few trigonometric
>and other functions. Note that the trigonometric functions work on
>radians not degrees!
>
>-----> Cut Here <-----
>#include <stdio.h>
>#include <math.h>
>
>float degreesToRadians(float angle)
>{
> return angle * (PI / 180);
>}
>
>main()
>{
> printf("Sin of 45: %f\n", sin(degreesToRadians(45)));
>}
>-----> CUT HERE <-----
Don't get me wrong, I'm not ragging anyone, nor their code, but from
one fellow programmer to another, why did you choose to not write the above
code as:
#include <stdio.h>
#include <math.h>
#define RAD(deg) ( ( deg ) * ( 2 * M_PI ) / 360.0 )
main()
{
printf("Sin of 45: %f\n", sin(RAD(45)));
}
I am more interested in the observation that some people prefer to do
things the hard way, as opposed to giving simpler examples. This is a
philosophical argument, not a programming one.
PV
______________________________________________________________________________
Paul Peavyhouse
http://www.cs.montana.edu/~pv
email: pv AT cs DOT montana DOT edu
______________________________________________________________________________
- Raw text -