>>> import math
>>> def move(x,y,step,angle):
nx=x+step*math.cos(angle)
ny=y+step*math.sin(angle)
print(nx,ny)
>>> move(100,100,60,math.pi/6)
151.96152422706632 130.0
不设置angle=0的话默认往右边100+60*sin30=130,文章里设置了就是100-60*sin30=70
Sign in to make a reply
噗安潘
>>> import math
>>> def move(x,y,step,angle):
nx=x+step*math.cos(angle)
ny=y+step*math.sin(angle)
print(nx,ny)
>>> move(100,100,60,math.pi/6)
151.96152422706632 130.0
不设置angle=0的话默认往右边100+60*sin30=130,文章里设置了就是100-60*sin30=70