从中心点缩放矢量?

jma*_*erx 5 algorithm graphics geometry

我想知道我是否有点,例如一个正方形:

 *     *



 *     *
Run Code Online (Sandbox Code Playgroud)

让我们说我知道这个广场的中心.我想要一个公式,它将使它的样本大小两倍,但是从中心开始

 *               *

      *     *



      *     *

 *               *
Run Code Online (Sandbox Code Playgroud)

因此,新形状是多边形的两倍并且从多边形的中心开始.它必须适用于任何形状而不仅仅是正方形.

我更多地关注它背后的理论而不是实现.

fbr*_*eto 8

如果您知道要缩放的多边形中心点cp和点,则:vscale

v2 = v - cp; // get a vector to v relative to the centerpoint
v2_scaled = v2 * scale; // scale the cp-relative-vector
v1_scaled = v2_scaled + cp; // translate the scaled vector back
Run Code Online (Sandbox Code Playgroud)

可以在任何维度的矢量上执行该平移 - 缩放 - 平移模式.