Pregunta

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

¿Fue útil?

Solución

This will do what you ask:

screen_x = (x/(|z|+1.0))*500;         
screen_y = (y/(|z|+1.0))*500;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top