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
    How does $P$ change as $X$ increases?2012-11-11
  • 0
    For example on the first calcualation I have P(-100,0) and X=2 and on the second calculation I have P(100,0) and X=3 But the second should take the changes from the first one into account.2012-11-11
  • 0
    Why would something change? I don't see any problem with the equations.2012-11-11
  • 0
    The reason is that I am writing a software at the moment and i would like to zoom into my content. Zooming should be based on the mouse position. This means the mouse position is my origin for scaling. It works fine with the equation above all my points are moving as intended as long I dont move the mouse to a different location and zoom further.2012-11-11
  • 0
    Why don't you just change P based on where your mouse is every time you move it and do the scalings one by one? You can get the coordinates of the mouse position, cannot you? In other words, can you tell exactly what you are doing and what exactly doesn't work?2012-11-11
  • 0
    Hi, I change P to where the mouse is that's not the Problem. The Problem is that as soon as i move p the equation does not work as intended.2012-11-11
  • 0
    I did some edits on my main post to make myself clearer.2012-11-11
  • 0
    So you detailed the problem but dont detailed your solution? This is a COLABORATIVE network.2012-11-27

1 Answers 1