如何计算距离圆周上一点固定弧长的 (x,y)
我在这上面花了很多时间,我能感觉到我的理智正在慢慢下降。因此,任何帮助都将非常感激。 我会尝试尽可能简洁。
我在二维平面上有一个圆。我知道它的中心点(C)和半径(R)的笛卡尔坐标。
我的困惑源于这个问题。当在圆外平面上设有一点时;我可以计算圆的圆周上最接近该点的点(P)。
我想要做的是确定圆周上 2 个点的 (x,y) 坐标。我们称它们为 P1 和 P2。 P1和P2是圆弧的两端。弧具有固定长度(X)。 P是P1和P2之间的中点。这样,从P到P1的弧长& P至P2均为X/2。
简而言之: 给定 C、R、P、X ;我需要计算P1和P2。
我正在尝试用 C++ 编写此代码,但任何建议或伪代码都会很棒。
编辑: X 是弧长,不是 P1 和 P2 之间的直线
I've spent so many hours on this I can feel my sanity slowly slipping. So any help would be really truly appreciated.
I'll try and be as succinct as possible.
I have a circle on a 2D plane. I know the cartesian coordinates for it's central point(C) and the radius(R).
My confusion stems from this problem. When provided with a point on the plane outside of the circle; I can calculate the point(P) on the circle's circumference closest to that point.
What I want to do is determine the (x,y) coordinates of 2 points on the circumference. Let's call them P1 and P2. P1 and P2 are two ends of an arc. The arc is of a fixed length(X). P is the midway point between P1 and P2. As such, the arc length from P to P1 & P to P2 are both X/2.
In short:
given C, R, P, X ; I need to calculate P1 and P2.
I am trying to code this in c++ but any suggestions or pseudo-code would be great.
EDIT:
X is an arc length, not a straight line between P1 and P2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在圆上,角度
theta
对应于theta * R
的弧长,这意味着您的弧将面对theta = X / R
的角度>。 ,如果从你的观点开始,那么只需按
theta/2
向上/向下:因此
On a circle, an angle
theta
corresponds to an arc length oftheta * R
, meaning your arc will subtend an angle oftheta = X / R
. So if start with your pointthen just go up/down by
theta/2
:and
所对角度为 θ(以弧度表示)的弧的弧长为 θR。因此,您需要半角 θ = X/(2R)。然后,您需要获取向量 (P -C),将其旋转 ±θ 角度,然后添加回 C 以获得 P1 和 P2。要将矢量旋转一定角度,请将其乘以旋转矩阵。
因此,在伪代码中,它看起来像这样:
An arc that subtends an angle of θ (in radians) has an arc length of θR. So, you want a half-angle of θ = X/(2R). You then need to take the vector (P -C), rotate it by angles of ±θ, and add back in C to get P1 and P2. To rotate a vector by an angle, multiply it by a rotation matrix.
So, in pseudocode, it would look like this:
有一些事情可以提供帮助。不会编写代码,但我想解决方案将基于三角形。考虑:
任何半径都具有相同的长度。
因此,从 P1-P1-C 绘制的三角形是等腰三角形。
任何切线都垂直于半径。
我现在很难证明这一点,但如果你将线从 C 延伸到 P1/P2 到与圆相交于 C->P 的切线,也会形成等腰。
从那里应该很容易弄清楚。
There's a few things that could help. Not gonna write the code but I imagine the solution is going to be based on triangles. Consider:
Any radius is the same length.
Thus the triangle drawn from P1-P1-C is isosceles.
Any tangent is perpendicular to the radius.
I'd be hard pressed to prove it out right here and now, but if you extend the lines from C through P1/P2 to the tangent that intersects the circle at C->P also form an isosceles.
Should be easy to figure out from there.