Remove old check_move code

This commit is contained in:
Ian Jauslin 2021-09-27 21:21:34 -04:00
parent 78f1c40757
commit bbdbf3bef9

49
main.py
View File

@ -85,54 +85,7 @@ class Cross_painter(Widget):
for other in self.crosses:
# do not compare a cross to itself
if other!=cross:
## find nearest points
#nearest1=(
#newpos[0]-other.size*1.5*sgn(newpos[0]-other.pos[0]),
#newpos[1]-other.size*0.5*sgn(newpos[1]-other.pos[1])
#)
#nearest2=(
#newpos[0]-other.size*0.5*sgn(newpos[0]-other.pos[0]),
#newpos[1]-other.size*1.5*sgn(newpos[1]-other.pos[1])
#)
#dist1_x=abs(nearest1[0]-other.pos[0])/cross.size
#dist1_y=abs(nearest1[1]-other.pos[1])/cross.size
#dist2_x=abs(nearest2[0]-other.pos[0])/cross.size
#dist2_y=abs(nearest2[1]-other.pos[1])/cross.size
#if dist1_x>dist1_y and dist1_x<1.5:
# if dist1_y<0.5:
# print(1)
# return self.check_move((other.pos[0]+3*sgn(newpos[0]-other.pos[0])*cross.size,newpos[1]),cross)
# elif dist1_y<1.5:
# print(2)
# return self.check_move((other.pos[0]+2*sgn(newpos[0]-other.pos[0])*cross.size,other.pos[1]+sgn(newpos[1]-other.pos[1])*cross.size),cross)
#elif dist2_x>dist2_y and dist2_x<1.5:
# if dist2_y<0.5:
# print(3)
# return self.check_move((newpos[0],other.pos[1]+2*sgn(newpos[1]-other.pos[1])*cross.size),cross)
#elif dist1_y>dist1_x and dist1_y<1.5:
# if dist1_x<0.5:
# print(4)
# return self.check_move((newpos[0],other.pos[1]+2*sgn(newpos[1]-other.pos[1])*cross.size),cross)
#elif dist2_y>dist2_x and dist2_y<1.5:
# if dist2_x<0.5:
# print(5)
# return self.check_move((newpos[0],other.pos[1]+3*sgn(newpos[1]-other.pos[1])*cross.size),cross)
# elif dist2_x<1.5:
# print(6)
# return self.check_move((other.pos[0]+sgn(newpos[0]-other.pos[0])*cross.size,other.pos[1]+2*sgn(newpos[1]-other.pos[1])*cross.size),cross)
if self.check_interaction(newpos,other)==False:
if math.sqrt((newpos[1]-cross.pos[1])**2+(newpos[0]-cross.pos[0])**2) > cross.size:
# angle between newpos and cross
theta=math.atan2(newpos[1]-cross.pos[1],newpos[0]-cross.pos[0])
# distance between new position and other
R=cross_polar(theta)
print(R,theta,R*math.cos(theta),R*math.sin(theta))
return (other.pos[0]-cross.size*R*math.cos(theta),other.pos[1]-cross.size*R*math.sin(theta))
return self.check_move((other.pos[0]-cross.size*R*(newpos[0]-cross.pos[0]),other.pos[1]-cross.size*R*(newpos[1]-cross.pos[1])),cross)
else:
return cross.pos
return newpos
return newpos
# check that a cross can be added at position