如何将 3D 平面中的点映射到屏幕平面
我已经分配了使用 C 语言中的简单图形将 3D 空间中的对象投影到 2D 平面中的任务。问题是,将一个立方体放置在固定的 3D 空间中,并且将相机放置在坐标为x,y,z 并且相机正在查看原点,即 0,0,0。现在我们必须将立方体顶点投影到相机平面上。
我继续执行以下步骤
步骤 1:我找到平面 aX+bY+cZ+d=0 的方程,该方程垂直于从相机位置到原点绘制的线。
步骤2:找到在上述步骤中获得的立方体的每个顶点到平面的投影。
现在我想将步骤 2 中在平面 aX+bY+cZ+d=0 中投影得到的顶点位置映射到我的屏幕平面中。
谢谢,
我不认为让 z 坐标等于 0 会引导我进行实际的映射。所以有任何帮助可以解决这个问题。
I have given an assignment of to project a object in 3D space into a 2D plane using simple graphics in C. The question is that a cube is placed in fixed 3D space and there is camera which is placed in a position whose co-ordinates are x,y,z and the camera is looking at the origin i.e. 0,0,0. Now we have to project the cube vertex into the camera plane.
I am proceeding with the following steps
Step 1: I find the equation of the plane aX+bY+cZ+d=0 which is perpendicular to the line drawn from the camera position to the origin.
Step 2: I find the projection of each vertex of the cube to the plane which is obtained in the above step.
Now I want to map those vertex position which i got by projection in step 2 in the plane aX+bY+cZ+d=0 into my screen plane.
thanks,
I don't think that by letting the z co-ordinate equals zero will lead me to the actual mapping. So any help to figure out this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过两个简单的步骤来完成此操作:
旋转),使得相机在该系统中的坐标为 x=y=z=0 并且立方体的平移 z 为 > 0.
这几乎就是 3D 游戏中的做法。如果使用立方体顶点坐标,则会将其侧面投影到屏幕上。然后,您可以实体填充生成的二维形状或对其进行纹理映射。但为此,您必须首先弄清楚哪些面没有被其他面遮挡(当然,除非您使用一种称为 z 缓冲的技术)。不过,对于简单的线框演示,您不需要它,只需在投影顶点之间绘制直线即可。
You can do that in two simple steps:
rotation), such that the camera's own coordinates in that system are x=y=z=0 and the cube's translated z's are > 0.
This is pretty much how it is done in 3d games. If you use cube vertex coordinates, then you get projections of its sides onto the screen. You may then solid-fill the resultant 2d shapes or texture-map them. But for that you'll have to first figure out which sides are not obscured by others (unless, of course, you use a technique called z-buffering). You don't need that for a simple wire-frame demo, though, just draw straight lines between the projected vertices.