从中心点缩放矢量? [英] Scaling vectors from a center point?
问题描述
我想弄清楚,如果我有积分,使例如方形:
I'm trying to figure out if I have points that make for example a square:
* *
* *
和我们说,我知道这个广场的中心。 我想要一个公式,这将使其成为eample两倍的大小,但离中心
and let's say I know the center of this square. I want a formula that will make it for eample twice its size but from the center
* *
* *
* *
* *
因此,新的形状是两倍大,并从该多边形的中心。它有适用于任何形状的不只是正方形。
Therefore the new shape is twice as large and from the center of the polygon. It has to work for any shape not just squares.
我在找更多的钱背后的理论比实现。
I'm looking more for the theory behind it more than the implementation.
推荐答案
如果您知道中心点 CP
键,点 v
,你将在多边形想通过扩展
,那么:
If you know the center point cp
and a point v
in the polygon you would like to scale by scale
, then:
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
此转换规模,模式转换可以在任何尺寸的载体来实现。
This translate-scale-translate pattern can be performed on vectors of any dimension.
这篇关于从中心点缩放矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!