title: Perspective projection view plane distance calculation confusion?
body: <p>I'm studying from a 3D computer graphics book trying to implement my own software renderer for educational purposes. Everything was going great until the book started talking about perspective projection, it got a bit confusing.</p>
  
  <p>The book (Tricks of the 3D Game Programming Gurus) was talking about computing <code>d</code>: the distance from the view point to the view plane. If we look at this scanned image from the book (I hope Andre doesn't mind because I tried contacting him asking but no reply):</p>
  
  <p><a href="https://i.stack.imgur.com/9CrAJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9CrAJ.png" alt="enter image description here"></a></p>
  
  <p>Well, here it's clear that the author meant 0.5 * Width besides the figure and not Width.</p>
  
  <p>Then he continues to say:</p>
  
  <pre><code>tan(θ) = opposite/adjacent = y/x, and in this case, y is the distance and x is related to the width.
  </code></pre>
  
  <p>Looking at the figure, I can't see how this is correct because the opposite of the angle <code>θ/2</code> is <code>W/2</code> and the adjacent is <code>d</code>. So:</p>
  
  <pre><code>tan(θ/2) = (W/2) / d =&gt;
  d * tan(θ/2) = (W/2) =&gt;
  d = (W/2) / tan(θ/2)
  </code></pre>
  
  <p>Am I wrong? am I missing anything? did the author mean something else?</p>
  
  <p>Any ideas/thoughts/explanations are appreciated.</p>
  
  <p><strong>EDIT:</strong> Although in the book's code it does 'work' when multiplication is used, but it's not correct. Because objects should get smaller the higher FOV value is used, that's why division is correct. But if multiplication is used the higher the FOV the bigger objects get. I think the author didn't notice this because he was using 90 degrees FOV angle most the times and <code>tan(90/2)=1</code> so it doesn't matter if we multiplied or divided.</p>