<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
               "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
  <!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../../../comsci/css/s011.css"/>
<link rel='SHORTCUT ICON' href='../../../comsci/images/FrameHome.ico' />
<style type="text/css">
</style>
<title> Basic Vector Calculus and Geometry </title>
</head>

<body>



<div class="message_right">
  <a href="http://validator.w3.org/check/referer">
    <img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid
	XHTML 1.1!" height="31" width="88" />
  </a>

  <a href="http://jigsaw.w3.org/css-validator/">
    <img style="width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
  </a>
  <br/>
  Created 2003-01-01 &nbsp; Modified 
<!--UPDATE_DATE_MODIFIED-->
<!--UPDATE_DATE_BEGIN-->
2007-02-13
<br/>
<a href="mailto:chelton.evans@yahoo.com">Chelton Evans</a>
<!--UPDATE_DATE_END-->
</div>


<h1> 
<a href="geom.html"> <img alt="proj" src="../../../comsci/images/compgeom.png" /></a>
 Basic Vector Calculus and Geometry 
<a href="../../../../index.html">
<img alt="home" src="../../../comsci/images/Frame.gif" /> </a>
</h1>

<p>
<a href="#Anticlockwise_Point_Ordering_Test">
  Anticlockwise Point Ordering Test</a><br/>
<a href="#Area_of_Triangle">Area of Triangle</a><br/>

<a href="#Barycentric_Coordinates">Barycentric Coordinates</a><br/>
<a href="#Bisecting_an_Angle_with_Ratios"> Bisecting an Angle with Ratios </a><br/>
<a href="#Line_and_Plane_Intersection">Line and Plane Intersection</a> <br/>
<a href="#Line_and_Cylinder_Intersection">
  Line and Cylinder Intersection</a><br/>
<a href="#Line_and_Line_Intersection">Line and Line Intersection</a><br/>
  &nbsp; &nbsp; 
  <a href="#Line_Segment_and_Line_Segment">Line Segment and Line Segment</a><br/>

<a href="#Line_and_Simplex_Intersection">
  Line and Simplex Intersection</a><br/>
<a href="#Orthogonal_Projection">Orthogonal Projection</a><br/>

<a href="#Point_to_Line_Distance_Minimized">Point to Line Distance Minimized </a><br/>

<a href="#Point_to_Plane_Distance_Minimized">Point to Plane Distance Minimized</a><br/>
<a href="#Polygon_Area">Polygon Area</a><br/>

<a href="#Ray_and_Box">Ray and Box</a><br/>
<a href="#Rotating_a_Plane">Rotating a Plane</a><br/>
<a href="#Reflection_Theory">Reflection Theory</a><br/>


<a href="#Volume_of_Tetrahedron">Volume of Tetrahedron</a><br/>

<a href="#Zero_Test">Zero Test</a><br/>
<a href="#References">References</a>

</p>


<div class="float25">
<a id="Line_and_Plane_Intersection"> </a>
<h2> Line and Plane Intersection </h2>

<p class="equ">
<math xmlns="&mathml;">
  <mi>x</mi>
  <mo>=</mo>
  <msubsup>
    <mi>x</mi>
    <mrow>
      <mi>0</mi>
    </mrow>
    <mrow>
    </mrow>
  </msubsup>
  <mo>+</mo>
  <mi>d</mi>
  <mi>t</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>w</mi>
  <mo>&CenterDot;</mo>
  <mi>x</mi>
  <mo>=</mo>
  <mi>c</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mo>=</mo>
  <mfrac>
    <mrow>
      <mi>c</mi>
      <mo>-</mo>
      <mi>w</mi>
      <mo>&CenterDot;</mo>
  <msubsup>
    <mi>x</mi>
    <mrow>
      <mi>0</mi>
    </mrow>
    <mrow>
    </mrow>
  </msubsup>
    </mrow>
    <mrow>
      <mi>w</mi>
      <mo>&CenterDot;</mo>
      <mi>d</mi>
    </mrow>
  </mfrac>
  
</math>

</p>

</div>

<div class="float25">
<a id="Line_and_Cylinder_Intersection"> </a>
<h2> Line and Cylinder Intersection </h2>

<p class="equ">
<math xmlns="&mathml;">
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>1</mi>
  </munderover>

  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi>&nbsp;2</mi>
    </mrow>
  </msubsup>
  <mo>=</mo>
  <mi>r</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>x</mi>
  <mo>=</mo>
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>2</mi>
  </munderover>
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
</math>

<br/>

<math xmlns="&mathml;">
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <mo>=</mo>
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>0i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <mo>+</mo>
  <mi>t</mi>
  <msubsup>
    <mo>d</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
</math>
</p>

