本文介绍了相机间距/偏向方向矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要做的是从我的相机投射光线。我知道相机的x,y和z坐标,以及它的俯仰和偏航。我需要计算它的方向向量,这样我就可以将它传递给我的光线追踪算法。
What I'm trying to do is cast a ray from my camera. I know the camera's x, y and z coordinates, as well as its pitch and yaw. I need to calculate its direction vector so I can pass it to my raytracing algorithm.
摄像机的向上矢量是(0,1,0)。从相机的角度来看,Pitch正在向上和向下看。
The camera's up vector is (0, 1, 0). "Pitch", from the perspective of the camera, is looking up and down.
(我更愿意不使用矩阵,但如果必须,我会这样做)
(I would prefer to not use matrices, but I will if I have to)
推荐答案假设您的坐标系已设置为满足以下条件:
Assuming that your coordinate system is set up such that the following conditions are met:
(pitch, yaw) -> (x, y, z) (0, 0) -> (1, 0, 0) (pi/2, 0) -> (0, 1, 0) (0, -pi/2) -> (0, 0, 1)这将计算(x,y,z):
This will calculate (x, y, z):
xzLen = cos(pitch) x = xzLen * cos(yaw) y = sin(pitch) z = xzLen * sin(-yaw)更多推荐
相机间距/偏向方向矢量
发布评论