【发布时间】:2019-01-05 18:55:18
【问题描述】:
我有一个由-13 degrees 旋转的红色容器,在这个容器内有一个由-13 degrees 旋转的粉色正方形。
仅使用下面的这些信息,我试图找到相对于原点(上、左)(0,0) 的pink square 变换
相对变换坐标是我需要在父级内部平移多少。并且边界框只是包含旋转的大小(它是屏幕截图上的黑框)
粉红方块
size before rotation
height : 398
width : 398
size after rotation
height : 477
width : 477
Bounding box
x : 179
y : 230
Relative transform to parent
x : 0
y : 49
Rotation
-13 deg
红色容器
size before rotation
height : 632
width : 447
size after rotation
height : 716
width : 577
Bounding box
x : 179
y : 182.28
Relative transform to parent
x : 279
y : 182
Rotation
-13 deg
这是我尝试做的事情
yCoordinate = pink.relativeTransform.y + redContainer.boundingBox.y
xCoordinate = pink.relativeTransform.x + redContainer.boundingBox.x
我设法让 yCoordinate 正确,但我无法获得 x 坐标,我担心这适用于所有角度
【问题讨论】:
标签: math rotation geometry bounding-box coordinate-transformation