Affine Transformation - Scale Around a Point

I am trying to scale the shape that I have in Java at a specific point.

When I use the AffineTransform.scale method, it scales in the upper left. In any case, you need to scale the snap at a point (for example, the center of the window for this case).

Thanks,

T

+4
source share
1 answer

I agree with Hovercraft Full of Eels that the right way to do this is to move the center to the upper left corner, scale, and then move the upper left corner back to the center.

However, if you want it to complete it in less than three steps, this conversion:

x ⟼ S (x - c) + c = Sx + (c - Sc),

where S is the scaling transformation, and c is the center in coordinates relative to the upper left position.

So you need to do the scaling and then translate c-Sc.

+3
source

Source: https://habr.com/ru/post/1486279/


All Articles