-
-
Notifications
You must be signed in to change notification settings - Fork 4
A.01 Vectors
A coordinate system (or frame) is a system that uses one or more numbers (also called coordinates) to uniquely determine a position, provided that we define an origin, a unit of measurement and a positive direction. The use of a coordinate system allows problems in geometry to be translated into problems about numbers, and vice versa.
We can determine a position

For example,
In the plane, two perpendicular lines (also called axes) are chosen, and the coordinates

For example, the point
In three dimensions, three mutually orthogonal axes are chosen and the three coordinates
You can also see the coordinates

Depending on the direction and order of the axes, a three-dimensional system may be a right-handed or a left-handed system.

Usually the y-axis points up, the x-axis points right while the z-axis points forward in a left-handed coordinate system (backward in a right-handed frame). That’s not a strict rule, though. Sometimes, you can have the z-axis points up. In that case, the y-axis points backward in a left-handed system (forward in a right-handed one). You can always switch from a y-up to a z-up configuration with a simple transformation, but there's no point in providing further details here as we will mostly use a y-up configuration. Typically, with DirectX we will use a left-handed coordinate system. However, again, that’s not a strict rule: you can also use a right-handed coordinate system.
In the plane, a ray from the origin is chosen (the ray is often called polar axis, while the origin is called pole). The coordinates

In three dimensions, with the coordinates

Spherical coordinates take this a step further by converting the pair of cylindrical coordinates

A point in the plane may be represented in homogeneous coordinates by a triple
Vectors describe quantities that have both a magnitude and a direction, such as displacements, forces and speed. In computer graphics, vectors are extensively used to specify the location of objects in the scene and the direction of their movements (as well as the direction of light rays, or the normal of surfaces). Moreover, vectors are also used to specify force and speed (especially if you are going to implement a physics engine).
A vector can be represented geometrically by an arrow, where the length indicates the magnitude and the aim indicates the direction of the vector.

Since we need to manipulate vectors with a computer, we are not particularly interested in this geometric definition, although. Fortunately, we can also define vectors numerically with tuples (a finite sequence of numbers). To do that, we need to bind vectors to the origin of a Cartesian system (that is, you have to translate a vector without changing magnitude and direction until its tail coincides with the origin).

At that point, we can use the coordinates

When only magnitude and direction of a vector matter, then the point of application is of no importance, and the vector is called free vector. On the other hand, a vector bound to a point is called bound vector. The numerical representation of a bound vector is only valid in the system where you bind it. If you bind the same free vector to different systems, the numerical representation changes as well.

This is an important point because if you define a vector by its coordinates, those coordinates are relative to a specific frame of reference. Then, we can conclude that two vectors
We can also define some interesting operations that can be done with vectors. For example, addition, subtraction, and three different types of multiplication.
Numerically, the sum of two vector
The addition may be represented geometrically by placing the tail of the arrow

The difference of two vector
The subtraction may be represented geometrically by bounding

We can multiply a vector
Geometrically, this is equivalent to scale a vector (that’s why real numbers are often called scalars). If

Below are some of the properties of vector addition and scalar multiplication:
| Commutative (vector) | |
| Associative (vector) | |
| Additive Identity |
|
| Distributive (vector) | |
| Distributive (scalar) | |
| Associative (scalar) | |
| Multiplicative Identity |
|
Now we can define the length of a vector

We have that
Sometimes, only the direction of a vector is important. In that case, we can normalize the vector so as to make its length 1. Usually, the symbol
We can verify that
Three unit vectors are of particular importance:

This form of vector multiplication results in a scalar value (that’s why it’s also called scalar product). The dot product of two vector
So, the dot product of two vectors is a sum of products of the corresponding components. Below are some of the properties of the dot product:
| Commutative | |
| Distributive | |
| Square of a vector length |
The associative property doesn’t apply since
From the law of cosines
Indeed, if we set
From equation
- If
$(\mathbf{u}\cdot\mathbf{v}) = 0$ then the angle$\theta$ between$\mathbf{u}$ and$\mathbf{v}$ is$90°$ (that is, they are orthogonal:$\mathbf{u}\ \bot\ \mathbf{v}$ ) - If
$(\mathbf{u}\cdot\mathbf{v}) > 0$ then the angle$\theta$ between$\mathbf{u}$ and$\mathbf{v}$ is less than$90°$ - If
$(\mathbf{u}\cdot\mathbf{v}) < 0$ then the angle$\theta$ between$\mathbf{u}$ and$\mathbf{v}$ is greater than$90°$
To conclude this section we will prove the law of cosines
Let
$\mathbf{a}$ be the vector from$C$ to$B$ ,$\mathbf{b}$ the vector from$C$ to$A$ , and$\mathbf{c}$ the vector from$A$ to$B$ .
We have that
$\mathbf{c}=\mathbf{a}-\mathbf{b}\quad$ (subtration of two vectors)Squaring both sides and simplifying
$|\mathbf{c}|^2=|\mathbf{a}-\mathbf{b}|^2$
$|\mathbf{c}|^2=(\mathbf{a}-\mathbf{b})\cdot (\mathbf{a}-\mathbf{b})\quad\quad\quad\quad\quad\quad\quad\quad$ (square of a vector length)
$|\mathbf{c}|^2=|\mathbf{a}|^2+|\mathbf{b}|^2-2\ \mathbf{a}\cdot\mathbf{b}\quad\quad\quad\quad\quad\quad\quad$ (distributive law of the dot product)
$|\mathbf{c}|^2=|\mathbf{a}|^2+|\mathbf{b}|^2-2\ |\mathbf{a}|\ |\mathbf{b}| \cos{\theta}\quad\quad\quad\quad$ (equation (1))
We can define the orthogonal projection of a vector

From trigonometry, we know that the adjacent side can be derived from the hypotenuse, multiplied by the cosine of the angle between adjacent side and hypotenuse. In this case, we have
with
Thanks to the orthogonal projection, we can write a generic bound vector
Indeed, we have
Also, note that

You can also see it as a sum of scaled vectors: we scale
Remember that you can also see it as a sequence of three translations: starting from the origin of the frame, we move
As stated earlier, the components of a bound vector are the coordinates of the arrowhead inside a frame. This implies we can use bound vectors to uniquely identify all the points of a frame. And indeed, we will use vectors to specify points as well. However, we still need a way to differentiate between vectors and points as they are not interchangeable. Observe that, for vectors, only direction and magnitude are important, so the point of application is irrelevant. On the other hand, points uniquely identify a location, so they only make sense if bound to the origin of a frame. Moreover, you can subtract points to get a vector that specifies how to move from a point to another. And you can also add a point and a vector to get a vector that specifies how to move a point to another location. However, unlike vectors, the addition of points doesn’t make any sense: you get the diagonal of a parallelogram, which doesn't mean anything geometrically. In short, think of vectors as free vectors, while considering points as bound vectors. So, if you have a vector
work in progress
