<?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> Transformations </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-01-01
<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>
Transformations 
<a href="../../../../index.html">
<img alt="home" src="../../../comsci/images/Frame.gif" /> </a>
</h1>

<p>
<a href="#vectorstomatricies"> Transition from Vectors to Matrices </a> <br/>
<a href="#Homogeneous_Coordinate_System"> 
  Homogeneouse Coordinate System</a><br/>
  &nbsp; &nbsp; 
  <a href="#OpenGL_and_Homogeneous_Matrices"> OpenGL and Homogeneous Matrices </a> <br/>
  &nbsp; &nbsp; 
  <a href="#Natural_Order_of_Transformation_Operations">  
    Natural Order of Transformation Operations </a> <br/>
  &nbsp; &nbsp; 
  <a href="#Rotating_about_a_point_in_2D">Rotating about a point in 2D</a><br/>
  
<a href="#affine">  Affine Transformations </a> <br/>
<a href="#rotation3d"> Rotations in 3D </a> <br/>
<a href="#linereflection"> Reflection of a point about a Line </a> <br/>
</p>



<div class="float25">
<a id="Homogeneous_Coordinate_System"></a>
<h2>
Homogeneous Coordinate System
</h2>

<p>
Brief: The homogeneous coordinate system combines a transform with a shift.
</p>

<p>
Consider a 2D transform in homogeneous coordinates.
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mfenced open='(' close=')'> 
  <mtable> 
    <mtr><mtd><mi>x'</mi></mtd></mtr>
    <mtr><mtd><mi>y'</mi></mtd></mtr>
    <mtr><mtd><mi>1</mi></mtd></mtr> 
  </mtable>
  </mfenced>
  <mo>=</mo>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>11</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>12</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>x</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>21</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>22</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>y</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>0</mi>
      </mtd>
      <mtd>
        <mi>0</mi>
      </mtd>
      <mtd>
        <mi>1</mi>
      </mtd>
    </mtr>

  </mtable>
  </mfenced> 
  <mfenced open='(' close=')'>
  <mtable>
    <mtr><mtd><mi>x</mi></mtd></mtr>
    <mtr><mtd><mi>y</mi></mtd></mtr>
    <mtr><mtd><mi>1</mi></mtd></mtr>    
  </mtable>
  </mfenced>
  
</math>

</p>

<p>This is how it looks with ordinary 2D matrix algebra. </p>

<p class="equ">

<math xmlns="&mathml;">
  <mfenced open='(' close=')'> 
  <mtable> 
    <mtr><mtd><mi>x'</mi></mtd></mtr>
    <mtr><mtd><mi>y'</mi></mtd></mtr>
  </mtable>
  </mfenced>
  <mo>=</mo>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>11</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>12</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>21</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>22</mi></mrow>
        </msub>
      </mtd>
    </mtr>
  </mtable>
  </mfenced>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr><mtd><mi>x</mi></mtd></mtr>
    <mtr><mtd><mi>y</mi></mtd></mtr>
  </mtable>
  </mfenced>
  <mo>+</mo>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
        <mi>x</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>y</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
  </mtable>
  </mfenced>

</math>

</p>

<p>In algebra both these can be expressed as <br/> 
  &nbsp; &nbsp; 

<math xmlns="&mathml;">
  <mi>X'</mi>
  <mo>=</mo>
  <mi>M</mi>
  <mi>X</mi>
  <mo>+</mo>
  <mi>X</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>
</p>


<p>
The homogeneous coordinate system can be implemented in 3D space too.

</p>


<p class="equ">

