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.

I've got a bit of a mathematical problem.

Basically I have a square, and the width and height are multiplied by 1.02. Now in the square is a point, which we'll refer to as (c,d), and the origin of the shape is the top left corner, we'll call that (a,b) Think of the square as an image of a dot, and so as the square is scaled, the dots position will move respectively. Diagram to clarify:

enter image description here

My question is, what equation would calculate a translation of the new scaled shape, so that the new point c,d would be in the same place as its previous point c,d in the un scaled position? Thanks

By the way, someone suggested to me that you would simply divide the co-ordinate a,b by 1.02, which I don't think is correct, as I tried it and it didn't achieve the desired result.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If I understand your setup correctly, the coordinates of the new location of the old $(c,d)$ will be $(c',d')$, where $$c'=a +(1.02)(c-a)\qquad \text{and} \qquad d'=b+(1.02)(d-b).$$

The expressions can be given in various modified forms. For example, one can rewrite the expression for $c'$ as $c'=(1.02)(c) -(0.02)a$.

Any point $(x,y)$ is transformed in the same way, to $(x',y')$, where $$x'=a +(1.02)(x-a)\qquad \text{and} \qquad y'=b+(1.02)(y-b).\quad\text{(Formula 1)}$$

Now let us suppose that you want to drag this new point $(c',d')$ so that it is in its old location $(c,d)$. That means that we "add" $((c-c'), (d-d'))$ to any $(x',y')$ that we have obtained as in Formula 1 above. If you do the details, you will obtain an explicit expression which turns out to be quite simple.

If a message from you indicates a wish for it, and someone else has not done so, I could amend this post by giving a derivation of the "formula."

Added: Inevitably, the derivation needs to assume a few things. We assume that the location "addresses" $a,b$, $c, d$ are in an ordinary Cartesian coordinate system. So somewhere there is an origin, and there are $x$ and $y$ axes as usual, and by $a, b$, for example, we mean what is usually called $(a,b)$. We do not assume that the sides of the square are parallel to the axes. Indeed the square has nothing to do with the calculation. The only thing that we assume is that the point $(a,b)$ is the center of dilatation.

One way to do the transformation is in three steps: (i) Drag $(a,b)$ to the origin, dragging everything along with it the same amount in the same direction; (ii) Do the scaling; (iii) Drag back.

So when we do the dragging, $(c,d)$ is transformed to $(c-a,d-b)$. When we do the dilatation, $(c-a, d-b)$ is transformed to $((1.02)(c-a), (1.02)(d-b))$.
And finally when we drag back, the point $((1.02)(c-a), (1.02)(d-b))$ is transformed to $(a+ (1.02)(c-a), b+ (1.02)(d-b))$. That produces the expressions for $c'$ and $d'$ mentioned earlier.

One can view things more simply. Draw a horizontal line and a vertical line through $(a,b)$. Then the "distance" of $(c,d)$ from the vertical line, at least in the picture, is $c-a$. That has to be scaled by a factor $1.02$. So the new distance from the vertical line is $(1.02)(c-a)$, and the new $x$-coordinate is $a+(1.02)(c-a)$. A similar calculation handles the $y$-coordinate.

I prefer the drag, dilate, drag back approach.

share|improve this answer
    
Thanks for your help, and yes a derivation would be very helpful. –  Sam Jun 25 '11 at 15:00
    
@Jessica: I had not seen that it was $(c,d)$ that needed to remain unchanged, since the picture made it look as if it was $(a,b)$. To take care of both possibilities, I have added some material to the solution. –  André Nicolas Jun 25 '11 at 16:54
    
Ah yes, I thought something was wrong, because I tried the original formula and that was producing undesirable results. By the way, if the figures that are put into this formula are simplified to 6 decimal places, and their full value is not into the equation, will the result be slightly incorrect? Because I have tried the amended formula and it now works better, but there is a slight inaccuracy. I suppose it's because of the rounding to 6 decimal places right? –  Sam Jun 25 '11 at 19:22
    
@Jessica: I did not write down the amended formula explicitly, but I guess instructions were clear enough. Six decimal places should be plenty for visually undetectable "error." Maybe dilatation with centre of dilatation $(a,b)$ followed by translation is not what you actually want. –  André Nicolas Jun 25 '11 at 20:54
    
By the way, it works fantastically now, I had previously made a programatic mistake when trying it. So once again, thanks, you have been very helpful! –  Sam Jun 26 '11 at 13:41

Your Answer

 
discard

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.