Prerequisites
- Graph Theory
- Shortest Path
Tools
This module discusses several algorithms that calculate various geometric properties, mostly based on only two operations described below: cross product and arctangent.
Cross Product
The cross product of u and v is written as u x v. Computationally, the cross product of two three-dimensional vectors u and v is the vector determinant of the following matrix (where i, j, and k are unit vectors in the x, y, and z directions respectively):
| i j k |
| ux uy uz |
| vx vy vz |
That equation works out to:
(uyvz-vyu z)i + (uzvx-u xvz)j + (uxv y-uyvx)k
This definition can be used for vectors in two dimensions by using three-dimensional vectors with a z component of 0. The resulting vector will only have a z value.
The cross product has three properties:
- The cross product of two vectors is perpendicular to both vectors.
- The length of the cross product is equal to the product of:
- the length of u,
- the length of v, and
- the sine of the angle between the vectors.
Of the two different directions that are perpendicular to both u and v, the direction the cross product points depends on whether u is ``to the right'' of v or ``to the left.''
Dot product
The dot product of two vectors u and v is a scalar written as u · v. Computationally, it is defined in three dimensions as: uxvx + u yvy + uzv z
The dot product is actually equal to the product of:
- the length of u
- the length of v
- the cosine of the angle between u and v.
Presuming u and v are non-zero, if the dot product if negative, u and v make an angle greater than 90 degrees. If it is zero, then u and v are perpendicular. If u cdot v is positive, then the two vectors form an acute angle.
Arctangent
The arctangentfunction calculates the (an) angle whose tangent is its argument and generally returns a real number between -pi/2 and pi/2. An additional function in C, atan2, takes two arguments: a DELTA y