在 2D 中旋转对象 space
Rotate object a object in 2D space
我正在寻找在 2D 中旋转对象的解决方案 space。我点了
坐标 X,Y。我需要将这个对象围绕中心的对象移动一段距离。 Here is a picture with description 我正在使用 java FX。我需要一些
对此公式化。可能我必须使用一些 sin 和 cos 来转向,但我不知道如何。谢谢你的帮助。
您可以将 Rotate
添加到要旋转的对象的变换列表中:
double x = /* x-coordinate for center of rotation */ ;
double y = /* y-coordinate for center of rotation */ ;
double angle = /* angle in degrees */ ;
Rotate rotate = new Rotate(angle, x, y);
nodeToRotate.getTransforms().add(rotate);
旋转中心的坐标必须与正在旋转的节点使用的坐标系相同。
当你旋转向量时(x,y)
(连接中心和点的线)
新坐标将是 (x',y')
并通过
关联
x'= x*cos(angle)-y*sin(angle)
y'= x*sin(angle)+y*cos(angle)
因为这里的 y 坐标是颠倒的(即正向下)你必须用 -y
替换 y
我正在寻找在 2D 中旋转对象的解决方案 space。我点了 坐标 X,Y。我需要将这个对象围绕中心的对象移动一段距离。 Here is a picture with description 我正在使用 java FX。我需要一些 对此公式化。可能我必须使用一些 sin 和 cos 来转向,但我不知道如何。谢谢你的帮助。
您可以将 Rotate
添加到要旋转的对象的变换列表中:
double x = /* x-coordinate for center of rotation */ ;
double y = /* y-coordinate for center of rotation */ ;
double angle = /* angle in degrees */ ;
Rotate rotate = new Rotate(angle, x, y);
nodeToRotate.getTransforms().add(rotate);
旋转中心的坐标必须与正在旋转的节点使用的坐标系相同。
当你旋转向量时(x,y)
(连接中心和点的线)
新坐标将是 (x',y')
并通过
x'= x*cos(angle)-y*sin(angle)
y'= x*sin(angle)+y*cos(angle)
因为这里的 y 坐标是颠倒的(即正向下)你必须用 -y
y