I have a shape and a vector of shape's points, and I want to zoom in/out (resize whatever) the shape by dragging the mouse from a point of the shape to other random point (like in windows point for example)
What I search e read is that to scale a shape you have to recalculate all coordinates to:
xScaled = firstX * scaleX
yScaled = firstY * sclaleY
My problem is how to find that scale factor, what is the formula? Remebering that I have acess to the firstHitPoint, the actual point and all the points of the shape, and I have to do this by dragging the mouse.
Here is a peaceof my code:
@Override
public void transformPoints() {
findTransformationFactors();
int size = points.size();
for(int i = 0; i < size; i++)
points.set(i, new Point(points.get(i).x * scaleX, points.get(i).y * scaleY));
}
@Override
public void findTransformationFactors() {
int oldx = firstHitPoint.x;
int oldY = firstHitPoint.y;
int actualX = actualPoint.x;
int actualY = actualPoint.y;
scaleX = ??
scaleY = ??
}