<math xmlns="&mathml;">
  <mfenced open='(' close=')'>
  <mtable>
    <mtr><mtd><mi>x'</mi></mtd></mtr>
    <mtr><mtd><mi>y'</mi></mtd></mtr>
    <mtr><mtd><mi>z'</mi></mtd></mtr>
    <mtr><mtd><mi>1</mi></mtd></mtr>
  </mtable>
  </mfenced>
  <mo>=</mo>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>11</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>12</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>13</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>x</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>21</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>22</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>23</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>y</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>31</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>32</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>m</mi>
        <msub>
          <mi></mi>
          <mrow><mi>33</mi></mrow>
        </msub>
      </mtd>
      <mtd>
        <mi>z</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>

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

  </mtable>
  </mfenced>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr><mtd><mi>x</mi></mtd></mtr>
    <mtr><mtd><mi>y</mi></mtd></mtr>
    <mtr><mtd><mi>z</mi></mtd></mtr>
    <mtr><mtd><mi>1</mi></mtd></mtr>
  </mtable>
  </mfenced>

</math>

</p>

</div>

<div class="float25">

<p>The beauty of the homogeneous coordinate system is that it combines the shift
 and translation into one matrix multiplication using standard matricies.
 No need to write separate transforms - the transforms can be combined.
</p>

<p>It is also a state.  Apply this transformation and this shift.</p>

<p>
Essentially the space has been extended to include the translation.
 Someone discovered how to do this using normal matrix mathematics.
</p>

<p>Note that a point (x,y) in homogeneous coordinates is represented as a column vector. Here it is in 2D.</p>

<p class="equ">
<math xmlns="&mathml;">
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
        <mi>x</mi>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>y</mi>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mi>1</mi>
      </mtd>
    </mtr>
  </mtable>
  </mfenced>

</math>

</p> 


</div>

<div class="float25">

<a id="linereflection"> </a>
<h2>Reflection of a point about a Line through the Origin </h2>

<p class="equ">

<math xmlns="&mathml;">
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>1</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd>
        <mi>x</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
      <mtd>
        <mi>y</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mo>-</mo><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>
 
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>1</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd>
        <mo>-</mo>
        <mi>x</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
      <mtd>
        <mo>-</mo>
        <mi>y</mi>
        <msub>
          <mi></mi>
          <mrow><mi>0</mi></mrow>
        </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>
  
</math>

</p>

<p>
Thinking geometrically, shift the point to the origin, rotate
 and reverse the shift. Each operation corresponds with the matrix
 being multiplied on the left hand side.
</p>

<img src="diagg00301.png" alt="point reflected in axis" />


</div>

<div class="spacer" />

<div class="float25">

<a id="rotation3d"> </a>
<h2> Rotations in 3D </h2>

<p class="equ">

<math xmlns="&mathml;">

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>1</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>

    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mo>-</mo><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>
 
</math>

 &nbsp; &nbsp; x-axis rotation  <br/>

<math xmlns="&mathml;">

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>

    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mo>-</mo><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>
 
</math>

 &nbsp; &nbsp; y-axis rotation  <br/>

<math xmlns="&mathml;">

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mo>-</mo><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>

    <mtr>
      <mtd><mi>sin</mi><mi>&theta;</mi></mtd>
      <mtd><mi>cos</mi><mi>&theta;</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
      <mtd><mi>0</mi></mtd>
    </mtr>
    <mtr>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>0</mi></mtd>
      <mtd><mi>1</mi></mtd>
    </mtr>
  </mtable>
  </mfenced>
 
</math>

 &nbsp; &nbsp; z-axis rotation  

</p>


</div>

<div class="spacer" />

<div class="float25">
<a id="Rotating_about_a_point_in_2D"></a>
<h3>Rotating about a point in 2D</h3>

<p>The homogeneous coordinates seem mystifying and they are.  But when you compare it with
 normal algebra it is easy to see what is going on.  Consider the following example of
 finding a transform that rotates about a given point in 2D by an angle of theta.
 The standard transformation matrix rotates about the origin and not the point so you need
 to first shift to the origin, apply the rotation and shift back again.
</p>

