sunLoadingImage
whowedImag
decoration left 1
decoration left 2
transhome
transprojects
transgallery
transarticles
decoration rigth
English
Українська
Show/Hide search bar
black cat logo variable logo
[02 Nov 2012]

Vectors in Computer Graphics

Vectors

Vectors have direction and magnitude. Number of components in a vector corresponds to number of dimensions. Scalar can be treated as speed or distance, and vector as velocity or offset with direction. Depending on requirements, vector can be written as row-vector or as column-vector (for example, for proper matrix multiplication):

row-vector              Column-vector. It is equal to transposed row-vector.

Length (magnitude) of the vector:

Length (magnitude) of the vector

Normalized vector (vector with lenght equal to 1, unit vector):

Normalized vector

Magnitude of difference between vectors:

Magnitude of difference between vectors

Dot product of vectors

Dot (inner) product of vectors is one of the most usefull and used operations in computer graphics. It is equal to sum of products of corresponding components of the vectors. Result is scalar value:

Dot product of two vectors

Dot product can be interpreted as cosine of angle between two vectors, or as projection of one vector on another. These interpretations are very related. Lets look on vectors a and b:

Geometrical interpretation of dot product

Cosine of angle between vectors and angle are calculated as:

Cosine of angle between two arbitrary vectors
Cosine of angle between two unit vectors
Angle between vectors

Length of projection of vector a on vector b and projected vector e are equal to:

Length of projection of vector a on vector b
Projected vector e

Properties of dot product:

  • dot product has higher priority than addition and substraction
  • Vectors are perpendicular is dot product is equal to 0
  • Vectors are parallel and have same direction if dot product is equal to 1
  • Vectors are parallel but have opposite directions if dot product is equal to -1
  • Angle between vectors is less than 90 degrees if dot product is greater than 0
  • Angle between vectors is greater than 90 degrees if dot product is less than 0
  • Dot product of vector with itself is equal to magnitude of the vector raised to power of 2
  • Result of dot product doesn
  • k - scalar
  • Distributivity of dot product

Cross product of vectors

Cross product is another usefull operation in computer graphics. It's only defined for 3-dimensional space. Result of cross product of two vectors is vector that is perpendicular to them. This property is used for calculation of normals, orthogonalization of vectors, etc. Lets look at vectors a and b:

Vector c is result of cross product of vectors a and b

Vector c is equal to:

Calculation of dot product

Vectors a and b don't have to be perpendicular. Magnitude of vector c is equal to area of parallelogram S that is formed by vectors a and b. If vectors a and b are unit vectors, then magnitude of c will be equal to sine of angle between vectors a and b:

Area of parallelogram
Sine of angle between vectors

Direction of vector c depends on order of vectors in cross product. For example, in right-handed coordinate system, direction of vector c can be determined by right-hand rule. If index finger points in direction of vector a and middle finger in direction of vector b, then thumb will determine direction of vector c. For left-handed coordinate system you can use your left-hand rule. If the order of vectors in cross product is changed, then vector c will point in opposite direction.

Cross product has higher priority than addition, substraction and dot product.

Other properties of cross product:

  • Change in order of vectors in cross product leads to opposite result

  • Distributivity of cross product
  • Cross product is not associative
  • Cross product of vector with itself is equal to 0
  • Cross product of parallel vectors is equal to 0

Scalar triple product of vectors

Triple product of vectors is equal to volume of parallelepiped that is formed by vectors a, b and c:

Scalar triple product of vectors
Мішаний добуток рівний обєму паралелограма, який утворений трьома векторами. Результат потрібно взяти до модуля.

Also, triple product is equal to determinant of a matrix that is formed form vectors a, b and c:

Calculation of triple product as determinat of a matrix

Properties of triple product:

  • If two vectors (of a, b or c) are parallel, then result is equal to 0.
  • If vectors a, b and c lie on same plane, then result is equal to 0.



Sun and Black Cat- Igor Dykhta (igor dykhta email) © 2007-2014