2.1 Dot Product

Vectors were based on the intuitive idea of a directed magnitude, but as yet we have no method to calculate either the magnitudes or the directions of vectors. We now remedy this situation by defining a new vector operation: the dot product. We shall write |v| for the magnitude (or length) of a vector v; |v| is therefore a nonnegative real number. Now let v and w be two vectors, and let Ų be the angle (the one < 180°) between the two vectors when they are positioned so that their tails coincide. The dot product of v and w is defined by:

v.w = |v||w|cosŲ (2.1)

If the vectors are expressed in coordinates, relative to an orthonormal basis (ie a basis where all the basis vectors are orthogonal and have length 1), then the formula for the dot product in n-dimensional space can be shown to be:

v.w = v1w1 + v2w2 + ... + vnwn (2.2)

Notice that the dot product takes two vectors as input and yields a scalar as output. The dot product of two orthogonal vectors is 0, and if two nonzero vectors v and w have v.w = 0, they must be orthogonal. This is very important for people like us: it means that the dot product provides a test for orthogonality. Furthermore, if v and w have the same direction, then v.w = |v||w|cos0 = |v||w|. In particular, for any vector v,

v.v = |v||v|cosŲ = |v||v| = |v|2 (2.3) ie
|v| = (2.4)

so you can compute the magnitude of a vector v by taking the square root of v.v. To compute the angle Ų between two vectors v and w, we rearrange Formula (2.1):

cosŲ = v.w / |v||w| (2.5)

and so

Ų = arccos ( v.w / |v||w| ) (2.6)

where arccos (the arc cosine) is, roughly speaking, the inverse function that "undoes" cosine, so that if y = cos(x) then x = arccos(y).

We have crated a Visual Basic program called OMNIVOR to compute the rotations of the eyes. A module od OMNIVOR is GEOSUB (for GEOmetric subroutines). In GEOSUB, there is a function VDOT (meaning Vector DOT product) that takes two vectors as inputs and computes their dot product using Formula (2.2). There is also a VMAG (Vector MAGnitude) function that takes a single vector as input and computes its magnitude using Formula (2.4). The function VANG (Vector ANGle) takes two vectors and computes the angle between them in degrees. (A technical detail: the ARCCOS function in OMNIVOR, which VANG uses to compute angles according to Formula (2.6), yields angles in radian measure, which is more convenient than degree measure for most calculations. Since 1 radian = 180° / p = 57.3°, VANG multiplies this angle by the conversion factor RTOD (Radians TO Degrees), which equals 180 / p, to switch to degree measure). The reverse conversion factor DTOR (Degrees TO Radians), which equals p / 180, is used throughout OMNIVOR to convert degree measure to radians.)

The dot product has the following properties which are useful for simplifying algebraic formulas:

DP1. v.w = w.v
DP2. u.(v + w) = u.v + u.w
DP3. s(u.v) = (su) . v = u.(sv)
DP4. v.v > 0 if v 0 and v.v = 0 if v = 0

2.2 Some Applications of the Dot Product

Example 2.1. Given the vectors v = (4, 3, 0) and w = (-5, 12, 0), find v.w and calculate the angle q between v and w.
Solution. Using Formula (2.6), we have v.w = v1w1 + v2w2 + v3w3 = (4)(-5) + (3)(12) + (0)(0) = -20 + 36 + 0 = 16; v.v = (4)(4) + (3)(3) + (0)(0) = 16 + 9 + 0 = 25 and so |v| = 5; w.w = (-5)(-5) + (12)(12) + (0)(0) = 25 + 144 + 0 = 169 and so |w| = 13. Thus q = arccos (v.w)/(|v||w|) = arccos (16 / (5)(13)) = arccos (16/65) = arccos .246 = 1.322 radians = 75.75°.

Problem 2.1. The following are the axes of the six extraocular muscles of the right eye (ie the vectors of length 1, lying along the axes about which the individual muscles rotate the eye, and oriented according to the right hand rule) expressed relative to a basis of orthogonal vectors of length 1 pointing forward, left and up. Write a computer program, using a dot multiplication function you have written yourself and taking the ARCCOS, ARCSIN and VANG functions from OMNIVOR module GEOSUB, and use the program to compute the dot products of, and angles between, the muscle vectors. Then answer the questions below:

LR = .232 -.117 -.966
MR = -.251 .001 .968
SR = -.524 -.851 -.027
IR = .449 .891 .068
SO = -.858 .513 -.034
IO = .810 -.565 .158

i. Which pair of muscles have their pulling directions most nearly parallel, and what is the angle between them? ii. Which two are most nearly orthogonal, and what is the angle? iii. If the head were rotating with angular velocity (2, -1, 3) and you had to deliver a torque with only one muscle to counterrotate the eye, which muscle would you choose and what would be the angle between the desired and actual torque directions? (Assume that the eye velocity induced by a muscle torque has the same direction as the torque).

Example 2.2. Find the vector u of length 1 with the same direction as v = (2, 2, 1). This process of computing u from v is called normalizing v.

