# 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.

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.

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.

### 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:

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, t**he 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.

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.

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**.

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

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

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.