到目前为止,我在JavaFX中旋转对象所使用的方法是将其分成三组,每一组都附加了一个旋转并锁定在一个单独的轴上,如下所示:
Rotate heading, roll, pitch;
Group normalrotate, rollrotate, verticalrotate;
heading.setAxis(new Point3D(0,1,0));
normalrotate.getTransforms().add(heading);
roll.setAxis(new Point3D(0,0,1));
rollrotate.getTransforms().add(roll);
pitch.setAxis(new Point3D(1,0,0));
verticalrotate.getTransforms().add(pitch);
并且每次需要旋转对象时,我都会做一次setAngle()。这对于仅涉及heading和roll的情况非常有效,直到我决定还需要pitch。现在,许多OpenGL等库的教程都说对于这些类型的旋转最好使用旋转矩阵或四元数,但是JavaDoc缺乏有关此类内容的有用数据。
例如:当我沿y轴将一个对象旋转180度时会发生什么(实际上应该发生透明蓝色部分的旋转)?
![enter image description here](https://istack.dev59.com/3myEs.webp)