Define a straight line
\gamma: [0,L] \to \mathbb R^2,
\gamma(t) = { \color{teal}\begin{pmatrix} x(t) \\y(t) \end{pmatrix}}
from the point
\mathbf {\color{red}A}
to the point \mathbf {\color{blue}B}
an.
{\color{teal}x(t)}
=
X + fractionReduce(P-X,L) * t
{\color{teal}y(t)}
=
Y + fractionReduce(Q-Y,L) * t
The point \mathbf {\color{red}A}
has the coordinates {\color{red}(X,Y)}
,
and \mathbf {\color{blue}B}
is \color{blue} (P,Q)
.
For the straight-line connection from {\color{red}(X,Y)}
to
\color{blue} (P,Q)
we need the direction vector.
This is \color{orange}\begin{pmatrix} P-X\\Q-Y\end{pmatrix}
.
Thus, we have the (obvious) parametrization
\gamma: [0,1] \to \mathbb R^2, \gamma(t) = { \color{red}\begin{pmatrix}X\\Y\end{pmatrix} }+
t \cdot { \color{orange}\begin{pmatrix} P-X\\Q-Y\end{pmatrix} }= { \color{teal}
\begin{pmatrix} X + P-X \cdot t \\
Y + Q-Y \cdot t \end{pmatrix}}
.
But the interval is not [0,1]
, it is \color{purple}[0,L]
. Thus
we have more time.
In the parametrization above, we replace t
by \dfrac t{L}
and get
\gamma: [0,L] \to \mathbb R^2, \gamma(t) =
{ \color{red}\begin{pmatrix}X\\Y\end{pmatrix} }+
\dfrac t{L} \cdot { \color{orange}\begin{pmatrix} P-X\\Q-Y\end{pmatrix} }=
{ \color{teal} \begin{pmatrix} X + fractionReduce(P-X,L) \cdot t \\
Y + fractionReduce(Q-Y,L) \cdot t \end{pmatrix}}
.