python中怎么输入角度_在Python中更正两点之间的角度
我有一個(gè)Python代碼應(yīng)用程序,它記錄鼠標(biāo)活動(dòng)(按規(guī)則間隔記錄的點(diǎn),時(shí)間等待),然后處理數(shù)據(jù)以輸出鼠標(biāo)移動(dòng)的角度(Y軸為0)和它移動(dòng)的速度。
目前我的輸出是東0度,南-90度,西180度,北90度,這不是我的預(yù)期輸出。我不確定三角法或其他計(jì)算中是否有問(wèn)題,所以希望對(duì)這方面的任何幫助。
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
再次感謝您的幫助,特別是關(guān)于我的角度被關(guān)閉。謝謝。
總結(jié)
以上是生活随笔為你收集整理的python中怎么输入角度_在Python中更正两点之间的角度的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何查看无线网卡型号_如何检查笔记本电脑
- 下一篇: python金字塔图绘制_如何用R或Py