0
$\begingroup$

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.

ℓ′=√(aΔx)2+(bΔy)2

  • 0
    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).2012-04-02
  • 2
    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.2012-04-02
  • 0
    Actually, I am mapping Rectangle1(with x1 * y1) and Rectangle2(with x2 * y2)2012-04-02
  • 0
    user960567: **How?**2012-04-02
  • 0
    Using Ratios.,,2012-04-02
  • 0
    one way find the answer, is to open image in Paint and observe the change in pixel coordinate lol, also i think you can have a bijection using a linear function. Imagine the lines from one corner to the edges of the rectangular, where those lines would intersect a smaller rectangular ?2012-04-02
  • 0
    The line is same. Only the rectangle expanded.2012-04-02
  • 1
    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.2012-04-02
  • 0
    Actually, the line is also expanding with the same ratio as Rectangle ratio.2012-04-02
  • 0
    But the rectangle is not expanding with any single ratio!2012-04-02
  • 0
    As I pointed out earlier, since the scaling in the horizontal and vertical direction is not the same, the answer depends on the slope of the line.2012-04-02
  • 0
    @AndréNicolas, I know the slope of line.2012-04-02
  • 1
    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?2012-04-02
  • 0
    @user960567: You mean I assume the original line, since the new line will have usually a somewhat different slope. Then the question can be answered.2012-04-02
  • 0
    I am 100% sure that the slope remain same.2012-04-02
  • 0
    @anon, Sorry for that. Actually I am working on complex problem. I was tried to simplified it.2012-04-02
  • 0
    The only way it's possible, given the numbers in the picture, that the slope remains unchanged by the transformation is if the line is either vertical or horizontal. (But as long as we don't know which, we still can't answer this question!)2012-04-02
  • 0
    @anon, See update.2012-04-02
  • 0
    @AndréNicolas, See update.2012-04-02
  • 0
    The answer is still the same: the length of the line after transformation depends on the slope before transformation. And the slope is still not given.2012-04-02
  • 0
    @anon, I think If I have the points of this line then I need to multiply x ratio and y ratio with my points and then calculate the distance. Is it correct?2012-04-02
  • 0
    If you know the coordinates of the endpoints of the line segment, yes.2012-04-02
  • 0
    @anon, the slope is also known. Is you can further simplify this.2012-04-02
  • 0
    Oh i didn't notice that the horizontal and vertical ratios are not the same lol2012-04-02
  • 0
    @AndréNicolas got answer see above. No need for slope.2012-04-02
  • 0
    @BroskianaJones, got answer see above. No need for slope.2012-04-02
  • 0
    @GerryMyerson, got answer see above. No need for slope.2012-04-02
  • 1
    @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.2012-04-02
  • 0
    @AndréNicolas, You are correct. Sorry for that. I was just visualizing that time.2012-04-03

2 Answers 2

1

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}.$$

  • 0
    I know the slope of line.2012-04-02
  • 0
    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?2012-04-02
  • 0
    Very nice and superb last. I think this is same as @user27978 is given us at bottem.2012-04-02
  • 0
    further testing reveal that the formuls is giving correct result even after transformation the slope is not same, ℓ′=√(aΔx)2+(bΔy)2. Take a example of 200 * 200 Rectangle R1 and 800 * 400 Rectangle R2. The distance between 0,0 and 100,100(mid point) in R1 is 141.4213562 with slope 1. Now the same line become 0,0 and 400,200(mid point) for R2 and their distance become 447.2136. Using your new formula, gives the same result(447.2136), even the slope is different(0.5). Can you please confirm that this is correct formula, even the slope is different.2012-04-02
  • 0
    @user960567: Whether or not the transformation changes the slope of the original line is irrelevant to my reasoning and therefore has no bearing on the validity of the formulas written in my answer. They are correct. Your asking me this tells me you do not fully understand my answer and how I got it.2012-04-02
  • 0
    yes I am just wanted to say that even the slope of new line in R2 changes, the distance is always correct. I am wondering why all of you guys said before that it is not possible without slope and other information. Clearly your last formula don't need this.2012-04-02
  • 1
    @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.2012-04-02
  • 0
    OK. Thanks. Sorry for that.2012-04-02
1

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.

  • 0
    I know the slope of line.2012-04-02
  • 0
    I think your formula is wrong. It should be (x2-x1) instead of (x1 - y1).2012-04-02
  • 0
    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.2012-04-02
  • 0
    This is same as anon giving above. Thanks.2012-04-02