title: Test if point inside angle
body: <p>In 2D plane there are four points: <code>O</code>, <code>A</code>, <code>B</code>, <code>P</code>.</p>
  
  <p><code>O</code>, <code>A</code>, <code>B</code> define an "angle", i.e. two rays, both originating at <code>O</code>, and one passing though <code>A</code>, while the other goes through <code>B</code>. How to tell on which "side" of the angle the point <code>P</code> lies, i.e. whether it is inside the space marked by the two rays?</p>
  
  <p>Note that the points are placed arbitrarily, i.e. the angle might have larger size than π.</p>
  
  <p>This is similar problem to determining which side of line a point lies, as discussed e.g. in <a href="http://www.faqs.org/faqs/graphics/algorithms-faq/" rel="nofollow">comp.graphics.algorithms FAQ</a> (Subject 1.02: How do I find the distance from a point to a line?), but here it is about two rays, instead of one line.</p>
  
  <p>Edit: Apologies for not stating it more explicitly: the angle is oriented, i.e. given <code>P</code>, it might lay on the right of <code>O</code>, <code>A</code>, <code>B</code>, but then it is on the left of <code>O</code>, <code>B</code>, <code>A</code>. Let's say the triangle <code>O</code>, <code>A</code>, <code>B</code> has clock-wise orientation. Again, it is similar to the "which side of line" problem: there it also matters whether the line passes though <code>A</code>, <code>B</code>, or <code>B</code>, <code>A</code>.</p>
  
  <p>An example:</p>
  
  <pre><code>        \                               \
           A                               B
            \   right                       \    left
     left    \                      right    \
              O------B----                    O------A----
  </code></pre>