简体   繁体   中英

perspective projection of line segments

when i cast 3d point on 2d screen i use

    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

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?

much tnx for answer

This will do what you ask:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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