Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在缩放之前找到缩放点?_Java_Android_Animation_Math_Geometry - Fatal编程技术网

Java 如何在缩放之前找到缩放点?

Java 如何在缩放之前找到缩放点?,java,android,animation,math,geometry,Java,Android,Animation,Math,Geometry,我有一个视图和动画。我在3X和3Y上放大了这个视图 透视X和透视->视图中心 在缩放视图之前,我想找到一个点(左、上),该点已经缩放了值 How can i find this point? ->()------------------------ | ______________ | | | | |

我有一个视图和动画。我在
3X
3Y
上放大了这个视图

透视X和透视->视图中心

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

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

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

您可以按如下比例计算任意点:

// 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;

但轴心点是视图的中心。为什么不缩放他?缩放时枢轴点不移动-这就是枢轴点的点-所有东西都围绕它移动,但它保持在同一点上。