www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/25/19:34:40

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199703260011.AA292805089@typhoon.rose.hp.com>
Subject: Re: Newbie troubles with Sin and Cos
To: DBerry1 AT dca DOT gov DOT au
Date: Tue, 25 Mar 1997 16:11:29 PST
Cc: djgpp AT delorie DOT com
In-Reply-To: <0000oqkoqioy.0000nzhphlnh@dca.gov.au>; from "DBerry1@dca.gov.au" at MAR 26, 97 9:38 am

> while (theta < 360)
> {
> result = sin(theta);
> printf ("Sin of %i is %f\n",theta,result);
> theta++;
> }
> return 0;
> }

Your problem is not related to DJGPP.  This code will fail under 
any compiler as the sin and cos routines require radians
(pg 250 of k&r 2nd "Angles for trigonometric funtions are expressed as 
radians."

If memory serves 1 radian = 57.3 degrees and 2Pi Radians = 360.

so 

result = sin ( theta * 2 * M_PI / 57.3  );

should work.

Andrew

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019