The Dot Product
The dot product (aka inner product or scalar product) of two vectors, and , is defined as the (scalar) real number given by the sum of the products of their corresponding coordinates. This operation is denoted by a dot, and given by:
 |
 |
|
Dot Product Definition
|
|
|
|
|
For example, if and are 2D vectors, then: .
The dot product has the properties:
|

|
[Vector Length]
|
|

|
[Scalar Association]
|
|

|
[Commutation]
|
|
|
[Additive Distribution]
|
|

|
[Cauchy-Schwarz Inequality]
|
|
An amazing mathematical formula for the dot product is:
where is the angle between the vectors v and w. This formula is used extensively in computer graphics since it speeds up computation in many situations by avoiding direct usage of an inefficient trigonometric function. Further, to compute of the angle between two vectors, the following product of two normalized unit vectors is convenient:

It is useful to note that when , then .
It is interesting that the dot product cosine formula is equivalent to the well-known trigometric identity known as “The Cosine Law”. Say we have a triangle with vertices A, B, C, and the side opposite each vertex has length a, b, c respectively. If we know a and b, and the angle between their edges, as shown in the diagram, then we can calculate c. Define the vectors and , corresponding to the sides a and b. Then, the side c corresponds to the vector , and we can calculate:

Similarly, given the Cosine Law, one can derive the vector dot product cosine formula. Amazingly, the early Greeks actually knew the Cosine Law [Euclid’s Elements, Book 2, Prop 12 and 13], even though they did not have algebra and trigonometry at the time. For the acute angle case, it was stated in purely geometric terms as:
Proposition 13. In acute-angled triangles the square on the side opposite the acute angle is less than the sum of the squares on the sides containing the acute angle by twice the rectangle contained by one of the sides about the acute angle, namely that on which the perpendicular falls, and the straight line cut off within by the perpendicular towards the acute angle.
Another very useful fact about the dot product cosine formula (implicitly used in Euclid’s Prop 2-13) is that it can be interpreted geometrically as the projection of one vector onto the other. So, if u is a unit vector, then is the length of the perpendicular projection of w onto u, as shown in the diagram:
Further, when two vectors v and w are perpendicular, they are said to be normal to each other, and this is equivalent to their dot product being zero, that is: . So this is a very simple and efficient test for perpendicularity. Because of this, for any vector one can easily construct perpendicular vectors by zeroing all components except 2, flipping those two, and reversing the sign of one of them; for example, , , etc. The dot product of any of these with the original vector v is always = 0, and thus they are all perpendicular to v. For example, in 3D space with , the two vectors and , when nonzero, are a basis for the unique plane through the origin and perpendicular to v.
Beyond this, another important and useful consequence of the dot product formula is that, for :


The 2D Perp Operator
Based on the preceding, we can define an operator on the 2D plane that gives a counterclockwise (ccw) normal (i.e.: perpendicular) vector of v to be:
 |
 |
|
2D Perp Operator Definition
|
|
|
|
|
This operator is called the perp operator. The perp vector v is the normal vector pointing to the left (ccw) side of the vector v as shown in the diagram:

Some properties of the perp operator are:
|

|
[Perpendicular]
|
|

|
[Preserves length]
|
|

|
[Scalar Association]
|
|

|
[Linear]
|
|
|
[Anti-potent]
|
|
The 2D Perp Product
Also in 2D space, there is another useful scalar product of two vectors v and w, the perp product (aka the 2D exterior product, or outer product), which is denoted with a , and given by:
 |
|
2D Perp Product Definition
|
|
|
 |
 |
|
where
|
|
|
|
|
Some properties of the 2D perp product are:
|
|
[Nilpotent]
|
|

|
[Scalar Association]
|
|

|
[Antisymmetric]
|
|

|
[Additive Distribution]
|
|

|
[Lagrange Identity]
|
|
Also, for the 2D perp product, we have another amazing formula:
which can be used to compute from v and w. In particular, if , then .
Moreover, geometrically the perp product gives the (signed) area of the 2D parallelogram spanned by v and w, as shown in the diagram:
So, to compute the area of a 2D triangle with vertices P0, P1, P2, define the edge vectors at P0 as and . Then, since a triangle is half of a parallelogram, we get the (signed) area of as:

which is a very efficient formula for area. This signed area is positive when the vertices P0, P1, P2 are oriented counterclockwise and is negative when they are oriented clockwise, so it can be used to test for the orientation of a triangle. This can also be used to test for which side of the directed line through the point P2 lies on: it is left side of when the area is positive; it is on the line when the area = 0; and it is on the right side when the area is negative.
Similarly, the 2D perp product can be used to determine which side (left or right) of one vector another vector is pointing, since for :


The 3D Cross Product
The 3D cross product (aka 3D outer product or vector product) of two vectors, v and w, is only defined for 3D vectors, say and . It is denoted by a , and is given by:
The cross product has the properties:
|

|
[Nilpotent]
|
|

|
[Scalar Association]
|
|

|
[Antisymmetric]
|
|

|
[Additive Distribution]
|
|

|
[Normality]
|
|

|
[Lagrange Identity]
|
|
However, the cross product is not associative with itself, and it is not distributive with the dot product. Instead, one has the following formulas. These are not often used in computer graphics, but sometimes can streamline computations since dot products are easier to compute than cross products. Note that the formulas for left and right association are different.
|

|
[Left Association]
|
|

|
[Right Association]
|
|

|
[Dot-Cross Association]
|
|

|
[Generalized Lagrange Identity]
|
|

|
[Jacobi Identity]
|
|
Using the Generalized Lagrange Identity, we can compute that:

which demonstrates the important cross product formulas:
where is the angle between v and w. The vector u is perpendicular to both v and w, and geometrically points outward from the vw-plane using a right-hand rule. Further, the magnitude is the area of the parallelogram spanned by v and w as shown in the following diagram:
This fact makes the cross product very useful for doing 3D area computations. For example, for a 3D triangle , with edge vectors and , one can compute its area as:

Another important consequence of the cross product formula is that if v and w are perpendicular unit vectors, then is also a unit vector since sin( ) = 1. Thus, the three vectors v, w, and form an orthogonal coordinate frame of reference (or basis) for 3D space. This is used in 3D graphics to simplify perspective calculations from observer viewpoints.
Finally, in 2D space, there is a relationship between the embedded cross product and the 2D perp product. One can embed a 2D vector in 3D space by appending a third coordinate equal to 0, namely: . Then, for two 2D vectors v and w, the embedded 3D cross product is: , whose only non-zero component is equal to the perp product.
The 3D Triple Product
Another useful geometric computation is the 3D (scalar) triple product, which is given by:
 |
 |
|
3D Triple Product Definition
|
|
|
|
|
This product has the properties:
|

|
[Even-Parity Invariant]
|
|

|
[Anti-Symmetric]
|
|

|
|
|
Geometrically, the triple product is equal to the volume of the parallelepiped (the 3D analogue of a parallelogram) defined by the three vectors u, v and w starting from the same corner point as shown in the diagram:
To understand this, recall that is the area of the base (parallelogram), and the projection of u onto the normal vector gives a perpendicular altitude with height = . The volume is then the product of the base area with this height, which yields the formula. Further, this is a signed volume, whose sign depends on the orientation of the “coordinate frame” vectors u, v, and w.
Using this formula, we can also get the volume of a 3D tetrahedron with 4 vertices for i=0,3. The volume of this tetrahedron is 1/6 that of the parallelepiped spanned by the vectors , , and . This gives:
|