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 deg

RE: [PHP] convert degrees to heading

2004-09-14 Thread Gryffyn, Trevor
o "$degrees degrees is roughly $compdir on the compass\n"; } Yeah, I don't know what "east of northeast" is, so I just labeled it "NEE" :) Great thinking though. You still get the prize on this one. -TG > -----Original Message- > From: Da

RE: [PHP] convert degrees to heading

2004-09-14 Thread Ford, Mike
> > > -Original Message- > > From: 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 > > > > > &g

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

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 W

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;

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

RE: [PHP] convert degrees to heading

2004-09-13 Thread Gryffyn, Trevor
> 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-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... ---John Holmes... -- PHP General Mailing List (http://

RE: [PHP] convert degrees to heading

2004-09-13 Thread Gryffyn, Trevor
In some other languages, you could put your range of values in the "case" statements, but not PHP I guess. I think in this case, you're stuck with a bunch of if/elseif statements. Only 16 of them though, right? :) -TG > -----Original Message----- > From: René Fournier [mai

[PHP] convert degrees to heading

2004-07-16 Thread René Fournier
I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90 = North. E.g.: from: 135 degrees to: NW Now, I was planning to write a series of if statements to evaluate e.g., if ($heading_degrees < 112.5 && $heading_degrees > 67.5) { $headi