to eAlerts

for Geom Site



Vector Products

by Dan Sunday



Dot Product, 2D Perp Operator, 2D Perp Product, 3D Cross Product, 3D Triple Product

The Dot Product

The dot product (aka inner product or scalar product) of two vectors, v=(vi) and w=(wi) , 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



For example, if v=(v1,v2) and w=(w1,w2) are 2D vectors, then: v.w=v1w1+v2w2.

The dot product has the properties:


[Vector Length]


[Scalar Association]




[Additive Distribution]


[Cauchy-Schwarz Inequality]

An amazing mathematical formula for the dot product is:


where theta 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 cos-theta of the angle between two vectors, the following product of two normalized unit vectors is convenient:


It is useful to note that when abs-v=abs-w=1, then dot-v.w=cos.

PIC_Cosine-LawIt 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 theta between their edges, as shown in the diagram, then we can calculate c. Define the vectors v=B-C and w=A-C, corresponding to the sides a and b. Then, the side c corresponds to the vector v-w=B-A, 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 u_dot_w 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: v_dot_w=0. So this is a very simple and efficient test for perpendicularity. Because of this, for any vector v=(v1...vn) 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, v_n-flip12, v_n-flip23, 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 v=(v1,v2,v3), the two vectors w1=(-v2,v1,0) and w2=(0,-v3,v2), 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 theta-abs-le-180:



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



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:




[Preserves length]


[Scalar Association]





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 perp_prod_symbol, and given by:

2D Perp Product





Some properties of the 2D perp product are:




[Scalar Association]




[Additive Distribution]


[Lagrange Identity]

Also, for the 2D perp product, we have another amazing formula:


which can be used to compute sin-theta from v and w. In particular, if abs-v=abs-w=1, then perp-v.w=sin.

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 v=P1-P0 and w=P2-P0. Then, since a triangle is half of a parallelogram, we get the (signed) area of DELTA-P0P1P2 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 P0P1 the point P2 lies on: it is left side of P0P1 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 theta-abs-le-180:



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 v=(v1,v2,v3) and w=(w1,w2,w3). It is denoted by a cross_prod_symbol, and is given by:

3D Cross Product





The cross product has the properties:




[Scalar Association]




[Additive Distribution]




[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 theta 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 v_x_w-abs 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 DELTA-P0P1P2, with edge vectors v=P1-P0 and w=P2-P0, 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 v_x_w is also a unit vector since sin(90-deg) = 1. Thus, the three vectors v, w, and v_x_w 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 v=(v1,v2) in 3D space by appending a third coordinate equal to 0, namely: v,0=(v1,v2,0). Then, for two 2D vectors v and w, the embedded 3D cross product is: v,0_x_w,0=(0,0,v_perp_w), 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



This product has the properties:


[Even-Parity Invariant]





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 v_x_w-abs is the area of the base (parallelogram), and the projection of u onto the normal vector v_x_w gives a perpendicular altitude with height = abs-u_cos. 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 delta4_P0P1P2P3 with 4 vertices Pi-3Dcoords-xyz for i=0,3. The volume of this tetrahedron is 1/6 that of the parallelepiped spanned by the vectors u=P1-P0, v=P2-P0, and w=P3-P0. This gives:



Previous: Points and Vectors

NavLeft NavRight

Next: Summary Sheet


© Copyright 2012 Dan Sunday, 2001 softSurfer