Vectors are of fundamental importance in any 3D game engine. They are used to represent points and directions in space. They are used to represent spatial directions such as direction of light, orientation of camera, normal of a triangular mesh. Understanding how to manipulate vectors is an essential skill for a successful 3D programmer.
Affine Space
=========
Imagine our universe. Has it got any origin or axes? NO. But we can define Origin as the sun and define axes. Or we can take the Origin as center of the earth. In mathematics, an affine space is an abstract structure that generalises the affine-geometric properties of Euclidean space. In an affine space, one can subtract points to get vectors, or add a vector to a point to get another point, but one cannot add points, since there is no origin.Math gurus please visit wikipedia for more info.
Vector Algebra
===========
A vector is represented as a list of its components (V1, V2, V3,…, Vn) where n is the dimension of the vector. You can get more information about vectors from wikipedia.
Types of Vectors
Zero (Null) Vector: A vector whose magnitude is zero; magnitude is calculated as
root of(V12 + V22 V32 +…+V12)
Unit Vector: A vector whose magnitude is unity.
Like Vectors: Vectors whose directions are the same
Unlike Vectors: Vectors whose directions are opposite
Negative of a vector: Vector which is opposite in direction but same in magnitude
Collinear Vectors: Vectors which are parallel and in the same line of action
Co-Initial Vector: A vector which is not altered by shifting it about parallel in space
Free Vector: If it is our liberty to choose origin for a vector then it is a free vector
Localized Vector: If we cannot choose the vector’s origin then it is a localized vector
Addition of two vectors
=================
(a,b) + (c,d) = (a+c,b+d)
Properties
=======
Commutative,
Associative,
Existence of additive identity
Existence of additive inverse
Substraction of two vectors
====================
(a,b) – (c,d)
take negative of (c,d) then add
(a,b)+(-(c,d))
(a,b)+(-c,-d) = (a-c, b-d)
Properties same as additive properties
Multiplication by scalar
=================
5*(a,b) = (5a,5b)
Properties
=======
Associative
Distributive
Existence of Identity
Dot Product
=========
(a,b) . (c,d) = (ac,bd)
AB.CD = mag(AB)*mag(CD)*cos(theta)
Where AB,CD are two vectors and theta the angle between them
Cross Product
==========
(a,b,c) X (d,e,f) = determinant( i,j,k,a,b,c,d,e,f)
where i,j,k are the unit vectors
AB.CD = mag(AB)*mag(CD)*sin(theta)*n
Where AB,CD are two vectors and theta the angle between them and n the normal vector perpendicular to both AB and CD