Date: Wed, 26 Mar 1997 09:55:55 -0300 Message-Id: <1.5.4.16.19970326095019.2a479348@dce03.ipt.br> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: DBerry1 AT dca DOT gov DOT au, djgpp AT delorie DOT com From: Cesar Scarpini Rabak Subject: Re: Newbie troubles with Sin and Cos At , DBerry1 AT dca DOT gov DOT au wrote: >G'day > >I've just started playing around with DJGPP and have come across the >following problem. > >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. > >for instance here's the output from a simple prog I did to test my idea > >Sin of 0 is 0.000000 >Sin of 1 is 0.841471 >Sin of 2 is 0.909297 >Sin of 3 is 0.141120 >Sin of 4 is -0.756802 > The arguments for the trig functions (btw in almost any prog language) are in _radians_ and not degrees. >But using a calculator I get > >Sin of 0 is 0 >Sin of 1 is 0.017452 >Sin of 2 is 0.034899 >Sin of 3 is 0.052335 >Sin of 4 is 0.069756 > Switch you calc to radians and you'll get similar results. >Here's the simple prog... > >#include >#include >#include > >float result = 0.0; >int theta = 0; > >main () >{ >while (theta < 360) >{ >result = sin(theta); >printf ("Sin of %i is %f\n",theta,result); >theta++; >} >return 0; >} > To use degrees instead of radians you'll need to convert be it via a macro or a funtion (for a lot of cases) or do calculation up to the calling of the trig function. >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 ? > >Thanks >dberry AT dca DOT gov DOT au > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cesar Scarpini Rabak E-mail: csrabak AT ipt DOT br DME/ASC Phone: 55-11-268-3522 Ext.350 IPT - Instituto de Pesquisas Tecnologicas Fax: 55-11-268-5996 Av. Prof. Almeida Prado, 532. Sao Paulo - SP 05508-901 BRAZIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~