Python 计算坐标点沿角度下降后的新位置
import math
def move(x, y, step, angle=0): angle = math.radians(angle) # 将角度转化为弧度 nx = x + step * math.cos(angle) ny = y - step * math.sin(angle) # 注意这里是减去步长,因为是下降 return nx, ny
new_x, new_y = move(10, 20, 2, 60) print('新的坐标点为:({0}, {1})'.format(new_x, new_y))
原文地址: https://www.cveoy.top/t/topic/nZQv 著作权归作者所有。请勿转载和采集!