Solution. u = v / |v| = v / = v / 3 = (2/3, 2/3, 1/3).

In OMNIVOR, the subprogram VNORM takes a vector as input and normalizes it. If you write CALL vnorm(v(), n()) then the vector n is the normalized version of v. You can also write write CALL vnorm(v(), v()) if you want the normalized output vector to have the same name as the input; in this case, the input vector is "overwritten" and lost, and the new v, after the subprogram has run, is the normalized vector.
Technical point: perhaps you are wondering why VDOT, VMAG and VANG are all functions in OMNIVOR, but VNORM is a subprogram (also sometimes called a subroutine). I don't know the technical details behind this, but briefly, a function in Basic takes inputs, which may be scalars, vectors, strings or whatever, and yields an output which is a number. Two important points are that you don't have to choose any name for this output number, and that the function expression can be used directly inside other equations. For example if you want your computer program to make s equal to the sum of v.w and x.y, you can simply write

s = vdot(v(), w()) + vdot(x(), y())

In contrast, a subprogram can yield many outputs which can be scalars, vectors, strings and so on (not just a single number as with a function), but the outputs must be named, and the subprogram call must occupy a line all to itself in the computer program: it cannot be plunked directly into a formula as was done with the function VDOT above. If you had a subprogram, called VECDOT, to do dot products, and wanted to compute the same sum as above, you would have to write something like:

CALL vecdot(v(), w(), vdotw)
CALL vecdot(x(), y(), xdoty)
s = vdotw + xdoty

This is less compact and clear than the VDOT version, so whenever possible (ie whenever we are calculating single scalar outputs) we use a function instead of a subprogram. In the case of VNORM and many other procedures, however, we are calculating nonscalar (ie vector, matrix etc.) outputs, and are therefore obliged to use subprograms. Some computer languages other than BASIC allow functions with vector etc. outputs.

Problem 2.2. Find a unit vector bisecting the angle between (1, 0, 0) and (.87, .5, 0). Do the same for (1, 0, 0) and (4, 0, 3).

2.3 Projections

For many applications it is useful to decompose a vector v into a sum of two parts, one parallel to a specified vector a and the other orthogonal to a. The part parallel to a is written proja v, and is called the orthogonal projection (or simply the projection) of v on a, or sometimes the vector component of v along a (not to be confused with the plain old components ie coordinates of v).

If q is the angle between v and a, then as Figure 2.2 shows, the magnitude of proja v is the absolute value of |v|cosŲ; that is Figure 2.2

| proja v | = | |v|cosŲ|
= | |v||a|cosŲ|
= | |v||a|cosŲ / |a| |
= | v.a / |a| |. (2.7)

The direction of proja v is obviously the same as or exactly opposite that of a, depending on whether v.a is positive or negative. That is, proja v is v.a / |a| times the unit vector (ie the vector of length 1) lying along a:

proja v = (v.a/|a|)(a/|a|) = (v.a/a.a)a (2.8)

Try to convince yourself (perhaps with a picture) of the important fact that projv a is the vector parallel with a that is the closest to v, ie it is the best approximation to v aligned with a.

The vector component of v orthogonal to a is simply

v - proja v. (2.9)

Problem 2.3. Prove that, as the name suggests, v - proja v is orthogonal to a.

Problem 2.4. Find the projection of IO on LR.

Problem 2.5. Convince yourself that, if we represent the magnetic field with a vector m, and an eye coil with a vector c orthogonal to its plane, then the signal from the coil in the field is c.m.

2.4 Cross Product

A second type of vector multiplication which will be important for us is the cross product. This operation takes two vectors v and w as input and yields a third vector, v × w, orthogonal to v and w (or in other words orthogonal to the plane containing v and w). Note the contrast with the dot product, which also takes two vectors but yields a scalar as output. Another interesting contrast with the dot product, and in fact with all the other vector operations we'll encounter, is that the cross product is defined only for 3-D space, because only in three dimensions is there a unique line (counting all parallel lines as equivalent) orthogonal to a given plane; in two dimensions, there is no line orthogonal to the plane, and in four or more dimensions there are infinitely many lines orthogonal to any given plane.

The magnitude of v × w is given by the formula:

| v × w | = | |v||w|sinŲ |, (2.10)

where Ų is the angle between v and w. When two vectors are parallel, the angle between them is either 0 or 180°. Since sin0 = sin180 = 0, it follows that the cross product of parallel vectors is the zero vector 0 (in contrast to the dot product, where orthogonal inputs yield a zero output).

The cross product of v and w is oriented according to a version of the right hand rule: if you point your right thumb in the direction of v × w, then your fingers curl round in the direction from v toward w. It follows from this rule that w × v has the opposite direction from v × w, ie cross multiplication is not commutative but anticommutative: changing the order of the inputs changes the sign of the output.

