Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Let say I have the following image,

enter image description here

How to calculate the new length of line?

Update: It seems there is confusion on question. See this image,

enter image description here

I just need to map the 100 * 100 Rectangle with 250 * 150 Rectangle. Everything inside 100 * 100 Rectangle must be shown to 250 * 150 Rectangle.

Finally, I got the correct answer. Thanks to anon and user27978. This will work even if the slope of new line changed.


share|improve this question
Unless you're stretching the points inside the rectangle, the line stays the same. If you are stretching the rectangle, then the answer is not unique and therefore cannot be determined (imagine changing the slope but not the length of the original line). –  anon Apr 2 '12 at 5:26
Have to guess about the question. There has been scaling by a linear factor of $2$ in the horizontal direction, and by a factor of $1.8$ in the vertical direction. If that is so, we cannot determine the new line length, it depends on the original slope of the line. To see this, note that if the line was horizontal, it would double in length, if it was vertical it would get its length multiplied by $1.8$, and if it is between, as in the picture, then the scaling factor for the length of the line is in between $2$ and $1.8$, can't say exactly where in between without knowing more. –  André Nicolas Apr 2 '12 at 5:26
If the line is the same as before, unaffected by the change of rectangles, then the length is also the same as before, and you are left without a coherent question. –  anon Apr 2 '12 at 5:42
user960567: We've told you many times over the answer depends on the slope of the line. Now you're telling us you know the slope, but of course you don't actually tell us what it is! How do you expect people to help you? –  anon Apr 2 '12 at 5:54
@user960567:Happy it worked out. Could have been a lot faster if it had been clear you knew rise and run. You had mentioned you were $100$ percent sure slope didn't change. I imagine you can see now that it does, albeit not much. –  André Nicolas Apr 2 '12 at 15:21
show 24 more comments

2 Answers

up vote 1 down vote accepted

I assume the transformation is of the form $\rm f:(x,y)\mapsto (ax,by)$, where we identify the lower left-hand corner with the origin. Given only the length $\ell$ of a line $\rm L$ contained inside the first triangle, it is impossible to determine the length $\ell\,'$ of its image on the other triangle, $\rm f(L)$. If $\rm a\ne b$, changing the slope of $\rm L$ but without altering its length will still alter the value of $\ell\,'$.

As a concrete example, say $\rm a=1,b=2$ so that a $1\times 1$ square becomes a $1\times 2$ rectangle. In the process, $\rm x$-coordinates remain unaffected while $\rm y$-coordinates double. Thus, the length of any given horizontal line will remain unchanged, while the length of a vertical line will double. Clearly the length prior to transforming is insufficient information to determine the length after transforming.

Say you also know $\rm m$ the slope of the line. (The case of a vertical line reduces to a one-dimensional problem, so we will ignore it.) If we move the line to the origin and write its coordinate components as $\rm (x,m\,x)$, then we have $\rm \sqrt{x^2+(m\,x)^2}=\ell$, which we can use to solve for $\rm x$ as

$$\rm x=\frac{\ell}{\sqrt{1+m^2}}.$$

Now $\rm f(x,m\,x)=(ax,bmx)$ has length $\ell\,'=\rm \sqrt{(ax)^2+(bmx)^2}=\sqrt{a^2+(b\,m)^2}x$, whence we have

$$\rm \ell\,'=\sqrt{\frac{a^2+(bm)^2}{1+m^2}} \,\ell.$$

With the coordinates of the lines segment's endpoints $\rm (x_1,y_1)$ and $\rm (x_2,y_2)$, we have

$$\rm m=\frac{\Delta y}{\Delta x}=\frac{y_2-y_1}{x_2-x_1}$$

whence we have

$$\rm \ell\,' = \sqrt{(a \Delta x)^2+(b\Delta y)^2}.$$

share|improve this answer
I know the slope of line. –  user960567 Apr 2 '12 at 5:53
Thanks......... –  user960567 Apr 2 '12 at 6:32
With multiple test, I am confirming that this is correct one. Actually I just needed to map meters in one rectangle into pixels in another rectangle. So, clearly the slope of a line remain same in both cases. So, a is x-ratio and b is y-ratio and slope is same as of ℓ, I got the solution. Thanks a lot @anon. Any comment welcome. But Why you vote down my question? –  user960567 Apr 2 '12 at 6:53
Very nice and superb last. I think this is same as @user27978 is given us at bottem. –  user960567 Apr 2 '12 at 7:58
@user960567: Actually, having both $\Delta x$ and $\Delta y$ amounts to having more information than just the slope $m=\Delta y / \Delta x$, not less information. At any rate, you were told you did not disclose enough information for an answer, then you said you actually had the information (but apparently were not going to let us in on it). This is inconsiderate, period. –  anon Apr 2 '12 at 9:56
show 4 more comments

The answer depends on the slope of the line. The horizontal scaling is $\frac{600}{300} = 2$, the vertical scaling is $\frac{450}{250} = \frac{9}{5}$. If $x, y \in \unicode{x211D}^2$ are the end points of the original line, then the length of the new line is $\sqrt{2^2(x_1 - y_1)^2 + (\frac{9}{5})^2(x_2 - y_2)^2} $. Since all we know is that $\sqrt{(x_1 - y_1)^2 + (x_2 - y_2)^2} = 150 m$, the most we can say is that the length of the new line lies between $\frac{9}{5} \times 150 m$ and $2 \times 150m$.

In the following, I drop the meter dimension as it is easy to confuse with the symbol I use to represent the slope, m.

If you know the slope of the line, say $m = \frac{y_2 - x_2}{y_1-x_1}$, then the length formula for the original line gives $\sqrt{(1+m^2)(x_1 - y_1)^2} = 150$, or $|x_1-y_1| = \frac{150}{\sqrt{1+m^2}}$, from which we get $|x_2-y_2| = |m|\frac{150}{\sqrt{1+m^2}}$. Then the length of the new line is given by plugging these numbers in: $\sqrt{2^2 \frac{150^2}{1+m^2} + (\frac{9}{5})^2 \frac{m^2 150^2}{1+m^2} } = \frac{150}{\sqrt{1+m^2}}\sqrt{2^2 + (\frac{9}{5})^2 m^2 } $. A quick sanity check with $m=0$ and $m = \infty$ returns the expected numbers.

share|improve this answer
I know the slope of line. –  user960567 Apr 2 '12 at 5:53
I think your formula is wrong. It should be (x2-x1) instead of (x1 - y1). –  user960567 Apr 2 '12 at 6:13
I chose bad labels for the end points, which may be confusing. One end point is $(x_1, x_2)$, the other is $(y_1,y_2)$. However, the formulae are correct in terms of these corrdinates. –  copper.hat Apr 2 '12 at 6:17
This is same as anon giving above. Thanks. –  user960567 Apr 2 '12 at 7:59
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.