我知道了!刚刚在转换矩阵上看到了Peyam博士的视频。
上面的表达式来自下面的方法。我知道要绕中心旋转一个点,我们必须>
但是我无法理解的部分是:
r[0] = x * Math.cos(angle) - y * Math.sin(angle); ^ | why we use the minus sign here? r[1] = x * Math.sin(angle) + y * Math.cos(angle); ^ | And why here we use plus sign instead of minus? Vec2.prototype.rotate = function (center, angle) { //rotate in counterclockwise var r = []; var x = this.x - center.x; var y = this.y - center.y; r[0] = x * Math.cos(angle) - y * Math.sin(angle); r[1] = x * Math.sin(angle) + y * Math.cos(angle); r[0] += center.x; r[1] += center.y; return new Vec2(r[0], r[1]); };
这本书很棒,但是它并没有解释它简单地吐出来的大部分代码。
上面的表达式来自下面的方法。我知道要绕中心旋转点,我们必须将点移至原点进行旋转并将点移回原处... ... >>>>
我知道了!刚刚在转换矩阵上看到了Peyam博士的视频。
要获得x'和y',我们将变换矩阵乘以当前坐标(x,y)enter image description here
我知道了!刚刚在转换矩阵上看到了Peyam博士的视频。