我该如何处理 2D 图像并将其围绕 X、Y 或 Z 轴旋转,就好像它是 3D 图像一样。在 java 中?
我想要实现 2D 图像的效果,但有点倾斜,例如平面,我希望图像可以绕其 Y 轴旋转......任何人都可以帮助我了解如何做..* *
I want to achieve the effect of a 2D image I have but a little inclined, for example a plane, I want the image can be rotated about its axis Y. .. anyone can help me with some idea of how to do ..**
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上你需要一点线性几何/代数,和/或一个包来为你做这些。
从几何学的角度来看,您可以将图像视为位于空间的平面上; 你看着它就好像它被反投影到你的显示器上一样。 如果图片与屏幕完全平行且大小相同,则每个点都会映射到屏幕上的一个像素。 否则,您必须进行计算来进行映射,其中涉及该平面与屏幕平面之间的 x,y,z 方向角度的三角函数。 线性代数的出现是因为处理这种计算的简单方法是一系列 4×4 矩阵的乘法。
现在,您可以自己编程所有内容,并且对于您的想法来说,这并不那么困难。 查看任何好的计算机图形文本,例如 Shirley 或 弗利和范达姆。
就封装而言,Java 中有很好的 3D 图形。 更好的是,还有一些很好的教程:
Basically you need a little linear geometry/algebra, and/or a package to do them for you.
From the geometry point of view, you think of the image as if it's on a plane in space; you're looking at it as if it were back-projected on your monitor. If the picture is exactly parallel to that screen, and the same size, each point is mapped to a pixel on the screen. Otherwise you have to go through a computation that makes that mapping, which involves a trig function for the angles in the x,y,z directions between that plane and the plane of the screen. The linear algebra comes in because the easy way to handle this computation is as a series of multiplications of 4×4 matrices.
Now, you could program all that yourself, and for what you're thinking of it wouldn't be all that difficult. See any good computer graphics text, like Shirley, or Foley and van Damm.
As far as a package, there's good 3D graphics in Java. Even better, there are good tutorials:
在什么背景下? 在我看来,通过 JOGL 使用 OpenGL 等 3D API 是实现这一目标的最简单方法。 否则,如果角度是可变的,您将需要某种形式的软件渲染器。
In what context ? Using a 3D API like OpenGL trough JOGL seems to me like the simplest way to achieve this. Otherwise, if the angle is variable, you'll need some form of software renderer.