Re: convert degrees to heading

From: Date: Tue, 14 Sep 2004 08:19:34 +0000
Subject: Re: convert degrees to heading
Groups: php.general 
Request: Send a blank email to php-general+get-196596@lists.php.net to get a copy of this message
Hi, > Alternatively, try :- > > $Compass = array('West', 'North Westerly', 'North', 'North > Easterly', > 'East', 'South Easterly', 'South', > 'South Westerly'); > > print $Compass[round($Degrees / 45)] . "\n"; > > This can be expanded easily by adding 'North North West' etc. at the > relevant points in the array and changing the 45 to 22.5. > > No messy horrible switches :-) Oh and I forgot to mention, it also deals fairly well with weird degrees such as 48.7. Dave php/2004-09-14.2.tx TGryffyn@air-cargo-inc.com, php-general,m5@renefournier.com +----------------------------------------------------------------------------+ | Dave Restall, IIRC Limited, PO Box 46, Skelton, Cleveland, TS12 2GT. | | Tel. 0845 10 80 151 Mob. +44 (0) 7973 831245 Int. +44 (0) 1287 653003 | | email : dave@iirc.net dave@restall.net Web : http://www.iirc.net | +----------------------------------------------------------------------------+ | Azh nazg durbatal^uk, azh nazg gimbatul, Azh nazg thrakatal^uk agh | | burzum ishi krimpatul! | | -- J. R. R. Tolkien | +----------------------------------------------------------------------------+

« previous php.general (#196596) next »