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
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
>
> > -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
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
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
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;
[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
> 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
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://
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
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
11 matches
Mail list logo