Message-Id: <3.0.6.32.19990227021519.0088c6f0@pop.globalserve.net> X-Sender: derbyshire AT pop DOT globalserve DOT net X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Sat, 27 Feb 1999 02:15:19 -0500 To: djgpp AT delorie DOT com From: Paul Derbyshire Subject: Re: sin, cos ?? In-Reply-To: <36D5B053.2AA88FD6@cartsys.com> References: <36d2f284 DOT 0 AT news DOT sbbs DOT se> <199902231842 DOT NAA15055 AT envy DOT delorie DOT com> <7b26kt$g5n AT chronicle DOT concentric DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com At 12:19 PM 2/25/99 -0800, you wrote: >Paradox wrote: >> >> Is there another function that uses degrees? > >No, but you can easily convert between the two. > >#include >#define DEG2RAD(deg) ((deg)*(M_PI/180.0)) >#define RAD2DEG(rad) ((rad)*(180.0/M_PI)) Ack! Macros! const long double pi = 3.141592653589793 template // 'F' as in 'Floating point' inline F deg2rad (F deg) { return deg*pi/180.0; } template inline F rad2deg (F rad) { return 180.0*rad/pi; } There. Nice and type-safe and free of bogons with arguments that have side effects. More readable too, just as inlined and quick, and moreover, if you have egcs you can stick these in your own namespace and keep them from cluttering the global one. -- .*. "Clouds are not spheres, mountains are not cones, coastlines are not -() < circles, and bark is not smooth, nor does lightning travel in a `*' straight line." ------------------------------------------------- -- B. Mandelbrot |http://surf.to/pgd.net _____________________ ____|________ Paul Derbyshire pderbysh AT usa DOT net Programmer & Humanist|ICQ: 10423848|