图形 (2D) 旋转:旋转 x 轴
Graphics (2D) Rotation: Rotate x Axis
我有一个 JPanel
,我在其中通过 drawPolygon
方法绘制三角形。我的目标是围绕 X 轴旋转图形。我知道有个方法叫做rotate,但是这个方法只绕Z轴旋转
如何绕 X 轴 JPanel
旋转图形?
Example of rotation
如果 Graphics 2D 库没有进行这种旋转的功能,请告诉我如何才能存档我的目标。我不介意切换到另一种 GUI 类型,例如 Java-fx 或 canvas。 (但留在Java)
Java二维提供AffineTransform
, but an affine transformation ensures that parallel lines remain parallel after transformation. As an alternative, consider JavaFX 3D, which provides a PerspectiveCamera
for perspective projection; this complete example uses Rotate.Y_AXIS
, but Rotate.X_AXIS
will produce the desired effect. Also consider a Java Advanced Imaging Warp
, cited here, which offers a WarpPerspective
with PerspectiveTransform
.
我有一个 JPanel
,我在其中通过 drawPolygon
方法绘制三角形。我的目标是围绕 X 轴旋转图形。我知道有个方法叫做rotate,但是这个方法只绕Z轴旋转
如何绕 X 轴 JPanel
旋转图形?
Example of rotation
如果 Graphics 2D 库没有进行这种旋转的功能,请告诉我如何才能存档我的目标。我不介意切换到另一种 GUI 类型,例如 Java-fx 或 canvas。 (但留在Java)
Java二维提供AffineTransform
, but an affine transformation ensures that parallel lines remain parallel after transformation. As an alternative, consider JavaFX 3D, which provides a PerspectiveCamera
for perspective projection; this complete example uses Rotate.Y_AXIS
, but Rotate.X_AXIS
will produce the desired effect. Also consider a Java Advanced Imaging Warp
, cited here, which offers a WarpPerspective
with PerspectiveTransform
.