Hey, yeah, its not panda3d specific at all, but I found that I ended up using this kind of comparison alot to clip my floats when doing manual movement/camera calculations. Anyway, hope someone finds it useful like I do.
Ex.: compare 1.0 to 1.2 but allow 1.0 to be greater or lesser than 1.2 by 0.2 and still be considered equal. In this case they are considered equal.
#
# Util.py
#
# Author: mss
#
#
# determines if a is near b by the amount of c
#
# useful for floats when you want to compare them.
#
def near(a, b, c):
d = a - b
if abs(d) <= abs(c):
return True
else:
return False
(If there is something like this already in python, let me know and I will just remove this post…)