如何在比例尺之前找到缩放点?

时间:2015-01-22 11:47:32

标签: java android animation math geometry

我有一个视图和动画。我在3X3Y上扩大了这一观点。

pivotX和pivotY - >观点中心

我想在缩放视图之前找到一个点(左,上),已经缩放的值。

 How can i find this point? ->()------------------------
                               |    ______________     |
                               |    |            |     |
                               |    |   100x50   |     |
                               |    |            |     |
                               |    --------------     |
                               |                       |
                               -------------------------

注意:坐标系为 [x:从左到右,y:从上到下]

1 个答案:

答案 0 :(得分:0)

您可以计算出像这样的比例之后的任何点:

// find the position relative to the pivot point
float relativeX = pointBeforeScale.x - pivotPoint.x; 
float relativeY = pointBeforeScale.y - pivotPoint.y;

// multiply the relative position by the scale
relativeX *= scale;
relativeY *= scale;

// add the pivot point to the result to get the absolute position.
float pointAfterScaleX = relativeX + pivotPoint.x;
float pointAfterScaleY = relativeY + pivotPoint.y;