Define a straight-line connection
\gamma: \left[ 0,L \right] \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}
.
{\color{teal}x(t)}
=
X + fractionReduce((P-X)*N,Z) * t
{\color{teal}y(t)}
=
Y + fractionReduce((Q-Y)*N,Z) * 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}\left[0,L \right ]
.
Thus, we have less time.
In the parametrization above, we replace t
by fractionReduce(N,Z) \cdot t
and get
\gamma: \left [0,L \right] \to \mathbb R^2,
\gamma(t) = { \color{red}\begin{pmatrix}X\\Y\end{pmatrix} }+
fractionReduce(N,Z) \cdot t
{ \color{orange}\begin{pmatrix} P-X\\Q-Y\end{pmatrix} }= { \color{teal}
\begin{pmatrix} X + fractionReduce((P-X)*N,Z) \cdot t \\
Y + fractionReduce((Q-Y)*N,Z) \cdot t \end{pmatrix}}
.