3
$\begingroup$

im trying to solve the following problem but cannot find any solution on my own. Take the following example. I have two points A and B. They have the following coordinates:

Ax = -100 Ay = 0 Bx = 100 By = 0 

Now I would like to scale my points by factor x in the coordinate system based on a given point as origin. This point has the same coordinates as point A:

Px = -100 Py = 0 X = 2 

I found the following formula to calculate the resulting coordinates:

Ax' = X * (Ax - Px) + Px Ay' = X * (Ay - Py) + Py 

With this formula I can increase X as long as I scale from the same point P. But how can I solve this problem if P also changes while X increases? Thank you in advance. And sorry im not the best in math so I dont know if I choosed the right Tag for this topic.

As requested here is a little example to make myself clearer. Imagine 2 Points A and B with the following coordinates:

A(-100, 0) B(100, 0) 

Now I set my origin for scaling to the positon of point one and zoom by a factor of two:

P(-100, 0) X = 2 

When I appliy the equation above I expect point A to remain at its position and point B moving to postion (300,0).

Ax' = 2 * (-100 + 100) - 100 = -100 Bx' = 2 * (100 + 100) - 100 = 300 

As you can see this works. Now I move my point for scaling to the position of the scaled B and increase X to 3:

B(300,0) P(300,0) X = 3 Bx' = 3 * (300 - 300) + 300 = 300 

As you can see this works too. But my problem is that I cant change the initial coordinates of B (because I am writing a computer program and my coordinates should not change) and taking this into account the equation does not work:

B(100,0) P(300,0) X = 3 Bx' = 3 * (100 - 300) + 300 != 300 

Is it possible to calculate the final coordinates of B without changing its initial coordinates?

Solved

Ok,

I solved my problem by moving and scaling my coordinates system instead. This way my points could keep their original coordinates. Thanks for your answers.

  • 0
    So you detailed the problem but dont detailed your solution? This is a COLABORATIVE network.2012-11-27

1 Answers 1

3

It sounds like you want to zoom in based on an origin at $P$ by a factor $X$. The new point $P'=(0,0)$ because it is the origin. Given a point $A$, $Ax'=X(Ax-Px), Ay'=X(Ay-Py)$ in the new system, because you want to scale the distance from $P$ by a factor of $X$.