Help end child hunger

Dot Product

 
Prev: Cross Product Next: Vector Projection
 

The dot product, aka inner product, takes two vectors and returns a scalar value. It is an easy way to compute the cosine between two vectors.

The equation bellow shows how to compute the inner product of two vectors v1 and v2. The operation is commonly represented by “.”.

    	v1 . v2 = v1x*v2x + v1y*v2y + v1z*v2z

The relation with the cosine of the angle between v1 and v2 is given by

	v1 . v2 = |v1| |v2| * cos(a)

From the above we also know that the inner product of two vectors is 0 (zero) either if any of the vectors is null, or if the vectors are orthogonal, i.e. the angle is 90 degrees (see also the cross product).

Bellow is a list of some properties of the inner product:

        v1 . v2 = v2 . v1
        v1 . (v2 + v3) = (v1 . v2) + (v1 . v3)

The inner product can be defined as a macro in C:

#define innerProduct(v,q) \

		((v)[0] * (q)[0] + \
		(v)[1] * (q)[1] + \
		(v)[2] * (q)[2])

 

Prev: Cross Product Next: Vector Projection
 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: