Determine 180 degree turn using compass

Peter M. Brigham, MD pmbrig at gmail.com
Mon Jan 16 09:20:34 EST 2012


... or just:
   if tDegrees < 0 then put (360 + tDegrees) into tDegrees
or, with no conditional at all:
   put (360 + tDegrees) wrap 360 into tDegrees
-- works for all values, positive or negative

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Jan 16, 2012, at 12:00 AM, Ken Ray wrote:

> 
> On Jan 15, 2012, at 10:59 PM, Ken Ray wrote:
> 
>>> And if the starting point is say 10 and I turn left 170 degrees and now I am at 200 and 10 - 200 is -190 but I have not really turned -190 but only 170 and again this may be incorrect based on when the sample interval was fired.
>> 
>> Actually -190 *is* 170, if you approach it as "if the number is negative, then subtract abs(it) from 360":
>> 
>>  if tDegrees < 0 then put (360 - tDegrees) into tDegrees
> 
> Whoops! I meant:
> 
>    if tDegrees < 0 then put (360 - abs(tDegrees)) into tDegrees
> 
> Sorry about that…
> 
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/	
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list