Logo_iSurf_org

Subscribe
to eAlerts

for Geom Site
Updates

CLICK HERE

 

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
Definition

dot_prod-define

 

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

The dot product has the properties:

dot-vect-len

[Vector Length]

dot-scalar-assoc

[Scalar Association]

dot_prod-commute

[Commutation]

dot-distrib-left 

[Additive Distribution]

dot-abs-(v_dot_w).le.abs-v_abs-w

[Cauchy-Schwarz Inequality]


An amazing mathematical formula for the dot product is:

dot-v.w=abs-vw-cos


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:

cos=v-absv_dot_w-absw

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:

Eqn_Cosine-Law

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:

PIC_dot_proj-w
P2-P1=...=u_dot_w

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:

dot_prod_angle_inequal

PIC_dot_angles


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

perp_op_define

 

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:

PIC_perp-op-define

Some properties of the perp operator are:

perp_op_normal

[Perpendicular]

perp_op_length

[Preserves length]

perp_op_scalar-assoc

[Scalar Association]

perp_op_linear

[Linear]

perp_op_antipotent 

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

2D Perp Product
Definition

perp_prod_define

where

determ_abcd=ad-bc

 

Some properties of the 2D perp product are:

perp_prod_nilpotent 

[Nilpotent]

perp_prod_scalar-assoc

[Scalar Association]

perp_prod_antisymmetry

[Antisymmetric]

perp_prod_distrib-left

[Additive Distribution]

perp_dot_Lagrange-ID

[Lagrange Identity]


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

perp-v.w=abs-vw-sin


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:

PIC_perp_2D-Area
Area2D_vw=..

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:

Area_P0P1P2=perp-v-w-half

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:

perp_prod_angle_inequal

PIC_perp_angles


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
Definition

cross_prod_define

where

determ_abcd=ad-bc

 

The cross product has the properties:

cross_prod_nilpotent

[Nilpotent]

cross_prod_scalar-assoc

[Scalar Association]

cross_prod_antisym

[Antisymmetric]

cross_prod_add-distrib-left

[Additive Distribution]

cross_prod_nomal

[Normality]

cross_dot_Lagrange-ID1

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

cross_prod_left_assoc_uvw

[Left Association]

cross_prod_right_assoc_uvw

[Right Association]

dot_cross_assoc

[Dot-Cross Association]

cross_dot_Lagrange-ID2

[Generalized Lagrange Identity]

cross_prod_Jacobi-ID

[Jacobi Identity]


Using the Generalized Lagrange Identity, we can compute that:

cross_prod_proof=sin

which demonstrates the important cross product formulas:

cross_vxw=abs-vw-sin

 

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:

PIC_cross_3D-Area
Area3D_vw=..

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:

Area_P0P1P2=cross-v-w-half

 

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
Definition

triple_prod_define

 

This product has the properties:

triple_prod_permute

[Even-Parity Invariant]

triple_prod_antisym

[Anti-Symmetric]

triple_prod_triple-cross

 


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:

PIC_triple_3Dparal-Vol
Vol_uvw=triple-uvw=u_dot_(v-cross-w)

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:

PIC_triple_3Dtetra-Vol
Vol_P0P1P2P3=triple-uvw-sixth

 

Previous: Points and Vectors

NavLeft NavRight

Next: Summary Sheet

 

© Copyright 2012 Dan Sunday, 2001 softSurfer