python中怎么输入角度_在Python中更正两点之间的角度

我有一个Python代码应用程序,它记录鼠标活动(按规则间隔记录的点,时间等待),然后处理数据以输出鼠标移动的角度(Y轴为0)和它移动的速度。

目前我的输出是东0度,南-90度,西180度,北90度,这不是我的预期输出。我不确定三角法或其他计算中是否有问题,所以希望对这方面的任何帮助。

i = 0

angles = []

speeds = []

#positions is an array of coordinates taken 0.1 seconds apart from each other

for point in positions:

if i is not 0:

pointY = 2500 - point[1] #invert position of X and assign variable

deltaX = point[0]-pointXP # difference is current pointX minus PointXPast

deltaY = pointY-pointYP

dist = math.sqrt(deltaX**2 + deltaY**2) #distance is the hypotenuse

if dist is 0: #if the mouse has not moved

continue

speed = dist/timeWait # speed is distance/time

angle = math.degrees(math.atan2(deltaY,deltaX)) #angle using Tan

angles.append(angle)

speeds.append(speed)

pointXP = point[0]

pointYP = pointY

else: #this is only for the first iteration

i = 1

pointXP = point[0]

pointYP = 2500 - point[1]

continue

再次感谢您的帮助,特别是关于我的角度被关闭。谢谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值