1
\$\begingroup\$

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

\$\endgroup\$
0
\$\begingroup\$

"Let vec_AB_s = B_s - A-s be the vector from A_s to 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."

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Note that if you're using perspective projection, the movement of the point along the line on the screen and the movement of the corresponding point along the line in 3D space are not always linearly related. If the line recedes away from the camera, then evenly spaced points on the 3D line will be closer together on the screen at the far end of the line than they are at the near end. So you would need to transform lambda in this case. \$\endgroup\$ – DMGregory Mar 23 '20 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.