透视投影:确定3D空间(x,y,z)中点的2D屏幕坐标(x,y) [英] Perspective Projection: determine the 2D screen coordinates (x,y) of points in 3D space (x,y,z)

查看:372
本文介绍了透视投影:确定3D空间(x,y,z)中点的2D屏幕坐标(x,y)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望确定3D空间(x,y,z)中点的2D屏幕坐标(x,y).

I wish to determine the 2D screen coordinates (x,y) of points in 3D space (x,y,z).

我要投影的点是用GPS坐标和海拔高度表示的现实点.

The points I wish to project are real-world points represented by GPS coordinates and elevation above sea level.

例如: 点(纬度:49.291882,长度:-123.131676,高度:14m)

For example: Point (Lat:49.291882, Long:-123.131676, Height: 14m)

摄像机的位置和高度也可以确定为x,y,z点.我还具有摄像机的方位角(罗盘度),倾斜度(水平线以上/以下)和横摇角(围绕z轴).

The camera position and height can also be determined as a x,y,z point. I also have the heading of the camera (compass degrees), its degree of tilt (above/below horizon) and the roll (around the z axis).

我没有3D编程的经验,因此,我阅读了透视投影的主题,并了解到它需要矩阵,变换等知识-目前所有这些都使我感到困惑.

I have no experience of 3D programming, therefore, I have read around the subject of perspective projection and learnt that it requires knowledge of matrices, transformations etc - all of which completely confuse me at present.

有人告诉我OpenGL可能用于构建真实点的3D模型,设置相机方向并检索3D点的2D坐标.

I have been told that OpenGL may be of use to construct a 3D model of the real-world points, set up the camera orientation and retrieve the 2D coordinates of the 3D points.

但是,我不确定使用OpenGL是否是解决此问题的最佳解决方案,即使我也不知道如何创建模型,设置相机等

However, I am not sure if using OpenGL is the best solution to this problem and even if it is I have no idea how to create models, set up cameras etc

有人可以建议解决我问题的最佳方法吗?如果OpenGL是可行的解决方案,那么如果有任何区别,我将不得不使用OpenGL ES.哦,无论我选择哪种解决方案,都必须迅速执行.

Could someone suggest the best method to solve my problem? If OpenGL is a feasible solution i'd have to use OpenGL ES if that makes any difference. Oh and whatever solution I choose it must execute quickly.

推荐答案

这是一个非常笼统的答案.假设相机位于(Xc,Yc,Zc),并且您要投影的点是P =(X,Y,Z).相机到要投影到的2D平面的距离为F(因此,该平面的方程为Z-Zc = F).投影到平面上的P的2D坐标为(X',Y').

Here's a very general answer. Say the camera's at (Xc, Yc, Zc) and the point you want to project is P = (X, Y, Z). The distance from the camera to the 2D plane onto which you are projecting is F (so the equation of the plane is Z-Zc=F). The 2D coordinates of P projected onto the plane are (X', Y').

然后,非常简单:

X'=((X-Xc)*(F/Z))+ Xc

X' = ((X - Xc) * (F/Z)) + Xc

Y'=((Y-Yc)*(F/Z))+ Yc

Y' = ((Y - Yc) * (F/Z)) + Yc

如果您的相机是原点,那么它可以简化为:

If your camera is the origin, then this simplifies to:

X'= X *(F/Z)

X' = X * (F/Z)

Y'= Y *(F/Z)

Y' = Y * (F/Z)

这篇关于透视投影:确定3D空间(x,y,z)中点的2D屏幕坐标(x,y)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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