Thursday, 16 October 2014

Vectors, Matrices, Quaternions, and Tangent Space

In Review
     We covered many mathematical concepts in the previous weeks. In a short, hopefully brief, and definitive way, here is what we have covered in recent weeks:

Vectors
      "A point in space represent by and x, y, z location. This point must come from an origin."

Unit Vectors
     "Normalized vectors"
          - Normalization: v =  ( v / ||v|| )

Representations:

Regularly Written:                                                               Code:

  Two-Dimensional Vector: X-Coord, Y-Coord                      Vec2(float x, float y)
Three-Dimensoinal Vector: X-Coord, Y-Coord, Z-Coord      Vec3(float x, float y, float z)

Components:

     - Magnitude
          For vector (A) below:


     - Direction
          tan(theta) = (y2 - y1) / (x2 - x1)
          For Vector (A) below:


Calculations:

     - Dot Product
          A (dot) B = Ax * Bx + Ay * By + Az * Bz

       
     - Cross Product
          a (cross/x) b = |a| * |b| * sin(theta) * n

       

Matrices
     "A table of data that represents the orientation, position and scale of an object"
          -

Rotation Matrices:

     It is easy to determine which axis the rotation will be performed around since it will be the only axis that is left as a one (meaning there will be no changes applied, and it remains the same while everything else rotates).


                       x              y          z





Orthogonal Matrix
     - A Matrix that consists solely of unit vectors.




MVP Matrix
     "A 4x4 matrix that consists of the Model, View, and Projection Matrices."

     - Model Matrix
           Holds the model's transformation values in regards to rotations, translations and scaling.








     - View Matrix
          Holds the orientation of the camera that it will be applied to. Sets which direction is up in the world, and in turn, the corresponding direction and right/left unit vectors.



     - Projection Matrix
          Calculates the values that make the corresponding positions in the table appear in the desired perspective view



Quaternions
     "A four dimensional vector in space that has three operations: addition, scalar multiplication, and quaternion multiplication. They are special because the multiplication of two quaternions in non-communative - meaning that the order in which they are multiplied will change the end result of the multiplication."

Representation:

     q = < 3D Vector, Float>  /  <Vec3, float>
     q = <x, y, z, w>


Tangent Space/Homogeneous Matrix 
     "Referencing N-space in N+1 space. For example, representing something in two-dimensional space of coordinates (x, y) as a three-dimensional object in space of coordinates (x, y, w)"

This is done through the increase of every dimension of all primitives:

1.
- Making Points into Lines
- Making Lines into Planes
- Making Planes into Cubes/Cuboids (3D -> 4D)

2. (Example for 2D-3D)
Projecting all points through a plane at position z = 1.
All lines will intersect at one point (called the "projective line" in 3D - or the vanishing point)

3.
These resulting lines from 2D point space give us the projected 3D shape of the objects that the points created in perspective.


Image of Tangent Space Representation (Tangent of a point on an object):





References

wikipedia.com (for a couple of definitions/images) google.ca/images (everything counts, right? :P)
http://www.mathsisfun.com/algebra/vectors-dot-product.html
http://www.mathsisfun.com/algebra/vectors-cross-product.html
http://www.dummies.com/how-to/content/calculating-magnitude-with-vectors.html
http://hotmath.com/hotmath_help/topics/magnitude-and-direction-of-vectors.html