# Unprojeting a line on the screen

I have a line connecting two points of my model. I see a projection of this line on my screen and a want to map a point of that projection to the corresponding point in my model PoV.

Let A = (x_a, y_a, z_a, 1.) and B=(x_b, y_b, z_b, 1.) be the coordinates of two points of my line in the model PoV.

Let M,V and P be the model, view and projection matrices. Let A_s = NDC_to_screen(P*V*M*A) and B_s = NDC_to_screen(P*V*M*B) be the coordinates of A and B projections on my screen (assume that those two points are distinct). Let vec_AB_s = B_s - A-s be the vector from A_sto B_s and let C_s = A_s + lambda_s * vec_AB_s be a point that lie on the line's projection on my screen.

How can I get the 3D coordinates of C so that C_s = NDC_to_screen(P*V*M*C) ? Something that would be usefull for me would be to have it in the form C = A + lambda * vec_AB

Since the line is being projected onto the screen, then lambda will not change as a ratio between points (assuming your lambda is 0 to 1.0).Simply use the lambda and apply to A and B. C = A + lambda * vec_AB like you stated in your post.