[Math] Calculate connecting line and circular arc between two points and angles

curvesgeometry

Given two points and angles, how can I calculate the connection between the two points in the form of a straight line and a circular arc?


Context of the question: I am trying to make a program that converts a model railway layout created in XtrkCAD into a SCARM layout (scarm.info). Both design applications have a different approach, and a different way of saving the layout to a file. Luckily both use a human readable text file format.

XtrkCAD knows the concept of the easement or transition curve, but SCARM doesn't. When converting a layout I now get gaps in the track where XtrkCAD had an easement. When I close that gap using SCARM, it creates a piece of track consisting of a straight part and a circular curve.

The following image shows an example. A straight track (length 50) has to be connected to a curved track (radius 276, angular length 56.5 degrees). The red track created by SCARM is a straight track of length 56, followed by a curved track with radius 360 and an angular length of 16.8 degrees.

enter image description here

What I would like to know is how I can calculate the straight track and the curved track, based on the end points of the two pieces of track that should be connected and their angles.

Best Answer

Suppose you must connect two straight segments $AB$ and $CD$, or two arcs, or a segment and an arc (colored blue in the picture), ending at points $B$ and $C$.

Extend the segments (or draw the lines tangent to the arcs at $B$ and $C$) so that they meet at $F$. If $BF>CF$ (as in the picture) construct point $G$ on $BF$ such that $FG=FC$ and draw the perpendicular lines to $GF$ and $CF$ at points $G$ and $C$.

Let $K$ be the point where these perpendicular lines meet and draw arc $GC$ centered at $K$: this arc, together with segment $BG$, provides the needed connection (red in the picture).

enter image description here