Say I have 2 separate objects.
One is a line defined by two points, the other is a polyline defined by three points.
Line 1 consists of the set of two points:
$a=(0,0,0)$ and b=$(0,0,1)$
Line 2 consists of the set of three points, which in this example are:
$c=(4,1,1)$, $d=(3,3,2)$, $e=(4,4,3)$
So line 2 has two end points and one "inner" point. This "inner" point can also be two or more, till $n-2$ for arbitrary polylines.
The problem is a way to transform line 2 so that it fits in line 1. In other words, scale and rotate all three points of line 2 so that it aligns with line 1.
Point $c$ would map to point $a$ and point $e$ would map to point $b$. Point $d$ also has to be calculated and added to the point set of line 1. I have linked a figure to illustrate the two objects. The positive Z-axis is pointing up.
As shown in the linked figure, line 1 is just a unit vector in the Z-direction. This line can also start from another position such as $a_2= (1,1,1)$ till point $b_2=(1,1,2)$ if starting at $(0,0,0)$ is a problem and as long as it is of unit length in the Z-direction. Then, in the end it is just a matter of translating all the transformed points of line 2 with the vector $(b_2 - a_2)$ to get back to the starting position of $(0,0,0)$.
So, in this example the end the result would consist of a set of three transformed points, shown in the matrix below: $\begin{bmatrix} 0&0&0 \\\\ ...&...&... \\\\ 0&0&1 \end{bmatrix}$
To summarize, the problem is how to transform line 2 into line 1 and also how to compute the "inner" points.