title: sample random point in triangle
body: <p>Suppose you have an arbitrary triangle with vertices <code>A</code>, <code>B</code>, and <code>C</code>. <a href="http://www.cs.princeton.edu/~funk/tog02.pdf" rel="noreferrer">This paper (section 4.2)</a> says that you can generate a random point, <code>P</code>, uniformly from within triangle <code>ABC</code> by the following convex combination of the vertices:</p>
  
  <pre><code>P = (1 - sqrt(r1)) * A + (sqrt(r1) * (1 - r2)) * B + (sqrt(r1) * r2) * C
  </code></pre>
  
  <p>where <code>r1</code> and <code>r2</code> are uniformly drawn from <code>[0, 1]</code>, and <code>sqrt</code> is the square root function.</p>
  
  <p>How do you justify that the sampled points that are <em>uniformly distributed</em> within triangle <code>ABC</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As pointed out in a comment on <a href="https://math.stackexchange.com/questions/18686/uniform-random-point-in-triangle">the mathoverflow question</a>, 
  <a href="http://books.google.com/books?id=fvA7zLEFWZgC&amp;pg=PA24#v=onepage&amp;q&amp;f=false" rel="noreferrer">Graphical Gems discusses this algorithm</a>.</p>