【问题标题】:How to find scaled point before scale?如何在比例之前找到比例点?
【发布时间】:2015-03-21 04:51:59
【问题描述】:

我对此有一个视图和动画。我在3X3Y 上放大了这个视图。

pivotX 和 pivotY -> 视图中心

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

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

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

【问题讨论】:

    标签: java android animation math geometry


    【解决方案1】:

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

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

    【讨论】:

    • 但枢轴是视图的中心。你为什么不给他缩放?
    • 轴心点在缩放时不会移动 - 这是轴心点的点 - 一切都围绕它移动,但它保持在同一个位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多