Calculating Circular Arc Segment Mid and End Point [duplicate]

I have different types of Circular Arc Segments. My given values are:

• the Start Point in Cartesian Coordinates (x_s, y_s)
• the Start Direction in rad (direction)
• the Length of the Arc (length)
• a value stating if the direction of the Arc is counter clockwise or not

The Start Direction is defined as the bearing used i.e. in road alignments (The bearing is the direction, clockwise from North sometimes stated in degrees, minutes and seconds). In a first step, I am calculating the Centre Point (x_c, y_c) of the Arc Segment, which already works correctly.

I now need to calculate the Mid and End Point of the Arc Segment. At the moment I am using the following to do so ('dist' is the distance along the segment, and therefore 0.5 for the midpoint and 1 for the endpoint):

if arc is clockwise: angle = dist * length / radius
if arc is counter-clockwise: angle = - dist * length / radius

x = x_c + radius * cos(direction + angle) (I)
y = y_c - radius * sin(direction + angle) (II)


I am aware, that I have to somehow change the signs before 'radius' in (I) and (II) depending on whether the endpoint/midpoint is left/right or above/below x_c/y_c, but I can't figure out how I can do that with my given values.

Did anyone get an idea, how to tackle the problem?

marked as duplicate by amd, Community♦Aug 24 '17 at 21:23

So after doing some more research in this forum I came across the following, that solved my problem: https://math.stackexchange.com/q/275510

• The solution that you cite is the mirror image of your problem. – amd Aug 24 '17 at 21:20

Instead of trying to do some sort of case analysis to sort out when you should have pluses and minuses, if I were doing this I’d simply rotate the starting point about the computed center point. You’ve already got all of the necessary ingredients for this: the starting point $(x_s,y_s)$, the center $(x_c,y_c)$ and the rotation angle (with direction encoded in the sign), which I’ll call $\theta$.

Start by translating $(x_c,y_c)$ to the origin, rotate the resulting point through the angle $\theta$, then translate back: \begin{align} x &= x_c+(x_s-x_c)\cos\theta+(y_s-y_c)\sin\theta \\ y &= y_c-(x_s-x_c)\sin\theta+(y_s-y_c)\cos\theta.\end{align} Note that this is a little different from the usual rotation formula because positive angles represent clockwise rotations.

For example, let’s say the start point is $S(3,2)$ the start direction is $\phi=-\pi/8$ (i.e., NNW), the radius $r=3$ and the arc length $s=2$. For a clockwise turn, the center of the arc is $$C=S+r(\sin(\phi+\pi/2),\cos(\phi+\pi/2))\approx (5.772,3.148).$$ For a counterclockwise turn, you would subtract $\pi/2$ instead, getting $(0.228,0.852)$ for the center. (If you’re not getting these values, you’ve already gone astray.)

The angle of arc is, as you’ve written, $\theta=s/r=2/3$ for a clockwise turn, $-2/3$ for counterclockwise. Plugging these values into the above formula, the end point of the clockwise arc is $$x \approx 5.772+(3-5.772)\cos(2/3)+(2-3.148)\sin(2/3)\approx 2.884 \\ y \approx 3.148-(3-5.772)\sin(2/3)+(2-3.148)\cos(2/3)\approx 3.960.$$ The midpoint is computed using half of this angle, i.e., $\theta=1/3$, resulting in $(2.777,2.970)$. I’ll leave plugging the values for a counterclockwise turn into the formula to you.

If you substitute the computations of the arc center, which you say you’re already doing correctly, into the above rotation formulas and simplify using the identities for trig functions of sums of angles, you’ll end up with the following formulas: \begin{align} x &= x_s \pm r\cos\phi \mp r\cos\left(\phi\pm\frac sr\right) \\ y &= y_s \mp r\sin\phi \pm r\sin\left(\phi\pm\frac sr\right). \end{align} As before, $\phi$ is the initial heading and $s$ is the distance along the arc (halved for the midpoint, of course). Where there is a choice of sign, the upper signs are for a right turn and the lower signs for a left turn.

• I spent the whole last night figuring out your solution and although I get what you mean it still does not work for me. What I did was the following: 1. translate to the origin (0/0) 2. calculate the mid and end point (x/y) supposing theta = 0 3. turning the resulting points by the angle alpha which is theta + pi/2 in case the direction is counter clockwise and theta - pi/2 in case the direction is clockwise using the following formulas: xt = cos(alpha) * x + sin(alpha) * y and yt = - sin(alpha) * x + cos(alpha) * y 4. translate back: _xe=xt+xc and _ye=yt+yc – FlixFix Aug 24 '17 at 10:43
• Anyway, I still don't get the correct result. This problem seems really trivial but it is getting somewhat frustrating because I am not able to solve it... – FlixFix Aug 24 '17 at 10:44
• @FlixFix Of course you’re not getting the correct result. You’re not doing what my answer tells you to. Why are you adding and subtracting $\pi/2$ from the angle of arc $\theta$ that you’ve already computed (called angle in your question)? You’re computing the end and mid points of a completely different arc than the one you started with. – amd Aug 24 '17 at 16:24