Re: RE: [PHP] convert degrees to heading

2004-09-15 Thread Dave Restall - System Administrator,,,
Hi Trevor, Very nice solution, Dave. I like simple, elegant and effective solutions like this. I was wracking my brain yesterday to come up with something like this, but my brain wasn't working. Hah. Good job! Thanks for the compliments - my head is now a bit bigger :-) I thought 0

Re: [PHP] convert degrees to heading

2004-09-14 Thread Dave Restall - System Administrator,,,
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

Re: [PHP] convert degrees to heading

2004-09-14 Thread Dave Restall - System Administrator,,,
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

RE: [PHP] convert degrees to heading

2004-09-14 Thread Ford, Mike
: John Holmes [mailto:[EMAIL PROTECTED] Sent: Monday, September 13, 2004 3:26 PM To: Gryffyn, Trevor; php Cc: René Fournier Subject: Re: [PHP] convert degrees to heading I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90

RE: [PHP] convert degrees to heading

2004-09-14 Thread Gryffyn, Trevor
Message- From: Dave Restall - System Administrator,,, [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 4:14 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Gryffyn, Trevor Subject: Re: [PHP] convert degrees to heading Hi, Alternatively, try :- $Compass = array('West

RE: [PHP] convert degrees to heading

2004-09-13 Thread Gryffyn, Trevor
The cleanest looking multiple if scenario is to use a Switch statement. Unfortunately I don't believe PHP's switch will do varied conditions, only equality statements: $j = 5; switch ($j) { case 6: echo first; break; case 6: echo second; break; case 5: echo third;

Re: [PHP] convert degrees to heading

2004-09-13 Thread John Holmes
I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90 = North. E.g.: Something like this... it'll account for 360 degrees, too. No different that a bunch of IF statements, though... ?php $dir = 378; switch($dir = $dir%360) { case 0 =

RE: [PHP] convert degrees to heading

2004-09-13 Thread Gryffyn, Trevor
, September 13, 2004 3:26 PM To: Gryffyn, Trevor; php Cc: René Fournier Subject: Re: [PHP] convert degrees to heading I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90 = North. E.g.: Something like this... it'll account for 360

RE: [PHP] convert degrees to heading

2004-09-13 Thread Jay Blanchard
[snip] The cleanest looking multiple if scenario is to use a Switch statement. Unfortunately I don't believe PHP's switch will do varied conditions, only equality statements: $j = 5; switch ($j) { case 6: echo first; break; case 6: echo second; break; case 5: echo

Re: [PHP] convert degrees to heading

2004-09-13 Thread Jason Wong
On Tuesday 14 September 2004 02:18, Gryffyn, Trevor wrote: In some other languages, you could put your range of values in the case statements, but not PHP I guess. switch(true) { case (expr1) : //do something; break; case (expr2) : //do something else;