<p class="equ">
<math xmlns="&mathml;">
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>1</mi>
  </munderover>

  <mo>(</mo>
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>0i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <mo>+</mo>
  <mi>t</mi>
  <msubsup>
    <mo>d</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>

  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>=</mo>
  <mi>r</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>1</mi>
  </munderover>
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>0i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>+</mo>
  <mi>t</mi>
  <mi>2</mi>
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>1</mi>
  </munderover>
  <msubsup>
    <mo>x</mo>
    <mrow>
      <mi>0i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <msubsup>
    <mo>d</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <mo>+</mo>
  <mi>t</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <munderover>
    <mo>&Sum;</mo>
    <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>1</mi>
  </munderover>
  <msubsup>
    <mo>d</mo>
    <mrow>
      <mi>i</mi>
    </mrow>
    <mrow>
      <mi></mi>
    </mrow>
  </msubsup>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>=</mo>
  <mi>r</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
</math>
</p>

<p> Solve quadratic. </p>

</div>


<div class="float25">
<a id="Line_and_Line_Intersection"></a>
<h2>Line and Line Intersection</h2>

<p>
After studying maths at school I did not think there was much to
 line to line intersections since we would see it as simply solving a two by two
 matrix.  But after looking at a few algorithms from a computational perspective 
 things changed for me and I became more interested.
</p>

<p>
What is said of intersection tests is very general - if they are going to be done millions ++ times
 then optimize them.  Avoid (or minimize) divisions (and perhaps minimize comparisions???).  If only the intersection
 point need be calculated then there is no need to calculate the intersection point in the second line.
</p>

<p class="equ">
Consider two lines defined by two points on the line. Equate the two
 lines as they are equal at their intersection. <br/>


<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>s</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>

</math>

<br/>

<math xmlns="&mathml;">
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>t</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
</math>

</p>

<p class="equ">
Let <br/>

<math xmlns="&mathml;">
  <mi>a</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>b</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>

</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>s</mi>
  <mi>a</mi>
  <mo>=</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>t</mi>
  <mi>b</mi>
</math>

</p>

<p class="equ">
Find &nbsp; 
<math xmlns="&mathml;">
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

 &nbsp; such that &nbsp; 

<math xmlns="&mathml;">
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&CenterDot;</mo>
  <mi>a</mi>
  <mo>=</mo>
  <mi>0</mi>
</math>

<br/>

Find &nbsp; 
<math xmlns="&mathml;">
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

 &nbsp; such that &nbsp; 

<math xmlns="&mathml;">
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&CenterDot;</mo>
  <mi>b</mi>
  <mo>=</mo>
  <mi>0</mi>
</math>

</p>

</div>

<div class="float25">

<p>I am calling the vector at right angles to a the inverse of a.  In 2D simply swap 
 the components around and multiply one of the components by negative 1. Also I will
 assume multiplication to be the dot product so the algebra becomes really simple.
</p>

<p class="equ">
Solve for t<br/>

<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>s</mi>
  <mi>a</mi>
  <mo>)</mo>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>(</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>t</mi>
  <mi>b</mi>
  <mo>)</mo>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>=</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>+</mo>
  <mi>t</mi>
  <mi>b</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mo>=</mo>
  <mfrac>
    <mrow>

  <mo>(</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mi>b</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
  </mfrac>
</math>




</p>









<p class="equ">
Solve for s<br/>

<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>s</mi>
  <mi>a</mi>
  <mo>)</mo>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>(</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>t</mi>
  <mi>b</mi>
  <mo>)</mo>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>+</mo>
  <mi>s</mi>
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

  <mo>=</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>s</mi>
  <mo>=</mo>
  <mfrac>
    <mrow>

  <mo>(</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
  </mfrac>
</math>

</p>

<p>If both points need to be calculated a further optimization is to eliminate one of the divisions.</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>-</mo>
  <mi>b</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>

 Let &nbsp; 

<math xmlns="&mathml;">
  <mi>c</mi>
  <mo>=</mo>

  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
  <mi>b</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
    </mrow>
  </mfrac>
</math> 
<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mo>=</mo>
  <mi>c</mi>
  <mo>(</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

<br/>


<math xmlns="&mathml;">
  <mi>s</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>c</mi>
  <mo>(</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

</p>

</div>

<div class="spacer" />

<div class="float25">
<a id="Line_Segment_and_Line_Segment"></a>
<h3>Line Segment to Line Segment</h3>

<p>If we are only concerned with two line segments intersecting then the division can be
 eliminated.</p>

<p class="equ">
Let &nbsp; 

<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>q</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>k</mi>
</math>

</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>s</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>


<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>


  <mfrac>
    <mrow>

  <mo>-</mo>
  <mi>k</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
  </mfrac>



  <mo>&leq;</mo>
  <mi>1</mi>
</math>


</p>


<p class="equ">

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>t</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>

  <mfrac>
    <mrow>

  <mi>k</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mi>b</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
  </mfrac>

  <mo>&leq;</mo>
  <mi>1</mi>
</math>

</p>



<p class="equ">
Case &nbsp; 

<math xmlns="&mathml;">
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&lt;</mo>
  <mi>0</mi>
</math>

<br/>

Let &nbsp; 

<math xmlns="&mathml;">
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>-</mo>
  <mi>&alpha;</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>&alpha;</mi>
  <mo>&gt;</mo>
  <mi>0</mi>
</math>

</p>

<p class="equ">

Consider when &nbsp; 

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>s</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>

  <mfrac>
    <mrow>

  <mo>-</mo>
  <mi>k</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mo>-</mo>
  <mi>&alpha;</mi>

    </mrow>
  </mfrac>

  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>


<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>k</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math>


</p>


<p class="equ">


Consider when &nbsp; 

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>t</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>


<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>

  <mfrac>
    <mrow>

  <mi>k</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>

    </mrow>
    <mrow>

  <mi>&alpha;</mi>

    </mrow>
  </mfrac>

  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>


<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>k</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math>

</p>

</div>

<div class="float25">

<p>So if these conditions are satisfied then the two line segments are intersecting.
 I will repeat the results without the derivation for easy reference.
</p>

<p class="equ">
For the case &nbsp; 

<math xmlns="&mathml;">
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&lt;</mo>
  <mi>0</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>&alpha;</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

 &nbsp; and 
<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>k</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math> <br/>



<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>k</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math>

<br/>


 must be true.



</p>


<p class="equ">
For the case &nbsp; 

<math xmlns="&mathml;">
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&gt;</mo>
  <mi>0</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>&alpha;</mi>
  <mo>=</mo>
  <mi>a</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
</math>

 &nbsp; and 
<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mo>-</mo>
  <mi>k</mi>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math> <br/>



<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mo>-</mo>
  <mi>k</mi>
  <mi>a</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>&leq;</mo>
  <mi>&alpha;</mi>
</math>

<br/>


 must be true.



</p>


</div>



<div class="float25">
<a id="Orthogonal_Projection"> </a>
<h2> Orthogonal Projection </h2>

<p> Given a set of orthogonal vectors
<math xmlns="&mathml;">
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>

, express 

<math xmlns="&mathml;">
  <mi>c</mi>
</math>

 as 

<math xmlns="&mathml;">
  <mo>&Sum;</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>
.
</p>

<p class="equ">
Let <br/>
<math xmlns="&mathml;">
  <mi>c</mi>
  <mo>=</mo>
  <mo>&Sum;</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mo>=</mo>
  <mo>[</mo>
  <mi>i</mi>
  <mo>==</mo>
  <mi>k</mi>
  <mo>]</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mi>c</mi>
  <mo>=</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mo>&Sum;</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mi>c</mi>
  <mo>=</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mo>=</mo>
  <mfrac>
    <mrow>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mo>&CenterDot;</mo>
  <mi>c</mi>

    </mrow>
    <mrow>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>
  <mo>&CenterDot;</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>k</mi></mrow>
  </msub>

    </mrow>
  </mfrac>
</math>

</p>

</div>

<div class="float25">
<a id="Reflection_Theory"></a>
<h2> Reflection Theory </h2>

<p>
A beam of light reflects of a surface. 
 Let 

<math xmlns="&mathml;">
  <mi>n</mi> 
</math> 

 be the normal to the surface and

<math xmlns="&mathml;">
  <mi>c</mi>
</math> 
 the vector reflecting off the surface.

 By resolving 

<math xmlns="&mathml;">
  <mi>c</mi>
</math>
 in terms of orthogonal vectors where

<math xmlns="&mathml;">
  <mi>n</mi>
</math>
 is one of these vectors the problem is
 trivially solved.
</p>

<p class="equ">
Let <br/>

<math xmlns="&mathml;">
  <mi>c</mi>
  <mo>=</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>n</mi>
  <mo>+</mo>
  <msubsup>
    <mo>&Sum;</mo>
    <mrow>
      <mi>1</mi>
    </mrow>
    <mrow>
      <mi>n</mi><mo>-</mo><mi>1</mi>
    </mrow>
  </msubsup>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>

<br/>

Let 

<math xmlns="&mathml;">
  <mi>c'</mi>
</math>

 be the reflected ray. <br/>

<math xmlns="&mathml;">
  <mi>c'</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>n</mi>
  <mo>+</mo>
  <msubsup>
    <mo>&Sum;</mo>
    <mrow>
      <mi>1</mi>
    </mrow>
    <mrow>
      <mi>n</mi><mo>-</mo><mi>1</mi>
    </mrow>
  </msubsup>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>

</p>

</div>


<div class="float25">
<a id="Area_of_Triangle"> </a>
<h2> Area of Triangle </h2>

<p class="equ">
<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mi>base</mi>
  <mo>.</mo>
  <mi>height</mi>
</math>
</p>


<p class="equ">
<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mi>b</mi>
  <mi>c</mi>
  <mi>sin</mi>
  <mi>A</mi>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mi>b</mi>
  <mi>c</mi>
  <mo>(</mo>
  <mi>b</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mi>c</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>-</mo>
  <mo>(</mo>
  <mi>b</mi>
  <mo>&CenterDot;</mo>
  <mi>c</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow>
          <mi>1</mi>
        </mrow>
        <mrow>
          <mi>2</mi>
        </mrow>
      </mfrac>
    </mrow>
  </msup>
</math>

<br/>

<math xmlns="&mathml;">
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mo>|</mo>
  <mi>b</mi>
  <mo>&times;</mo>
  <mi>c</mi>
  <mo>|</mo>
</math>

</p>

<p>With matrices and the determinant. </p>

<p class="equ">

<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mo>|</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>|</mo>
</math>

</p>



<p>The area between a line segment and the x-axis.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>.</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mo>(</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>(</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>
  <mo>(</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mo>(</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
</math>

</p>

<p>Linear combination of trapezoids.  Really the area enclosed
 by the lines and the axis added and subtracted.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>2</mi></mrow>
  </mfrac>
  <mo>|</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>(</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>+</mo>

  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>(</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>+</mo>

  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>(</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>

  <mo>|</mo>
  

</math>

</p>


<a id="Volume_of_Tetrahedron"> </a>
<h2> Volume of Tetrahedron</h2>

<p class="equ">

<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>6</mi></mrow>
  </mfrac>
  <mo>|</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>|</mo>
</math>

</p>



 
</div>

<div class="float25">
<a id="Point_to_Line_Distance_Minimized"></a>
<h2>Point to Line Distance Minimized </h2>

<p>
I picked up this technique in linear algebra where the
 teacher said it was possible to use matrix algebra to
 solve these sort of problems. There was no need for use
 to use it, maths is egalitarian.
</p>

<p>
Now in the comsci literature you do not see this or  
 much in maths because no one can argue with the most 
 primitive variables because it is correct
 (eg Newton published Principa with geometry, not his calculus).  
 So instead
 of promoting a better way of doing things we avoid any
 arguments by doing the job in a sub-optimal way.
 Conservatism is a killer.
</p>

<p> In this algebra do not divide. For the moment consider
 the multiplication operator defined as a dot product.
 For a single variable and vector multiplication just
 multiply the variable in each of the vectors components.
</p>

<p class="equ">
  Let &nbsp; 
<math xmlns="&mathml;">
  <mi>P</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
</math>
 &nbsp; and &nbsp; 
<math xmlns="&mathml;">
  <mi>P</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>

 &nbsp; be two points defining a line with direction
 from 1 to 2. <br/>

 Let <br/>
<math xmlns="&mathml;">
  <mo>(</mo>
  <mo>-</mo>
  <mi>P</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>P</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>t</mi>
  <mo>+</mo>
  <mi>P</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>A</mi>
  <mi>t</mi>
  <mo>+</mo>
  <mi>C</mi>
</math>

<br/>
<math xmlns="&mathml;">
  <mi>X</mi>
</math>
 &nbsp; be the point to the line to be minimized. 

</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>d</mi>
  <mo>=</mo>
  <mo>(</mo>
  <mi>A</mi>
  <mi>t</mi>
  <mo>+</mo>
  <mi>C</mi>
  <mo>-</mo>
  <mi>X</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
</math>

</p>

<p>Consider the distance between the two points. 
 Take the derivative in t and setting to zero for 
 minimum t. </p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>d'</mi>
  <mo>=</mo>
  <mi>2</mi>
  <mo>(</mo>
  <mi>A</mi>
  <mi>t</mi>
  <mo>+</mo>
  <mi>C</mi>
  <mo>-</mo>
  <mi>X</mi>
  <mo>)</mo>  
  <mi>A</mi>
</math>

<br/>
<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>=</mo>
  <mi>A</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mi>t</mi>
  <mo>+</mo>
  <mo>(</mo>
  <mi>C</mi>
  <mo>-</mo>
  <mi>X</mi>
  <mo>)</mo>  
  <mi>A</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mi>A</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>(</mo>
  <mi>X</mi>
  <mo>-</mo>
  <mi>C</mi>
  <mo>)</mo>  
  <mi>A</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mo>=</mo>
  <mfrac>
    <mrow>
  <mo>(</mo>
  <mi>X</mi>
  <mo>-</mo>
  <mi>C</mi>
  <mo>)</mo>  
  <mi>A</mi>
    </mrow>
    <mrow>
  <mi>A</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
    </mrow>
  </mfrac>

</math>

</p>


</div>

<div class="float25">
<a id="Bisecting_an_Angle_with_Ratios"> </a>
<h2>Bisecting an Angle with Ratios</h2>

<img src="diagg00101.png" alt="diagg00101.png" />

<p class="equ">
<math xmlns="&mathml;">
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mfrac>
    <mrow><mi>b</mi></mrow>
    <mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow>
  </mfrac>
  <mo>+</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mfrac>
    <mrow><mi>a</mi></mrow>
    <mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow>
  </mfrac>
  
</math>

</p>

<p>
For some reason I hate angles.  Some people say hate is
 a very strong word.  Despite the ancients propensity
 for geometry very few of them actually used algebra to
 do it.  
</p>

<p>
I made the error of mistaking the midpoint for this point.
 By using this representation you can turn a problem involving
 bisection to one with algebra. For example calculating
 the inscribed circle/sphere, 
see <a href="g027.xml#The_Inner_Circle">The Inner Circle</a>.
</p>


</div>

<div class="float25">
<a id="Point_to_Plane_Distance_Minimized"></a>
<h2>Point to Plane Distance Minimized</h2>

<p>Let multiplication of vectors be a dot product. Use the
 result that the minimum distance is perpendicular to the
 plane.</p>

<p class="equ">
Let 
<math xmlns="&mathml;">
  <mi>A</mi>  
</math>
 and 
<math xmlns="&mathml;">
  <mi>B</mi>  
</math>
 be arms of the plane at the origin. <br/>
<math xmlns="&mathml;">
  <mi>P</mi>  
</math> 
 be a point on the plane. <br/>

Let 
<math xmlns="&mathml;">
  <mi>W</mi>  
</math> 
 be the point being minimized for.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>N</mi>  
  <mo>=</mo>
  <mi>A</mi>
  <mo>&times;</mo>
  <mi>B</mi>
</math>
<br/>
<math xmlns="&mathml;">
  <mi>N</mi>  
  <mi>X</mi>
  <mo>=</mo>
  <mi>c</mi>
</math>
 defines a plane
<br/>
 where 
<math xmlns="&mathml;">
  <mi>c</mi>  
  <mo>=</mo>
  <mi>N</mi>
  <mi>P</mi>
</math>

</p>

<p class="equ"> Let 
<math xmlns="&mathml;">
  <mi>N</mi>  
  <mi>t</mi>
  <mo>+</mo>
  <mi>W</mi>
</math>
 be equation of line perpendicular to the
 plane and passing through 
<math xmlns="&mathml;">
  <mi>W</mi>  
</math>.
</p>

<p>Find the line and planes intersection point.</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>N</mi>  
  <mo>(</mo>
  <mi>N</mi>
  <mi>t</mi>
  <mo>+</mo>
  <mi>W</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mi>c</mi>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>t</mi>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>d</mi><mo>-</mo><mi>N</mi><mi>W</mi></mrow>
    <mrow><mi>N</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
    </mrow>
  </mfrac>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>N</mi><mo>(</mo><mi>P</mi><mo>-</mo><mi>W</mi><mo>)</mo></mrow>
    <mrow><mi>N</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
    </mrow>
  </mfrac>

</math>

</p>

<p>Now to get a distance function from the point to
 the point on the plane let d be the general distance
 function. Assume some nice properties of d such as
 subtracting a constant between the two components,
 and taking out a common factor.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>d</mi>  
  <mo>(</mo>
  <mi>W</mi>
  <mo>,</mo>
  <mi>N</mi>
  <mfrac>
    <mrow><mi>N</mi><mo>(</mo><mi>P</mi><mo>-</mo><mi>W</mi><mo>)</mo></mrow>
    <mrow><mi>N</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
    </mrow>
  </mfrac>
  <mo>+</mo>
  <mi>W</mi>
  <mo>)</mo>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>d</mi>  
  <mo>(</mo>
  <mi>0</mi>
  <mo>,</mo>
  <mi>N</mi>
  <mfrac>
    <mrow><mi>N</mi><mo>(</mo><mi>P</mi><mo>-</mo><mi>W</mi><mo>)</mo></mrow>
    <mrow><mi>N</mi>
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
    </mrow>
  </mfrac>
  <mo>)</mo>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>N</mi>  
  <msup>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msup>
  <mi>d</mi>
  <mo>=</mo>
  <mi>d</mi>  
  <mo>(</mo>
  <mi>0</mi>
  <mo>,</mo>
  <mi>N</mi>
  <mo>(</mo>
<mi>N</mi><mo>(</mo><mi>P</mi><mo>-</mo><mi>W</mi><mo>)</mo>
  <mo>)</mo>
  <mo>)</mo>
</math>

</p>

<p>From here we can get the distance from a point without
 the square root by realizing a component and squaring it,
 then sum these.
</p>

<p>Another thing we can get is signed distance. Because
 if a dot product is used for multiplication then each
 components
<math xmlns="&mathml;">
<mi>N</mi><mo>(</mo><mi>P</mi><mo>-</mo><mi>W</mi><mo>)</mo>
</math>
 tests positive when the point is on the other side of
 the half space. As 
<math xmlns="&mathml;">
  <mi>W</mi>  
</math> 
 goes nearer to the plane 
<math xmlns="&mathml;">
  <mi>NW</mi>  
</math> 
 approaches
<math xmlns="&mathml;">
  <mi>c</mi>  
</math> 
 and 
<math xmlns="&mathml;">
  <mi>NP</mi><mo>-</mo><mi>NW</mi>  
  <mo>=</mo>
  <mi>c</mi><mo>-</mo><mi>NW</mi>
</math> 

becomes smaller in magnitude.
</p>

<p>For me this was surprising. 
The point is that
 you can use signed distance and save a dot product.
 Further it will indicate which side of the plane
 the point is on.
</p>




 


</div>


<div class="float25">
<a id="Anticlockwise_Point_Ordering_Test"></a>
<h2> Anticlockwise Point Ordering Test </h2>

<h3>Point Ordering Test with Determinants</h3>

<p class="equ">
<math xmlns="&mathml;">

<mfenced open='[' close=']'>
  <mtable>
    <mtr>
       <mtd>

  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>

       </mtd>
       <mtd>

  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>

       </mtd>
       <mtd><mi>1</mi></mtd>

    </mtr>
    <mtr>
       <mtd>

  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

       </mtd>
       <mtd>

  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

       </mtd>
       <mtd><mi>1</mi></mtd>
    </mtr>


    <mtr>
       <mtd>

  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>

       </mtd>
       <mtd>

  <mi>y</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>

       </mtd>
       <mtd><mi>1</mi></mtd>
    </mtr>



  </mtable>
</mfenced>
<mo>&gt;</mo>
<mi>0</mi>

</math>
</p>

<p>This may generalize in N-dimensions. I suspect the equality operator 
 alternates. 
</p>

<a id="Anticlockwise_Point_Ordering_Test_with_Half_Spaces"></a>
<h3>Anticlockwise Point Ordering Test with Half Spaces</h3>

<p>A simpler test is with a half space test. 
 This generalizes for simplexes in any dimensions.
</p>

<p>
 Only one halfspace needs to be tested.
 For if the simplex winding breaks the opposite point 
 will be visible.
</p>

<img src="diagg00102.png" alt="diagg00102.png" />



<p>
If the simplex is degenerate then test for a zero
 dot product.
</p>



</div>

<div class="float25">
<a id="Zero_Test"></a>
<h2>Zero Test</h2>

<p>
Numerical instability is something everyone knows but
 is addressed differently by different people.  I worked on
 tessellation algorithms for quite some time before I hit a real
 problem with doubles that the inbuilt rounding algorithms 
 missed.
</p>

<p class="equ">
Let zero be a small positive number.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>x</mi>
  <mo>==</mo>
  <mi>0</mi>
  <mo>)</mo>
  <mo>=</mo>
</math>
<br/>
 &nbsp; &nbsp; 

<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>0</mi>
  <mo>&lt;</mo>
  <mi>x</mi>
  <mo>+</mo>
  <mi>zero</mi>
  <mo>&lt;</mo>
  <mi>zero</mi>
  <mo>+</mo>
  <mi>zero</mi>
  <mo>)</mo>
</math>

<br/>
or <br/>
 &nbsp; &nbsp; 

<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>0</mi>
  <mo>&lt;</mo>
  <mi>x</mi>
  <mo>+</mo>
  <mi>zero</mi>
  <mo>)</mo>
  <mo>(</mo>
  <mi>x</mi>
  <mo>&lt;</mo>
  <mi>zero</mi>
  <mo>)</mo>
 
</math>

  
</p>

<p>
Many algorithms are made stable with the explicit
 realization of zero as a very small quantity. Whole theories
 of calculus are built on this that in your wildest dreams
 you could not imagine.  Even though this test looks harmless
 enough at its heart is an operation which can not be reversed.
</p>




</div>



<div class="float25">

<a id="Barycentric_Coordinates"></a>
<h2>Barycentric Coordinates</h2>




<p>Barycentric coordinates can describe a point in a simplex.
  They are a linear average of the simplexes points.
</p>

<p>Here is a point inside a triangle. The variables u<sub>i</sub> range
 from 0 to 1.</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>1</mi>
</math>

<br/>



<math xmlns="&mathml;">
  <mi>p</mi>
  <mo>(</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>

</p>

<p>For a tetrahedron there is one more dimension so there
 is one more variable u<sub>3</sub>.
</p>


<p class="equ">

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>


<math xmlns="&mathml;">
  <mo>&Sum;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>1</mi>
</math>



<br/>


<math xmlns="&mathml;">
  <mi>p</mi>
  <mo>(</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mo>...</mo>
  <mo>)</mo>
  <mo>=</mo>
  <mo>&Sum;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>

</p>



</div>


<div class="spacer" />



<div class="float25">

<a id="Line_and_Simplex_Intersection"></a>
<h2>Line and Simplex Intersection</h2>


<p>Since 
  <a href="#Barycentric_Coordinates"> Barycentric Coordinates</a> 
 describes a point and a vector equation describes
 a point equating the two together and solving finds their
 intersection point.  A line and a triangle in 2D does not
 have a unique solution because there is one extra variable.
 This corresponds to the fact that the intersection is not a
 point but a line through the triangle.  For a triangle in 3D
 space the intersection point is generally unique.
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>

<br/>


<math xmlns="&mathml;">
  <mo>&Sum;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>1</mi>
</math>



<br/>


<math xmlns="&mathml;">
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
  <mi>t</mi>
  <mo>=</mo>
  <mo>&Sum;</mo>
  <mi>u</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>


  


</p>

<p>Real Time Rendering[1] describes an algorithm for computing the
 Ray/Triangle Intersection in 3D.  The matrix inverse is calculated
 with Cramer's rule and the determinants are replaced by expressions
 with dot and cross products.  The beauty of the algorithm is that
 only one division needs to be done.
</p>

</div>

<div class="float25">

<p>If you do not need to compute the barycentric coordinates u and v
 and instead just want to know if the intersection occurred then the
 one division can be avoided altogether.
</p>

<p class="equ">

Consider  &nbsp; 
<math xmlns="&mathml;">
  <mi>a</mi>
</math> &nbsp; 

 to be the determinant, <br/>

<math xmlns="&mathml;">
  <mi>u</mi>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>a</mi></mrow>
  </mfrac>
  <mi>s</mi>
  <mo>&CenterDot;</mo>
  <mi>p</mi>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>u</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>
 &nbsp; &nbsp; becomes <br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>s</mi>
  <mo>&CenterDot;</mo>
  <mi>p</mi>
  <mo>&leq;</mo>
  <mi>a</mi>
</math>

</p>

<p>Similarly substituting in the solution for v and multiplying out
 the denominator in the conditional equality removes
 the division and gets an expression that uses dot products
 only.
</p>

<p class="equ">

Consider  &nbsp; 
<math xmlns="&mathml;">
  <mi>a</mi>
</math> &nbsp; 

 to be the determinant, <br/>

<math xmlns="&mathml;">
  <mi>v</mi>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow><mi>a</mi></mrow>
  </mfrac>
  <mi>d</mi>
  <mo>&CenterDot;</mo>
  <mi>q</mi>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>v</mi>
  <mo>&leq;</mo>
  <mi>1</mi>
</math>
 &nbsp; &nbsp; becomes <br/>

<math xmlns="&mathml;">
  <mi>0</mi>
  <mo>&leq;</mo>
  <mi>p</mi>
  <mo>&CenterDot;</mo>
  <mi>q</mi>
  <mo>&leq;</mo>
  <mi>a</mi>
</math>

</p>

</div>

<div class="spacer" />

<div class="float25">

<p><a href="#Real_Time_Rendering">[1]</a> solved the equation</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>o</mi>
  <mo>+</mo>
  <mi>t</mi>
  <mi>d</mi>
  <mo>=</mo>
  <mo>(</mo>
  <mi>1</mi>
  <mo>-</mo>
  <mi>u</mi>
  <mo>-</mo>
  <mi>v</mi>
  <mo>)</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>u</mi>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>v</mi>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>

</p>

<p>As I am quoting I will keep their symbols but the use of o as a point is ridiculous.
 However their bold faced font on the vectors is very readable and if I could present
 half as well as the authors I would be happy.  Expressing this equation as a matrix
 please forgive my use of MathML as the current MathML rendering is not adequate.
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>(</mo>
  <mi>t</mi>
  <mo>,</mo>
  <mi>u</mi>
  <mo>,</mo>
  <mi>v</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>
  <mo>=</mo>
  <mo>o</mo>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>

<br/>

Let 
<math xmlns="&mathml;">
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>

<br/>

Let 
<math xmlns="&mathml;">
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>

<br/>

Let 
<math xmlns="&mathml;">
  <mi>s</mi>
  <mo>=</mo>
  <mi>o</mi>
  <mo>-</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>


<br/> then <br/>

<math xmlns="&mathml;">
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>(</mo>
  <mi>t</mi>
  <mo>,</mo>
  <mi>u</mi>
  <mo>,</mo>
  <mi>v</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>
  <mo>=</mo>
  <mi>s</mi>
</math>


</p>


<p class="equ">
<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>t</mi>
  <mo>,</mo>
  <mi>u</mi>
  <mo>,</mo>
  <mi>v</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>

  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
      
    </mrow>
  </mfrac>

  <mo>(</mo>

  <mi>det</mi>
  <mo>(</mo>
  <mi>s</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>,</mo>
  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>s</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>,</mo>

  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>s</mi>
  <mo>)</mo>


  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>

</math>


</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>det</mi>
  <mo>(</mo>
  <mi>a</mi>
  <mo>,</mo>
  <mi>b</mi>
  <mo>,</mo>
  <mi>c</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mo>-</mo>
  <mo>(</mo>
  <mi>a</mi>
  <mo>&times;</mo>
  <mi>c</mi>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>b</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mo>(</mo>
  <mi>c</mi>
  <mo>&times;</mo>
  <mi>b</mi>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>a</mi>

</math>

</p>

<p class="equ"> Let <br/>

<math xmlns="&mathml;">
  <mi>p</mi>
  <mo>=</mo>
  <mi>d</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>q</mi>
  <mo>=</mo>
  <mi>s</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
</math>

</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>
  <mo>(</mo>
  <mi>d</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>p</mi>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

</math>

<math xmlns="&mathml;">
  <mi>det</mi>
  <mo>(</mo>
  <mi>s</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>
  <mo>(</mo>
  <mi>s</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>q</mi>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>

</math>

<br/>

<math xmlns="&mathml;">
  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>s</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>=</mo>
  <mo>(</mo>
  <mi>d</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>s</mi>
  <mo>=</mo>
  <mi>p</mi>
  <mo>&CenterDot;</mo>
  <mi>s</mi>
</math>

<br/>

<math xmlns="&mathml;">
  <mi>det</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>d</mi>
  <mo>,</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>s</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mo>(</mo>
  <mi>s</mi>
  <mo>&times;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mi>d</mi>
  <mo>=</mo>
  <mi>q</mi>
  <mo>&CenterDot;</mo>
  <mi>d</mi>
</math>




</p>

<p class="equ">
<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>t</mi>
  <mo>,</mo>
  <mi>u</mi>
  <mo>,</mo>
  <mi>v</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>

  <mi>p</mi>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

    </mrow>
  </mfrac>
  <mo>(</mo>
  <mi>q</mi>
  <mo>&CenterDot;</mo>
  <mi>e</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>,</mo>
  <mi>p</mi>
  <mo>&CenterDot;</mo>
  <mi>s</mi>
  <mo>,</mo>
  <mi>q</mi>
  <mo>&CenterDot;</mo>
  <mi>d</mi>
  <mo>)</mo>
  <msup>
    <mi></mi>
    <mrow><mi>T</mi></mrow>
  </msup>
</math>

</p>

<p>This is easy to implement. Simply reject
 if the determinant is zero with a 
 <a href="#Zero_Test">Zero Test</a>, calculate u and
 v and test their bounds to ensure that the intersection
 point is
 in the triangle.
</p>





</div>


<div class="float25">
<a id="Ray_and_Box"></a>
<h2>Ray and Box</h2>

<p>A ray can be used to describe a line with thickness or a line
 in the computer science literature. For example [1] and [2] are both
 from the same book but the latter describes a ray as the area between
 two parallel lines in 2D and the former a line in 3D space.
</p>






</div>

<div class="float25">
<a id="Polygon_Area"></a>
<h2>Polygon Area</h2>

<p>Where the points have the same winding, the area of the convex
 polygon can be calculated. 
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>area</mi>
  <mo>=</mo>
  <msubsup>
    <mo>&Sum;</mo>
    <mrow>
      <mi>0</mi>
    </mrow>
    <mrow>
      <mi>n</mi><mo>-</mo><mi>1</mi>
    </mrow>
  </msubsup>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mo>,</mo><mi>x</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mo>+</mo><mi>1</mi><mo>,</mo><mi>y</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mo>+</mo><mi>1</mi><mo>,</mo><mi>x</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mo>,</mo><mi>y</mi></mrow>
  </msub>

  
</math>


</p>

<p>This can be derived directly by summing the triangles about
 a point as a sum of cross products ie the individual triangles.  
 The cross product is
 expanded and when simplified the above result is given.
</p>

<p>What is not so obvious is how this generalizes. By considering
 halfspaces the last two successive points generate a halfspace.
 Note that all successive halfspaces see the next point.
</p>

<p>In 3D can the volume be calculated by having the last 3 successive
 points generate a halfspace which sees the next point? Perhaps &lt;TODO&gt;
</p>

<p>Here is the sum to expand and simplify. Let 0 be the pivot point which is being
 rotated about. Let p<sub>i</sub> be ordered such that the next point is 
 visible on the surface. The area calculated by [1,2,3], [3,2,4], [3,4,5], [5,4,6],
 [5,6,7], ... This ordering is to have the triangles on the surface have consistent
 winding.
</p>

<p>Heres some thoughts.  In 2D there is only one direction of movement. In 3D 
 a surface move can be left or right.  Structure the surface transversal
 so a series of 1's and 0's to represent a right and a left move.  Let
 the last move use the last two points. The path is described. While its
 length in unknown all the variation is expressed in the vector or 1's and 0's.
</p>
 
</div>

<div class="float25">
<a id="Rotating_a_Plane"></a>
<h2>Rotating a Plane</h2>

<p>
Often we work in the xy plane and rotate the result.
 The best way to describe the planes orientation is with its normal.
 Working in the xy plane the normal is the z-axis vector.
 Given that we want to rotate the plane to the new position
 with normal N how is this done?
</p>

<p>
Assuming we have a function that rotates around a line through the origin,
 find the angle between z and N and rotate about their cross product.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>&theta;</mi>
  <mo>=</mo>
  <mi>cos</mi>
  <msup>
    <mi></mi>
    <mrow><mo>-</mo><mi>1</mi></mrow>
  </msup>
  <mo>(</mo>
  <mfrac>
    <mrow><mi>N</mi>&CenterDot;<mi>z</mi></mrow>
    <mrow><mo>|</mo><mi>N</mi><mo>|</mo></mrow>
  </mfrac>


  <mo>)</mo>
</math>

<br/>
<math xmlns="&mathml;">
  <mi>rotate</mi>
  <mo>(</mo>
  <mi>&theta;</mi>
  <mo>,</mo>
  <mi>z</mi>
  <mo>&times;</mo>
  <mi>N</mi>
  <mo>)</mo>
</math>
  

</p>


</div>





<div class="float25">
<a id="References"></a>
<h2>References</h2>

<ol>

<li>
<a id="Real_Time_Rendering"></a>
 T.Akenine-Moller E.Haines(2002). Real-Time Rendering 
 (Second Edition).
  ISBN 1-56881-182-9. Pages 578-581.
</li>

</ol>

</div>

</body>
</html>