<p class="equ">
Let R be the transform matrix,<br/>
 P be the point being translated,<br/> 
 X<sub>0</sub> be the point being rotated about, <br/>
 and P' is the transformed point.</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>P'</mi>
  <mo>=</mo>
  <mi>R</mi>
  <mo>(</mo>
  <mi>P</mi>
  <mo>-</mo>
  <mi>X</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>+</mo>
  <mi>X</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
</math>


</p>

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


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>'</mo>
      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>'</mo>
      </mtd>

    </mtr>

  </mtable>
  </mfenced>

  <mo>=</mo>
  

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
      </mtd>
    </mtr>
  </mtable>
  </mfenced>

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

      </mtd>

    </mtr>

  </mtable>
  </mfenced>

  <mo>+</mo>

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

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

    </mtr>

    <mtr>

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

    </mtr>

  </mtable>
  </mfenced>

</math>



<br/>


<math xmlns="&mathml;">


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>'</mo>
      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>'</mo>
      </mtd>

    </mtr>

  </mtable>
  </mfenced>

  <mo>=</mo>
  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
  <mi>r</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>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>r</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>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <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>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
    </mtr>
  </mtable>
  </mfenced>

</math>



</p>

</div>


<div class="float25">

<p>I am going to verify this result with homogeneous coordinates.  There are
 also two similar ways that we can view the computation.  Applying the operators to the point
 by multiplying the transforms in order.  Or take the equation and extract the operators order from
 it.
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>P'</mi>
  <mo>=</mo>
  <mi>X</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>R</mi>
  <mo>(</mo>
  <mo>-</mo>
  <mi>X</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>)</mo>
  <mi>P</mi>
</math>

</p>


<p>Comparing this with the normal linear equation you will notice that this equation is
 ordered from right to left.  For example P-X<sub>0</sub> is done first because
 it is the inner most bracket hence (-X<sub>0</sub>)P.  Next the multiplication of R comes
 before addition so the R operator is applied. This gives R(-X<sub>0</sub>)P.  Finally
 the addition is done yielding XR(-X<sub>0</sub>)P.  So essentially the equations are the
 same with the homogeneous one being exact in the ordering of operations whereas the first
 equation can be written in many different ways eg P=X<sub>0</sub>+R(P-X<sub>0</sub>), P=X<sub>0</sub>+R(-X<sub>0</sub>+P), ...
</p>

<p class="equ">

<math xmlns="&mathml;">


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

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

    </mtr>

    <mtr>

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

    </mtr>

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

  </mtable>
  </mfenced>




  <mfenced open='(' close=')'>
  <mtable>

    <mtr>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>0</mi>
      </mtd>
    </mtr>


    <mtr>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>0</mi>
      </mtd>
    </mtr>

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

  </mtable>
  </mfenced>




  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>1</mi>
      </mtd>
      <mtd>
  <mi>0</mi>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>0</mi>
      </mtd>
      <mtd>
  <mi>1</mi>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>

    </mtr>

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

  </mtable>
  </mfenced>





</math>



</p>


<p class="equ">

<math xmlns="&mathml;">


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <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>

      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

      </mtd>

    </mtr>

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

  </mtable>
  </mfenced>

</math>

</p>

<p>Multiply by P on the rhs.</p>

<p class="equ">

<math xmlns="&mathml;">


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <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>

      </mtd>

    </mtr>

    <mtr>

      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

      </mtd>

    </mtr>

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

  </mtable>
  </mfenced>

  <mfenced open='(' close=')'>
  <mtable>
    <mtr>
      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
    </mtr>

    <mtr>
      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
      </mtd>
    </mtr>

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

  </mtable>
  </mfenced>


</math>


<br/>


<math xmlns="&mathml;">


  <mfenced open='(' close=')'>
  <mtable>
    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>+</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <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>

      </mtd>
    </mtr>


    <mtr>

      <mtd>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
      </mtd>
      <mtd>
  <mo>+</mo>
  <mi>p</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>-</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>r</mi>
  <msub>
    <mi></mi>
    <mrow><mi>3</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>x</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>

      </mtd>
    </mtr>

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

  </mtable>
  </mfenced>


</math>


</p>

<p>This is the same as from standard algebra and hence the technique has been verified which gives me a little more confidence.
</p>



</div>


<div class="spacer" />


<div class="float25">

<a id="affine"> </a>
<h2> Affine Transformations </h2>

<p>Translations, rotation and sheering, all these transformations
 preserve parallel lines.
Affine transformation are reversible - the translation determinant is
 non zero and they form a group.
</p>

<p> Rigid motions or Euclidean transformations are rotations + translation
 and preserve distances and angles. They are a subset of affine 
 transformations.
</p>


<p>
 Affine transformation preserve lines.
In a sense affine transformations are linear. From a computation point of 
 view transforming a line means transforming the end points and
 drawing a line between the transformed points. As opposed to transforming
 every point on the line.
</p>

</div>


<div class="spacer" />

<div>

<a id="vectorstomatricies"> </a>
<h2> Transition from Vectors to Matrices </h2> 

<h3> A point in space </h3>

<p>
A point in space is represented as a sum of vectors. </p>

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

</p>

<p> In 2D. </p>

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

  <munder>
    <mi>p</mi><mrow><mi>~</mi></mrow>
  </munder>
  <mo>=</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <munder>
    <mi>v</mi><mrow><mi>~</mi></mrow>
  </munder>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mo>+</mo>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <munder>
    <mi>v</mi><mrow><mi>~</mi></mrow>
  </munder>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
</math>
</p>


<p class="equ">
<math xmlns="&mathml;">
  <mo>=</mo>
  <mo>(</mo>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>,</mi>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mo>)</mo>
  <mo>&CenterDot;</mo>
  <mfenced open='(' close=')'>
    <mtable>
      <mtr>
         <mtd>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
         </mtd>
      </mtr>
      <mtr>
         <mtd>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
         </mtd>
      </mtr>
    </mtable>
  </mfenced>
  
</math>
</p>

<p>
The vectors 

<math xmlns="&mathml;">
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>  
</math>
 have a vertical orientation, realizing this gives.

</p>

<p class="equ">
<math xmlns="&mathml;">
  <mfenced open='(' close=')'>
    <mtable>
      <mtr>
        <mtd>

  <mfenced open='(' close=')'>
    <mtable>
      <mtr>
        <mtd>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>00</mi></mrow>
  </msub>

        </mtd>
      </mtr>
      <mtr>
        <mtd>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>01</mi></mrow>
  </msub>

        </mtd>
      </mtr>
    </mtable>
  </mfenced>



        </mtd>
        <mtd>


  <mfenced open='(' close=')'>
    <mtable>
      <mtr>
        <mtd>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>10</mi></mrow>
  </msub>

        </mtd>
      </mtr>
      <mtr>
        <mtd>

  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>11</mi></mrow>
  </msub>

        </mtd>
      </mtr>
    </mtable>
  </mfenced>


        </mtd>
      </mtr>
    </mtable>
  </mfenced>

  <mfenced open='(' close=')'>
    <mtable>
      <mtr>
         <mtd>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
         </mtd>
      </mtr>
      <mtr>
         <mtd>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
         </mtd>
      </mtr>
    </mtable>
  </mfenced>

  
  
</math>
</p>

<p>
Ok - it looks ugly.  The vectors are still being treated as whole units.
Someone noticed that the sum can be summed in another order and give the same
 outcome.
</p>

<p class="equ">
<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>
  <mo>=</mo>
  <munder>
    <mi>&Sum;</mi>
    <mrow><mi>i</mi></mrow>
  </munder>
  <mi>a</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <munder>
    <mi>&Sum;</mi>
    <mrow><mi>k</mi></mrow>
  </munder>
  <mi>v</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mi>k</mi></mrow>
  </msub>
</math>

<br/>

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

</p>

<p>
Where k is associated with position. This was called matrix multiplication.
</p>

<p>
The relevance of the above now is clear.  The transition matrix comprise
 of columns of vectors. A transform is a linear combination of these vectors,
 and is associated with linear algebra. But in a sense is its own coordinate system.
</p>


</div>

<div class="float25">
<a id="Natural_Order_of_Transformation_Operations"> </a>
<h3> Natural Order of Transformation Operations </h3>

<p>
Somewhere along the way matrices evolved (I don't know how, its a huge
 story) so that transforming is multiplying the point with a matrix
 on the left hand side.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>M</mi>
  <mi>X</mi>
  <mo>&RightArrow;</mo>
  <mi>X</mi>
</math>
 &nbsp; or &nbsp; 
<math xmlns="&mathml;">
  <mi>X'</mi>
  <mo>=</mo>
  <mi>M</mi>
  <mi>X</mi>
</math>


</p>

<p> For a practical example consider rotating a point
 anti-clockwise by 45 degrees.
</p>

<p>
The point is represented as a 2 by 1 matrix - vertical orientation.
</p>

<p class="equ">

<math xmlns="&mathml;">
  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>cos</mi><mo>(</mo><mi>45</mi><mo>)</mo></mtd>
         <mtd><mo>-</mo><mi>sin</mi><mo>(</mo><mi>45</mi><mo>)</mo></mtd>
      </mtr>
      <mtr>
         <mtd><mi>sin</mi><mo>(</mo><mi>45</mi><mo>)</mo></mtd>
         <mtd><mi>cos</mi><mo>(</mo><mi>45</mi><mo>)</mo></mtd>
      </mtr>
    </mtable>
  </mfenced>
  <mo>=</mo>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
      <mi>2</mi>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow><mi>1</mi></mrow>
        <mrow><mi>2</mi></mrow>
      </mfrac>
    </mrow>
  </msup>
    </mrow>
  </mfrac>

  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mo>-</mo><mi>1</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mi>1</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>

</math>

<br/> rotate &nbsp; 
<math xmlns="&mathml;">
  <mo>(</mo>
  <mi>1</mi>
  <mo>,</mo>
  <mi>0</mi>
  <mo>)</mo>
</math>
 &nbsp; by 45 degrees. <br/>


<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
      <mi>2</mi>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow><mi>1</mi></mrow>
        <mrow><mi>2</mi></mrow>
      </mfrac>
    </mrow>
  </msup>
    </mrow>
  </mfrac>
</math>

<math xmlns="&mathml;">
  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mo>-</mo><mi>1</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mi>1</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>
</math>

<math xmlns="&mathml;">
  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>1</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>0</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>
</math>

<math xmlns="&mathml;">
  <mo>&RightArrow;</mo>

  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
      <mi>2</mi>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow><mi>1</mi></mrow>
        <mrow><mi>2</mi></mrow>
      </mfrac>
    </mrow>
  </msup>
    </mrow>
  </mfrac>
</math>

<math xmlns="&mathml;">
  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>1</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>1</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>

</math>

<br/>
 rotate again by 45 degrees. <br/>


<math xmlns="&mathml;">
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
      <mi>2</mi>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow><mi>1</mi></mrow>
        <mrow><mi>2</mi></mrow>
      </mfrac>
    </mrow>
  </msup>
    </mrow>
  </mfrac>

  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mo>-</mo><mi>1</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>1</mi></mtd>
         <mtd><mi>1</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>
  <mfrac>
    <mrow><mi>1</mi></mrow>
    <mrow>
      <mi>2</mi>
  <msup>
    <mi></mi>
    <mrow>
      <mfrac>
        <mrow><mi>1</mi></mrow>
        <mrow><mi>2</mi></mrow>
      </mfrac>
    </mrow>
  </msup>
    </mrow>
  </mfrac>

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

  <mo>&RightArrow;</mo>

  <mfenced open='[' close=']'>
    <mtable>
      <mtr>
         <mtd><mi>0</mi></mtd>
      </mtr>
      <mtr>
         <mtd><mi>1</mi></mtd>
      </mtr>
    </mtable>
  </mfenced>

</math>


</p>

<p>
If R is a 45 degree rotation
 and X is the point then rotating the point 90 degrees is multiplying X by R twice.
</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>R</mi>
  <mi>R</mi>
  <mi>X</mi>
  <mo>&RightArrow;</mo>
  <mi>X</mi>
</math>

</p>

<p>Standard algebra can not accept R as a translation.  Homogeneous coordinates came 
 into being to address this by alowing R to be a shift operation.
</p>



</div>


<div class="float25">

<a id="OpenGL_and_Homogeneous_Matrices"> </a>
<h3> OpenGL and Homogeneous Matrices </h3>

<p> OpenGL implements the homogeneous coordinate system.

Rather than applying operations directly to the point, 
 the operations are applied to the matrix which ends up multiplying
 the point(s). In the final
 stage this matrix is applied to the point.
</p>

<p> Let C be the current matrix and M be the new matrix operation. </p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>C</mi>
  <mi>M</mi>
  <mo>&RightArrow;</mo>
  <mi>C</mi>
</math>
</p>

<p>A little bit of algebra</p>

<p class="equ">
<math xmlns="&mathml;">
  <mi>C</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi><mo>+</mo><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>C</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
  <mi>M</mi>
  <msub>
    <mi></mi>
    <mrow><mi>i</mi></mrow>
  </msub>
</math>
<br/>

<math xmlns="&mathml;">
  <mi>C</mi>
  <msub>
    <mi></mi>
    <mrow><mi>N</mi><mo>+</mo><mi>1</mi></mrow>
  </msub>
  <mo>=</mo>
  <mi>C</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>M</mi>
  <msub>
    <mi></mi>
    <mrow><mi>0</mi></mrow>
  </msub>
  <mi>M</mi>
  <msub>
    <mi></mi>
    <mrow><mi>1</mi></mrow>
  </msub>
  <mi>M</mi>
  <msub>
    <mi></mi>
    <mrow><mi>2</mi></mrow>
  </msub>
  <mo>...</mo>
  <mi>M</mi>
  <msub>
    <mi></mi>
    <mrow><mi>N</mi></mrow>
  </msub>
</math>

</p>

<p> This shows the final ordering of the transformation matrix,
 operations operate on the right hand side and not the left
 as the natural ordering required.
</p>

<h3> Example </h3>


<p>Now consider the order of transforms to move from the large
 rectangle to the smaller one.
</p>

<ol>
<li> T1: &nbsp; translate or shift to the origin </li>
<li> S: &nbsp; scale the shape</li>
<li> R: &nbsp; rotate the shape </li>
<li> T2: &nbsp; translate it again </li>
</ol>



<img src="../../../misc/opgl/opgl015.png" alt="opgl015.png" />

<p> The natural ordering can be expressed in algebra. </p>

<p class="equ">

<math xmlns="&mathml;">
  <mi>T2</mi>
  <mi>R</mi>
  <mi>S</mi>
  <mi>T1</mi>
  <mi>X</mi>
  <mo>&RightArrow;</mo>
  <mi>X</mi>
</math>
</p>

<p>But OpenGL multiplies matrices on the right hand side,
 so you will have to reverse the order of transformations.
</p>

<pre>
  glTranslatef(-0.3,0.0,0.0);
  glRotatef(-45.0,0.0,0.0,1.0);
  glScalef(.707,.707,1.0);
  glTranslatef(-0.1,-0.5,0.0);
</pre>

<p>Expressing this as a multiplication of matricies and the point.</p>

<p>glTranslatef(-0.3,0.0,0.0)*glRotatef(-45.0,0.0,0.0,1.0)*glScalef(.707,.707,1.0)*glTranslatef(-0.1,-0.5,0.0)*X
</p>

<p>Now it is easy to see why people say that OpenGL reverses the order
 of operations because the order that they are written in code
 is reversed when applied to the point.
</p>

<ol>
<li>glTranslatef(-0.1,-0.5,0.0)</li>
<li>glScalef(.707,.707,1.0)</li>
<li>glRotatef(-45.0,0.0,0.0,1.0)</li>
<li>glTranslatef(-0.3,0.0,0.0)</li>
</ol>

<p>Note that swapping the scale and rotate operations does not change
 the outcome because these operations can be done in any order when
 they are together.  Sorry for any confusion.
</p>


</div>



</body>
</html>



