libgfx: Vector Math
Author: Michael Garland

## Vector Math

### class Vec4

This class implements a 4-dimensional real-valued vector. Individual elements are represent with `double` precision floating point numbers. To use the `Vec4` class you must include the header

        #include <gfx/vec4.h>

#### Constructor Methods

The `Vec4` class defines the following set of constructors:

        Vec4();                                        // Initializes vector to (0 0 0 0).
        Vec4(double x, double y, double z, double w);  // Initializes vector to (x y z w).
        Vec3(double s);                                // Initializes vector to (s s s s)

        Vec4(const Vec4& v);                           //
        Vec4(const float  v[4]);                       // These copy values from v
        Vec4(const double v[4]);                       //

        Vec4(const Vec3& v, double w);                 // Initializes vector to (v[0] v[1] v[2] w)

#### Specialized Functions

In addition to the standard functions provided by all vector classes, the `Vec4` class defines certain specialized functions which operate only on 4-D vectors.

The cross product of three 4-vectors `u, v, w` is a fourth vector which is perpendicular to all of `u, v, w`. It can be computed with the function call

        t = cross(u, v, w);

Since 4-D vectors are frequently used to represent 3-D homogeneous coordinates, a projection function is provided.

        Vec3 proj(const Vec4& v);

This routine takes a homogeneous vector (x y z w) and returns the corresponding 3-vector (x/w y/w z/w). If w is 0 then the vector (x y z) is returned.