在2D坐标系中围绕特定点缩放 [英] Scaling around a specific point in 2d coordinate system

查看:176
本文介绍了在2D坐标系中围绕特定点缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的坐标系的图像:

Below is an image my coordinate system:

我想做的是我要围绕画布中的特定点开始缩放,缩放效果很好,但是我的问题是我不知道如何计算缩放时画布移动了多少,请注意,我没有使用canvas.scale.

What I am trying to do is that I want to start scaling around a specific point in the canvas, the scaling works fine but my problem is that I don't know how to calculate how much to move the canvas while scaling, note that I am not using canvas.scale.

我只是在缩放时增加了系统中每2个单位之间的距离,并且工作得很好.

I am simply increasing the distance between each 2 units in the system while scaling and it's working just fine.

那么有什么方程式可以帮助我找出在特定点缩放时画布的偏移量是多少?

So is there any equation that can help me find out how much to offset the canvas while scaling at specific point?

假设我要围绕point(0,4)缩放,如何知道缩放时要移动画布多少?

Suppose I want to scale around point(0,4) how to know how much to move the canvas while scaling?

推荐答案

在这种情况下,方程式不如了解正确的原理有用.答案只有一句话,但我需要先解释一下原理.

Equations in this case are less useful than knowing the right principle. The answer is only one sentence, but I'll need to explain the principle first.

当您说围绕一个点缩放"时,您要寻找的是暂时将另一个点视为原点.围绕原点缩放是微不足道的;它只是标量乘法.扩展到另一点是三个操作:

When you say "scale around a point", what you're looking for is to temporarily treat that other point as the origin. Scaling around the origin is trivial; it's simply scalar multiplication. Scaling around another point is three operations:

  • 将指定点转换为原点
  • 在(临时的,新的)原点进行缩放.
  • 向后平移,使原点回到指定点.

以数学符号表示,将比例运算符称为S.将指定点指向原点T的平移运算符.将原点指向指定点的运算符是T的倒数,表示为T -1 .那么执行按比例缩放"的运算符为T -1 ST. (从右到左应用运算符.)

In mathematical notation, call the scaling operator S. Call the translation operator that take the designated point to the origin T. The operator that takes the origin to the designated point is the inverse of T, denoted T-1. Then the operator that does "scaling at a point" is T-1ST. (Apply operators from right to left.)

算子T -1 ST称为S与T的共轭.在线性代数中,它也称为相似变换.如果S和T可以用矩阵表示(在此设置中也是如此),则组合的运算符是矩阵的乘积.

The operator T-1ST is called the conjugation of S by T. In linear algebra, it's also call a similarity transform. If S and T can be represented by matrices (as is true in this setting), the combined operator is the product of the matrices.

因此,这是一句话的答案:通过对原点的平移来缀合缩放操作.

So here's the one sentence answer: Conjugate your scaling operation by a translation to the origin.

我应该补充一点,尽管这不是问题的一部分,但是共轭也是您如何围绕一个点旋转.

I should add, although it's not part of the question, that conjugation is also how you rotate around a point.

这篇关于在2D坐标系中围绕特定点缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