[OZAPRS] Math Question
Kevin Dawson
kevind at esi.com.au
Fri Oct 14 10:49:34 EST 2005
On Fri, Oct 14, 2005 at 08:57:07AM +1000, Darryl Smith wrote:
>
> I am doing some simple coding... I need to work out if two compass
headings
> are within 30 degrees of each other. Simple, eh?
>
> The issue is what happens if one is at 350 degrees and the other is at
10
> degrees?
Without actually testing it to see if it works, this comes to mind:
--------------------------
/* All angles in degrees */
int
nearby(int heading1, int heading2, int range)
{
int diff;
diff = abs(heading1 - heading2);
return (diff <= range || diff >= 360 - range);
}
--------------------------
Or did you want it in APL? :-)
Kevin
_______________________________________________
Ozaprs mailing list
Ozaprs at aprs.net.au
http://aprs.net.au/mailman/listinfo/ozaprs
More information about the Ozaprs
mailing list