*** empty log message ***

This commit is contained in:
gregw 2002-10-19 17:26:15 +00:00
parent 3371fb5391
commit f4f250edf2
1 changed files with 33 additions and 2 deletions

View File

@ -362,8 +362,8 @@ def reduceAngle(deg):
Reduces an angle (in degrees) to a value between -180. and 180.
"""
return (math.fmod((deg + 180.0), 360.0) - 180.0)
def shortestDestAngle(src, dest):
def shortestDestAngle2(src, dest):
"""
Returns a version of dest that is numerically closest to src. It is
assumed that src is between -180. and 180.
@ -371,6 +371,37 @@ def shortestDestAngle(src, dest):
"""
return (src + (reduceAngle(dest - src)))
def closestDestAngle2(src, dest):
# The function above didn't seem to do what I wanted. So I hacked
# this one together. I can't really say I understand it. It's more
# from impirical observation... GRW
diff = src - dest
# if the difference is greater that 180 it's shorter to go the other way
if diff > 180:
return dest - 360
# or perhaps the OTHER other way...
elif diff < -180:
return dest + 360
# otherwise just go to the original destination
else:
return dest
def closestDestAngle(src, dest):
# The function above didn't seem to do what I wanted. So I hacked
# this one together. I can't really say I understand it. It's more
# from impirical observation... GRW
diff = src - dest
# if the difference is greater that 180 it's shorter to go the other way
if diff > 180:
return src - (diff - 360)
# or perhaps the OTHER other way...
elif diff < -180:
return src - (360 + diff)
# otherwise just go to the original destination
else:
return dest
def binaryRepr(number, max_length = 32):
# This will only work reliably for relatively small numbers.
# Increase the value of max_length if you think you're going