How can I get the $(x,y)$ of a sub-line, which has 0.45 length of the original line, between two points?

62 Views Asked by At

Given two points $(x_1, y_1)$ and $(x_2, y_2)$, they forms a straight line. The target is to find a point $(x_t,y_t)$ between these two points, and the length from $(x_1, y_1)$ to $(x_t,y_t)$ is 0.45 of the length of $(x_1, y_1)$ and $(x_2, y_2)$. Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

Let $p=\langle x_1,y_1\rangle$ and $q=\langle x_2,y_2\rangle$. Points on the line passing through $p$ and $q$ have the form

$$p(t)=\Big\langle x_1+t(x_2-x_1),y_1+t(y_2-y_1)\Big\rangle\;.$$

You can easily check that $p(0)=p$ and $p(1)=q$. It’s also easy to check that $p\left(\frac12\right)$ is the midpoint of the segment $\overline{pq}$. More generally, if $0\le t\le 1$, then $p(t)$ is the point on $\overline{pq}$ that is $t$ fraction of the way from $p$ to $q$.

This is a very useful way of describing the line segment $\overline{pq}$. The points $p(t)$ with $0\le t\le 1$ are said to be convex combinations of $p$ and $q$ and are often written in the following equivalent form:

$$p(t)=\Big\langle(1-t)x_1+tx_2,(1-t)y_1+ty_2\Big\rangle=(1-t)p+tq\;.$$

If we allow $t$ to range over all of $\Bbb R$ instead of just $[0,1]$, we get the entire line through $p$ and $q$. The points on the line that are on the opposite side of $p$ from $q$ are those with $t<0$; the points that are on the opposite side of $q$ from $p$ are those with $t>1$.

0
On

Consider breaking up the line into its $x$ and $y$ components. The change in $x$ ($\Delta x = x_2 - x_1$) and the change in $y$ ($\Delta y = y_2 - y_1$) will be scaled by a factor of $0.45$. Hence, we obtain: $$ (x_t, y_t) = \left( x_1 + 0.45(x_2 - x_1), y_1 + 0.45(y_2 - y_1) \right) $$