math - 在度数上找到一个圆点?

标签 math geometry

假设我们有一个100x100的坐标系,如下图所示。 0,0是它的左上角,50,50是它的中心点,100,100是它的右下角,依此类推。

现在我们需要从中心向外画一条线。我们知道线的角度,但是需要计算其终点的坐标。 您认为什么是最好的方法?

例如,如果线的角度为45度,则其终点坐标大约为75,15。

最佳答案

您需要使用三角函数sincos

像这样的东西:

theta = 45
// theta = pi * theta / 180      // convert to radians.
radius = 50
centerX = 50
centerY = 50
p.x = centerX + radius * cos(theta)
p.y = centerY - radius * sin(theta)

请记住,大多数实现假定您正在使用弧度,并且y指向正数。

关于math - 在度数上找到一个圆点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6279999/

相关文章:

java - vector 数学中的大 float

python - 快速体素遍历 2D

math - 3d 成像 : defining an ellipsoid based on 3 given ellipses which are parallel to the Cartesian planes

algorithm - 凸包由最大组成。 n 点

javascript - Bresenham 同心圆留下空像素

javascript - 返回优化的 x 坐标以标准化/最大化具有定义的 y 位置的矩形数组的区域

linux - bash 脚本的算术错误

python - 如何用 Numpy 和 Matplotlib 散点图绘制两个同心圆

javascript - 从 GPS 坐标显示当前速度

c - tri tiling的解释和时间/空间复杂度