Problem 2.6. The standard basis, which we use to represent vectors in 3-D space, has e1 pointing forward, e2 left and e3 up. Show that, as a result of this choice of vectors, we have e1 × e2 = e3.

An orthonormal coordinate system with the property demonstrated in Problem 2.6 is called right handed. It is important to work in a right handed coordinate system because that's what everybody else does. All the standard textbook formulas for cross products, quaternions and so on assume the use of a right handed coordinate system. This, ultimately, is the explanation for some peculiar features of the coordinate system we use to describe eye rotations. For example, the reason that the positive direction for vertical rotation is downward rather than upward is that e2 points left, rather than right, and by the right hand rule a leftward-pointing quaternion vector represents a downward rotation.

In a right handed coordinate system, the formula for the cross product is

v × w = (v2w3 - v3w2)e1 + (v3w1 - v1w3)e2 + (v1w2 - v2w1)e3. (2.11)

The main algebraic properties of the cross product (in any coordinate system) are summarized below:

XP1. v × w = -(w × v)
XP2. u × (v + w) = u × v + u × w
XP3. s(v × w) = (sv) × w = v × (sw)
XP4. v × v = 0
XP5. (u × v) × w u × (v × w)
XP6. u × (v × w) = (u.w)v - (u.v)w

XP1 says that the cross product is anticommutative: changing the order of the inputs changes the sign of the output. XP2 and XP3 are like properties DP2 and DP3 of the dot product. XP4 is simply a special case of the fact that the cross product of parallel vectors is the zero vector. XP5 says that, unlike almost all other operations we'll consider in these lectures, cross multiplication is not associative, ie we have to be careful about the placement of parentheses in formulas involving cross products. XP6 is a useful relation between dot and cross products.

Another expression for the laws of cross multiplication in a right handed coordinate system can be obtained by expanding on Problem 2.6 and using the properties XP. Writing i for e1, j for e2 and k for e3 (the usual notation for basis vectors in a 3-D right handed coordinate system) we can use Formula (2.11) to derive the following equations:

i × j = -j × i = k
j
× k = -k × j = i
k × i = -i × k = j. (2.12)

Using these equations and properties XP2 and XP3 we can cross multiply any two vectors. The equations (2.12) are conveniently represented using a circle as in Figure 2.3.

In OMNIVOR, cross multiplication is performed by the subprogram VCROSS in module GEOSUB. Why is VCROSS a subprogram while VDOT is a function?

2.5 Applications of the Dot and Cross Products

Problem 2.7. We can represent the gaze direction by a vector, called g, of length 1, pointing along the line of sight. Suppose you want to rotate your gaze line from 20° left to 20° right. To achieve this gaze shift most efficiently (ie with the smallest possible eye rotation) you should rotate your eye about an axis orthogonal to both the initial and final gaze directions. A. Use the cross product to compute a vector of length 1 lying along this axis (and directed according to the right hand rule). B. Find another axis you could use to rotate the gaze line from 20° left to 20° right. C. Repeat A and B for a gaze shift from 20° left to 20° up.

Problem 2.8. The following are three eye position vectors (expressed relative to straight ahead) from one subject measured during the random saccade task in magnetic field coordinates (ie the basis vectors e1, e2 and e3 are aligned with the directions of the three magnetic fields): a = (-.052, .108, .297), b = (.022, .068, -.122), c = (-.016, -.162, .091). Assume that this subject has a peculiar VOR which perfectly follows Listing's law. When the subject is rotating at 150° / s to the left (that is, about an axis parallel with the vertical magnetic field) while looking straight ahead, what is the best possible VOR response that is compatible with Listing's law?

Hints. We'll cover Listing's law in more detail later, but the following brief review of things you already know in some Socratic sense will make the Problem solvable. According to Listing's law, the eye position vectors relative to any reference position r all lie in a single plane VPr, called the velocity plane (or sometimes the displacement plane) of r. Listing's law requires that, when the eye is in any position, its velocity vector must lie in the velocity plane for that position. The eye position vectors a, b and c all lie in the velocity plane of the straight ahead eye position, so we know where this plane is. Your job is to compute the eye velocity vector in this plane that is as close as possible to the negative of head velocity, ie as close as possible to (0, 0, -150).

More Hints. A good way to specify a plane is to find the forward-pointing vector of length 1 orthogonal to the plane (the unit normal vector to the plane). In OMNIVOR, the unit normal vector to the velocity plane in reference position is calculated by the program section PF (for Plane Fit), and is called n. YOU can compute n by taking the cross product of any two of a, b and c, and then normalizing the result. (If you cross multiply the vectors in the wrong order, you will get the backward-pointing normal vector, but this won't actually matter for the present problem). If you then take the optimal VOR response vector, call it v = (0, 0, -150), and subtract the projection of v on n, you obtain x = v - projn v, which is the vector in the velocity plane that is closest to v (you might want to draw a picture to convince yourself of this fact), ie x is the answer you are looking for. For the average real subject, of course, the VOR response is neither v nor x, but something like the vector halfway between: (v + x) / 2.