# Calculate connecting line and circular arc between two points and angles

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.

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.

• 1.Do you have to connect always a straight track to a curved track with another straight track and curved track? 2. Is the straight track to be joined always vertical or horizontal, or can it assume any direction? Commented Dec 12, 2015 at 16:18
• Ad 1. It is possible that an easement is connecting two curved tracks. Ad 2. All tracks can assume any direction. Commented Dec 12, 2015 at 16:53

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).