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

CC BY-SA 4.0
2018-09-30T04:33:23.613Z
2018-10-03T21:50:00.827Z
2018-10-03T21:50:00.827Z
PolymorphismPrince
<p>I've watched the <a href="https://www.khanacademy.org/computing/pixar/rendering/rendering-2/a/rendering-lesson-brief" rel="nofollow noreferrer">Pixar In A Box, Maths of Rendering Tutorial</a> on Khan Academy. I've started writing a raytracing program and have come to the point where I must solve for <code>t</code> (the parameter for the parametric ray through the camera and a point on the view plane).</p>
<p>In the tutorial, this is done by simply substituting the parametric formula for each <code>x</code>, <code>y</code>, and <code>z</code> into the equation of the plane that the triangle lies on. This leaves a single unknown (<code>t</code>).</p>
<p>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:</p>
<p><span class="math-container">$$i=\frac{1}{t}C+tP$$</span></p>
<p>becomes simply:</p>
<p><span class="math-container">$$tP$$</span></p>
<p>Which makes for an easy solve. My question is when the camera is not at [0,0,0] should I:</p>
<ol>
<li>Calculate the coordinates of the plane relative to the camera. (So the camera acts as if it is [0,0,0]</li>
<li>Solve the equation as a quadratic. I'm still confused a bit about why this is quadratic in the first place. Could someone explain this? And which solution do I use?</li>
</ol>
<p>Of the two options, which is more acceptable for use in this community? Why? Is one more computationally efficient?</p>
<p><strong>Edit:</strong>
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:</p>
<p><span class="math-container">$$x(t) = \frac{1}{t}C_{x}+tP_{x}$$</span></p>
<p>But I realize now that is the same as:</p>
<p><span class="math-container">$$x(t)=C_{x}+t(P_{x}-C_{x})$$</span></p>
<p>Which is dramatically easier to solve.</p>
<p>So my final question is, which of the three is the most acceptable way to solve for t? I'm assuming the third one.</p>

CC BY-SA 4.0
2018-10-03T21:49:42.427Z
Yeah for like 5 days
PolymorphismPrince
<raytracing><3d><pixel-graphics><ray>
How to raytrace triangular faces when camera is not at origin?
PolymorphismPrince
# How to raytrace triangular faces when camera is not at origin?

(Asked by: username_0 on 2018-09-30)

I've watched the [Pixar In A Box, Maths of Rendering Tutorial](https://www.khanacademy.org/computing/pixar/rendering/rendering-2/a/rendering-lesson-brief) 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 by simply substituting 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:

$$i=\frac{1}{t}C+tP$$

becomes simply:

$$tP$$

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 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:

$$x(t) = \frac{1}{t}C\_{x}+tP\_{x}$$

But I realize now that is the same as:

$$x(t)=C\_{x}+t(P\_{x}-C\_{x})$$

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.

**Tags:** raytracing, 3d, pixel-graphics, ray

> **Comments:**
> **username_0**: Yeah for like 5 days  

---

## 1 answers

### Answer by username_0 on 2018-09-30. Score: 1 | Accepted answer

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.


---

