Direction vector

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In mathematics, a direction vector that describes a line D is any vector

where and are two distinct points on the line. If v is a direction vector for D, so is kv for any nonzero scalar k; and these are in fact all of the direction vectors for the line D. Under some definitions, the direction vector is required to be a unit vector, in which case each line has exactly two direction vectors, which are negatives of each other (equal in magnitude, opposite in direction).

Parametric equation for a line[edit]

In Euclidean space (any number of dimensions), given a point p0 and a (nonzero) direction vector d, a line is defined parametrically as the set of points p where p = p0+ td, and where the parameter t varies between -∞ and +∞. This line formalism demonstrates use of direction vector d to specify the run direction of the line.

Generative versus predicate forms[edit]

The line equation p0+td is a generative form, but not a predicate form. Points may be generated along the line given values for p0, t and d:

pp0 +td

However, in order to function as a predicate, the representation must be sufficient to easily determine ( T / F ) whether any specified point p is on the given line [ p0, d ]:

p == p0 +td ( == evaluates to true if quantities on both sides evaluate numerically equal, false otherwise)

If you substitute a known point p into the above predicate, it cannot be evaluated for equality because t was not supplied, only [ p0, d ] and p.

Predicate form of 2D line equation[edit]

Run direction and orientation of 2D line
2D line equation (predicate form)

An example of a predicate form of the vector line equation in 2D is:[1]

po == L

Here, the line is represented by two features: o and L, shown graphically in the illustration.

o is the line's orientation, a normalized direction vector (unit vector) pointing perpendicular to its run direction (see illustration).

The orientation is computed using the same two quantities dx and dy that go into computing slope m:

o ← ( dy, -dx ) norm = ( dy, -dx ) / || ( dy, -dx ) || (orientation of a 2D line)

Orientation o has the advantage of not overcompressing the information vested in dx and dy into a single scalar as slope does, avoiding the need to appeal to infinity as a value. Numerical algorithms benefit by avoiding such ill-behaved exceptions (e.g. , slope of a vertical line).

The 2nd feature of a 2D line represented this way is its location L. Intuitively and visually, L is the signed distance of the line from the origin (with positive distance increasing along direction o). Orientation must be solved before determining location. Once o is known, L can be computed given any known point p on the line:

L ← po (location of a 2D line)

Lines may be represented as feature pair ( o , L ) in all cases. Every line has an equivalent representation ( -o , -L ).

To determine if a point p is on the line, plug the value of p into the vector line predicate and evaluate it:

po == L (vector line predicate)

In computation, the predicate must tolerate finite math error by incorporating an epsilon signifying acceptable equality:

abs (po - L) < epsilon (finite precision vector line predicate)

The predicate form for 2D lines can be extended to higher dimensions, using coordinate rotation (by matrix rotation). The general form is:

R p == L

where R is the matrix rotation that aligns the line with an axis, and L is the invariant vector Location of points on the line under this rotation.

See also[edit]


  1. ^ Bierre, Pierre (2010). Flexing the Power of Algorithmic Geometry (1st ed.). Spatial Thoughtware. ISBN 978-0-9827526-0-9. 

External links[edit]