Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate (x,y) for a fixed arc length away from a point on a circumference

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

like image 447
JConway Avatar asked Nov 05 '10 23:11

JConway


People also ask

What is the formula for a length of an arc?

Summary. The length of any arc is s = r θ , where is the length of the arc, is the radius, and is the measure of the angle in radians.


2 Answers

On a circle, an angle theta corresponds to an arc length of theta * R, meaning your arc will subtend an angle of theta = X / R. So if start with your point

P = C + R * (sin(u), cos(u))

then just go up/down by theta/2:

P1 = C + R * (sin(u + theta/2), cos(u + theta/2))

and

P2 = C + R * (sin(u - theta/2), cos(u - theta/2))
like image 176
Jesse Beder Avatar answered Nov 07 '22 04:11

Jesse Beder


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:

θ = X/(2R)
A = 2x2 rotation matrix corresponding to a rotation by θ radians
A' = transpose of A
P1 = C + A * (P - C)
P2 = C - A' * (P - C)
like image 25
Adam Rosenfield Avatar answered Nov 07 '22 04:11

Adam Rosenfield