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
z into the equation of the plane that the triangle lies on. This leaves a single unknown (
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:
Which makes for an easy solve. My question is when the camera is not at [0,0,0] should I:
- Calculate the coordinates of the plane relative to the camera. (So the camera acts as if it is [0,0,0]
- 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.