简体   繁体   English

线段的透视投影

[英]perspective projection of line segments

when i cast 3d point on 2d screen i use 当我在2D屏幕上投射3D点时,我使用

    if( z > 1.0 )                   
     {
      screen_x = (x/z)*500;         
      screen_y = (y/z)*500;
     }

this is i just can throw away all 'rear' points and scale front points 这就是我可以扔掉所有“后方”点并扩展前端点的方法

but now i need to cast/projects line segments - to 2d points then i can draw it as 2d line 但是现在我需要将线段投射/投影到2d点,然后将其绘制为2d线

some cases would be that one point of line segment is in front space but the other in rear space - how to cast the rear space point so I could draw it as a 2d line? 在某些情况下,线段的一个点在前部空间中,而另一点在后部空间中-如何投射后部空间点,以便可以将其绘制为2d线?

much tnx for answer 很多答案

This will do what you ask: 这将满足您的要求:

screen_x = (x/(|z|+1.0))*500;         
screen_y = (y/(|z|+1.0))*500;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM