I've watched the Pixar In A Box, Maths of Rendering Tutorial on Khan Academy. I've started writing a raytracing program and have come to the point where I must solve for t (the parameter for the parametric ray through the camera and a point on the view plane).

In the tutorial, this is done through simply substituting each the parametric formula for each x, y, and z into the equation of the plane that the triangle lies on. This leaves a single unknown (t).

However, in all the examples and exercises that are given by the tutorial the camera is located at [0,0,0]. As I'm sure you'll understand, this is in many cases unrealistic. Because the camera is at 0, they simplify as follows:

becomes simply:

Which makes for an easy solve. My question is when the camera is not at [0,0,0] should I:

  1. Calculate the coordinates of the plane relative to the camera. (So the camera acts as if it is [0,0,0]
  2. Solve the equation as a quadratic. I'm still confused a bit about why this is a quadratic in the first place. Could someone explain this? And which solution do I use?

Of the two options, which is more acceptable for use in this community? Why? Is one more computationally efficient?

Edit: I think I have found a solution as follows: The parametric equation (which is effectively just a weighted average) is represented like this in the tutorial:

But I realize now that is the same as:

Which is dramatically easier to solve.

So my final question is, which of the three is the most acceptable way to solve for t? I'm assuming the third one.

  • $\begingroup$ Have you been misreading $1-t$ as $1/t$ this whole time? $\endgroup$ – Rahul Oct 3 '18 at 6:44
  • 1
    $\begingroup$ Yeah for like 5 days $\endgroup$ – PolymorphismPrince Oct 3 '18 at 21:49

Wow I'm stupid, the whole problem was I thought it was 1/t and it is actually 1-t in parametric form. Hope this helps someone anyway.


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.