[英]Calculate coordinates of end point of a line by having the angle and the length
I have the coordinates of the start point of a line and also i have the angle and length of that line and i want to get the coordinates of the endpoint.我有一条线的起点的坐标,也有这条线的角度和长度,我想得到终点的坐标。
I am using the script:我正在使用脚本:
X_B = X_A + (length * round(abs(math.cos(Angle))))
Y_B = Y_A + (length * round(abs(math.sin(Angle))))
But in many cases it doesnt work但在很多情况下它不起作用
Make sure the angle is in radians , not in degrees :确保角度是弧度,而不是度数:
import math
length = 1
Angle = 3.14/3
X_A = 0
Y_A = 0
X_B = X_A + round(length * math.cos(Angle), 3)
Y_B = Y_A + round(length * math.sin(Angle), 3)
print(X_B, Y_B)
Output: Also, don't round sin
or cos
. Output:另外,不要四舍五入
sin
或cos
。 Perform the round on the resulting value.对结果值执行回合。
0.5 0.866
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.