Calculating the end point angle of an arc.

circlesgeometryprogramming

I am currently coding a program that draws a race track by combining multiple line segments that the user defines (which can be either a straight or a curve).

For my curve, I have the data for its radius, length and starting point. Using some maths explained here, I can also calculate the end point coordinates.

What would be a way to calculate the endpoint angle of the arc? It is important for me to know the end angle as the next line segment that connects with the arc will start with the same angle as the arc.

enter image description here
Example track Diagram

Edit

enter image description here
Problem Diagram

I am interested in finding the angle that a tangent intersecting the end point would make with the x axis.

Best Answer

The angle an arc spans (in radians) is $$ \widehat{\rm angle} = \frac{\rm arclength}{\rm radius} $$

Then you simply add up all the angles of all the corners up to the one you are drawing to find where the orientation of the arc end.

When the final orientation is 360° you have completed one circuit of the track.


The more interesting problem is coming up with the arc endpoint coordinates from the standpoint coordinates $(x_1,\,y_1)$, the initial direction $\theta_1$, the radius $r$ and the arc length $s$.

fig1

  1. A counter clockwise arc sweeps an angle $\varphi = s/r$ in radians, so the final direction of the track after the arc is $\theta_2 = \theta_1 + \varphi$.

    The endpoint coordinates are found with some trigonometry

    $$ \pmatrix{x_2 \\ y_2} = \pmatrix{x_1 -r \sin \theta_1 + r \sin \theta_2 \\ y_1 + r \cos \theta_1 - r \cos \theta_2 } $$

  2. A clockwise arc sweeps an angle $\varphi = s/r$ in radians, so the final direction of the track after the arc is $\theta_2 = \theta_1 - \varphi$.

    The endpoint coordinates are found with some trigonometry

    $$ \pmatrix{x_2 \\ y_2} = \pmatrix{x_1 +r \sin \theta_1 - r \sin \theta_2 \\ y_1 - r \cos \theta_1 + r \cos \theta_2 } $$