I need to scale an object at a uniform scale on a particular point using (x,y) multiplication such as the one explained here :
http://www.willamette.edu/~gorr/classes/GeneralGraphics/Transforms/transforms2d.htm#Combining
The problem I'm currently facing is that whenever I try to scale an object with some coefficient (equal for both X and Y) the object gets pushed by some value to the right.I would like to prevent this from happening and I understand that the solution of this problem would be to subtract a value from the (X,Y) before actually scaling the object but I can't get to find the correct value.In the tutorial above it is explained like this
We saw that the basic scaling and rotating transformations are always with respect to the origin. To scale or rotate about a particular point (the fixed point) we must first translate the object so that the fixed point is at the origin. We then perform the scaling or rotation and then the inverse of the original translation to move the fixed point back to its original position. For example, if we want to scale the triangle by 2 in each direction about the point fp = (1.5,1), we first translate all the points of the triangle by T = (-1.5,-1), scale by 2 (S) , and then translate back by -T=(1.5,1). Mathematically this looks like
What do they mean the origin?Does that mean (0,0) and if yes then multiplying wouldn't that be multiplying by zero and not getting any result?That doesn't make any sense that's why I suspect I must take this number that I subtract with just from one action.
Thanks in advance.
EDIT: This is the answer to the question explained for any person who could be possibly searching for it in the future since I didn't find a satisfying explanation on the Internet(excluding possible ones that I didn't find even through I searched sufficiently)
So in general if you would like to scale at point (X,Y) say that it (X = 10,Y = 15) with a Scale factor of 10 you must perform the following steps : 1)Find the center of the plane where the objects are currently located.For our case that would be the (10,15) point. 2)For each object that you are applying the scaling to subtract the X value of the center point from the object's X point and same goes for Y (I'm using the center point because I want it to be the uniform scale point). 3)Multiply the result from the operation by the scale factor (in our case 10).
The value you want to subtract from all coordinates before scaling is the point of your object that you do not want to get moved by the scaling operation. Typically, this is the center point, if applicable. By subtracting the center point, it gets mapped to coordinate space origin and is therefore unaffected by the scaling.
All other points of your object are still moved though because they get mapped to points other than (0,0).