def in_cone (a1, a2, d2, radius): # bug madkit ;-) parfois on est DANS l'objet... if d2 <= radius: d2 = radius + 1 delta = Math.asin (radius / d2) + 15 cone_sup = add_angles (a2, delta) cone_inf = add_angles (a2, -delta) rule = angle_in_range (a1, cone_inf, cone_sup) return rule
def in_cone(a1, a2, d2, radius): # bug madkit ;-) parfois on est DANS l'objet... if d2 <= radius: d2 = radius + 1 delta = Math.asin(radius / d2) + 15 cone_sup = add_angles(a2, delta) cone_inf = add_angles(a2, -delta) rule = angle_in_range(a1, cone_inf, cone_sup) return rule
def toBut(self, but): if but.x == 'abs': return but.y a = but.x - self.origin.x b = but.y - self.origin.y if a == 0 and b == 0: return rnd.nextDouble() * 360; if b < 0: return 180*Math.asin(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI+270 else: return 180*Math.acos(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI
def toBut(self, but): if but.x == 'abs': return but.y a = but.x - self.origin.x b = but.y - self.origin.y if a == 0 and b == 0: return rnd.nextDouble() * 360 if b < 0: return 180 * Math.asin( a / Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2))) / Math.PI + 270 else: return 180 * Math.acos( a / Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2))) / Math.PI