获得在在OpenGL弧度上的X,Y,Z轴的旋转相机? [英] Obtaining the camera rotation in radians on the X, Y, and Z axis in OpenGL?

查看:829
本文介绍了获得在在OpenGL弧度上的X,Y,Z轴的旋转相机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得各种轴相机的旋转在OpenGL(但使用Java,LWJGL和JME的具体)。相机对象可以让我得到的方向作为Vector3f,但是这似乎并没有工作就是让这些组件化的旋转;每个轴出现并列到另一个轴。我发现,与偏移角度成分toAngleAxis是一个快速劈,但不会在大多数情况下正常工作。我不是在数学遗憾的是那么好,否则我可能已经能够制定出这个问题:)同样,我只需要在X,Y和Z轴组件化和弧度,从0弧度到2 PI弧度。

I'm trying to obtain the camera rotation on various axis in OpenGL (but using Java, LWJGL, and jME specifically). The camera object allows me to get the direction as a Vector3f, but this doesn't seem to work to get the componentised rotation; each axis appears tied to another axis. I found that toAngleAxis with the angle component with offset was a quick hack, but doesn't work properly in most situations. I'm not so good at maths unfortunately, otherwise I may have been able to work out this problem :) Again, I just need the X, Y and Z axes componentised and in radians, from 0 radians to 2 PI radians.

谁能帮助?

欢呼和在此先感谢, 克里斯

Cheers and thanks in advance, Chris

推荐答案

获取旋转天使只需要改变以直角坐标给定成球形坐标中视图载体。您可以在维基

Obtaining the rotation angels requires just transforming the view vector given in cartesian coordinates into spherical coordinates. You can find the formulas in wikipedia.

viewvector = <x, y, z>

r = sqrt(x² + y² + z²)
phi = arctan2(y, x)
theta = arccos(z / r)

请注意,你只能获得两个旋转的天使形成观察向量。获得第三旋转角度需要知道在投影平面x或y轴

Note that you can only obtain two rotation angels form the view vector. Obtaining the third rotation angle requires knowing the projection plane x or y axis.

这篇关于获得在在OpenGL弧度上的X,Y,Z轴的旋转相机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