Computer Graphics Fundamentals I

In this story, we’ll start with a basic understanding of some fundamental concepts in computer graphics.

What is a vector?

A vector is a geometric object that has magnitude and direction. In addition, a vector can be decomposed and represented into its individual components. The number of components that a vector contains is called its dimensionality.

In Figure 1, the vector A has been decomposed into its x and y components. Thus, this vector has a dimensionality of 2.

Figure 1: Vector A and its components, Ax and Ay

In our case, we are often usually interested in two-dimensional and three-dimensional vectors. In two-dimensional space, a vector is usually decomposed into its x and y components. On the other hand, a vector is usually decomposed into its x, y, and z components in three-dimensional space.

Given a vector’s components in the three-dimensional space, the magnitude of the vector is given by Equation 1. This equation can be extended to higher dimensional space.

Equation 1: Magnitude of a vector

A vector whose magnitude is exactly equal to 1 (unit length) is called a normalized vector (not to be confused with a normal vector).

A normal vector is called normal because “normal” is synonymous to perpendicular. That is, a normal vector is perpendicular to the tangent plane at the surface. The blue arrow in Figure 2 shows a normal vector to a point in the red surface.

Figure 2: Normal vector

Vector Algebra

Vector operations follow rules according to vector algebra.

Vector Sum

Adding vectors is pretty simple. Vector sum is computed by adding the corresponding individual components of each vector. Given three-dimensional vectors U and V, the vector sum is:

Equation 2: Vector Addition

There are two different ways to multiply two vectors together — dot product and cross product. The results from these two operations are scalar and vector, respectively.

Dot Product

Depending on the situation, there are two ways where dot product can be obtained. Given two linearly independent vectors U and V, the dot product of two vectors is equal to the product of the magnitude of the two vectors multiplied by the cosine of the angle between them.

Equation 3: Dot product operation

In addition, the dot product of the vectors U and V can be computed by getting the sum of the products of the individual components of each vector.

Equation 4: Dot product operation

The dot product operation is usually used to compute for the scalar value of a vector projection to another vector.

Cross Product

Given two linearly independent vectors U and V, the cross product is defined as the vector that is perpendicular to both U and V. The resulting vector is normal to the plane containing U and V.

Equation 5: Cross product operation

The resulting vector is the determinant value of the Equation 5 given by:

Equation 6: Cross product operation

To get the magnitude of the resulting vector, one can use Equation 1. Alternatively, it can be computed using:

Equation 7: Magnitude of the normal vector to U and V

The cross product is usually used to compute for surface normals which can be useful for lighting calculations.

I’m Ryan. This is one of many stories about the fundamentals in the field of computer graphics. I am relatively new in the field. As I continuously learn, I would like to share my knowledge. I hope this would also serve as an inspiration to other people. Please follow, recommend, or add your thoughts in a response. Thank you.