I am wondering how I can use perspective rendering to render a point onto a screen. An image showing perspective rendering:

Picture of perspective rendering

Say I have a 3d point (with x, y, and z coordinates), a point for the camera, and a lookat point for the camera (the point that the camera is facing), how can I use this to plot the point?

In pseudo-code:

cameraPosition = [10, 6, 5] // Camera coordinates
cameraLookat = [5, 6, 5] // Where the camera is looking
pointA = [5, 5, 5] // X, Y, and Z coordinates

// Perspective render it to get 2d-coordinates
pointA2D = perspectivePlot(pointA, cameraPosition, cameraLookat)

How would the perspectivePlot function work? From my understanding, it needs to plot a line between the cameraPosition and pointA, then find where the line intersects a plane that is 1 unit away from cameraPosition at the angle determined by cameraLookat.

How would this be done?

  • $\begingroup$ Are you saying you need help computing the intersection of a line and a plane? $\endgroup$
    – Wyck
    Dec 20, 2021 at 3:24
  • $\begingroup$ You can either find the ray-plane intersection or you can transform the point and plane to the camera's coordinate system (the plane corresponding to $z=1$) and then divide by $z$: $(x,y,z) \rightarrow (x/z, y/z)$ $\endgroup$
    – lightxbulb
    Dec 20, 2021 at 12:34


Your Answer

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

Browse other questions tagged or ask your own question.