This class implements a 3-dimensional real-valued vector.
Individual elements are represent with double
precision
floating point numbers. To use the Vec3 class you must
include the header
#include <gfx/vec3.h>
The Vec3 class defines the following set of constructors:
Vec3(); // Initializes vector to (0 0 0). Vec3(double x, double y, double z); // Initializes vector to (x y z). Vec3(double s); // Initializes vector to (s s s) Vec3(const Vec3& v); // Vec3(const float v[3]); // These copy values from v Vec3(const double v[3]); // Vec3(const Vec2& v, double z); // Initializes vector to (v[0] v[1] z)
In addition to the standard functions provided by all vector classes, the Vec3 class defines certain specialized functions which operate only on 3-D vectors.
The cross product of two vectors v, w is a third vector which is perpendicular to both v and w. It can be computed with either a function call or an overloaded operator
u = cross(v, w); // Equivalent ways of computing u = v ^ w; // the cross product of v and w.
Since 3-D vectors may be used to represent 2-D homogeneous coordinates, a projection function is provided.
Vec2 proj(const Vec3& v);This routine takes a homogeneous vector (x y w) and returns the corresponding 2-D vector (x/w y/w). If w is 0 then the vector (x y) is returned.