我有一个已经应用了旋转的矩形.我想获得未旋转的尺寸(x,y,宽度,高度).
以下是元素的尺寸:
Bounds at a 90 rotation: {
height 30
width 0
x 25
y 10
}
Run Code Online (Sandbox Code Playgroud)
以下是旋转设置为无后的尺寸:
Bounds at rotation 0 {
height 0
width 30
x 10
y 25
}
Run Code Online (Sandbox Code Playgroud)
在过去,我能够将旋转设置为0,然后读取更新的边界.但是,我使用的其中一个功能有一个错误,所以现在我必须手动完成.
是否有一个简单的公式,使用我已有的信息获得旋转0的界限?
更新:对象围绕对象的中心旋转.
更新:
我需要的是类似下面的功能:
function getRectangleAtRotation(rect, rotation) {
var rotatedRectangle = {}
rotatedRectangle.x = Math.rotation(rect.x * rotation);
rotatedRectangle.y = Math.rotation(rect.y * rotation);
rotatedRectangle.width = Math.rotation(rect.width * rotation);
rotatedRectangle.height = Math.rotation(rect.height * rotation);
return rotatedRectangle;
}
var rectangle = {x: 25, y: 10, height: 30, width: 0 }; …Run Code Online (Sandbox Code Playgroud) 如果我知道矩形的中心点(在全局坐标空间中)、宽度和高度以及围绕该中心点的旋转,有人能给我一个算法来找到矩形的所有四个角的位置吗?
澄清编辑:我所指的宽度和高度是矩形边长。