#include <vec3f.hpp>
Public Methods | |
| Vec3 (void) | |
| Default constructor. Note: does not initialize x, y, and z! | |
| Vec3 (const Type X, const Type Y, const Type Z) | |
| Three component constructor. | |
| Vec3 (const Vec3 &v) | |
| Copy constructor. | |
| Vec3 (const Type v[3]) | |
| Construct from array. | |
| void | Set (const Type X, const Type Y, const Type Z) |
| Set from components. | |
| void | Set (const Type v[3]) |
| Set from array. | |
| operator Type * () | |
| Type * CONVERSION. | |
| operator const Type * () const | |
| CONST Type * CONVERSION. | |
| int | operator== (const Vec3 &A) const |
| COMPARISON (==). | |
| Vec3 & | operator= (const Vec3 &A) |
| ASSIGNMENT (=). | |
| Vec3 | operator+ (const Vec3 &A) const |
| ADDITION (+). | |
| Vec3 | operator- (const Vec3 &A) const |
| SUBTRACTION (-). | |
| Type | operator * (const Vec3 &A) const |
| DOT-PRODUCT (*). | |
| Vec3 | operator/ (const Vec3 &A) const |
| CROSS-PRODUCT (/). | |
| Vec3 | operator^ (const Vec3 &A) const |
| ALSO CROSS-PRODUCT (^). | |
| Vec3 | operator * (const Type s) const |
| MULTIPLY BY SCALAR V*s (*). | |
| Vec3 | operator/ (const Type s) const |
| DIVIDE BY SCALAR (/). | |
| Vec3 | operator & (const Vec3 &A) const |
| COMPONENT MULTIPLY (&). | |
| Vec3 & | operator+= (const Vec3 &A) |
| ACCUMULATED VECTOR ADDITION (+=). | |
| Vec3 & | operator-= (const Vec3 &A) |
| ACCUMULATED VECTOR SUBTRACTION (-=). | |
| Vec3 & | operator *= (const Type s) |
| ACCUMULATED SCALAR MULT (*=). | |
| Vec3 & | operator/= (const Type s) |
| ACCUMULATED SCALAR DIV (/=). | |
| Vec3 & | operator &= (const Vec3 &A) |
| ACCUMULATED COMPONENT MULTIPLY (&=). | |
| Vec3 | operator- (void) const |
| NEGATION (-). | |
| Type | Length (void) const |
| LENGTH OF VECTOR. | |
| Type | LengthSqr (void) const |
| LENGTH OF VECTOR (SQUARED). | |
| Vec3 & | Normalize (void) |
| NORMALIZE VECTOR. | |
| Type * | Star () const |
| Returns the 'star' matrix for a vector. More... | |
| void | UpdateMinMax (Vec3 &Min, Vec3 &Max) const |
Update Min and Max to enclose this. More... | |
| void | CompleteOrthonormalBasis (Vec3 &U, Vec3 &V) const |
Construct an orthonormal basis from this. More... | |
| void | Print () const |
Dump the vector to stdout in a pretty way. | |
Public Attributes | |
| Type | x |
| Type | y |
| Type | z |
| The storage for the three components of the vector. | |
Static Public Attributes | |
| Vec3 | ZERO = Vec3<Type>(0,0,0) |
| This is a handy way to get the zero vector just use Vec3<Type>::ZERO. | |
Friends | |
| Vec3 | operator * (Type s, const Vec3 &v) |
| SCALAR MULT s*V. | |
Everybody in graphics has to write their own basic 3-vector class. And we're no exception. This one uses templates, so that with one definition of the class you can have a 3-vector of floats or doubles depending on how precise you are, or you can make 3-vectors of ints or unsigned char, handy for representing colors.
A couple of typedefs for common instatiations are provided by default: Vec3f, and Vec3d, the float and double versions, respectively.
|
||||||||||||||||
|
Construct an orthonormal basis from
Compute two unit vectors The algorithm works as follows: Find smallest component of L (this), zero it, negate one of the other two and swap them. Then normalize. Ex. if x1 is the smallest, assign (x2,y2,z2):=(0,z1,-y1) Clearly now v1 dot v2 = x1*0 + y1*z1 + z1*-y1 = 0; Zeroing out the smallest means that the magnitude of the remaining vector will be as big as possible so that when we normalize, we are safe from dividing by anything close to zero (unless *this was near 0 magnitude to begin with, in which case lack of precision can't be avoided) |
|
|||||||||
|
Returns the 'star' matrix for a vector.
This is the skew-symmetric matrix A such that A v ==
| 0 -z y|
| z 0 -x|
|-y x 0|
Return format is just an array in row-major (OpenGL/Fortran) order. That is [0, -z, y, z, 0, -x, -y, x, 0]. |
|
||||||||||||||||
|
Update A very handy routine for working with min-max or axis aligned bounding boxes. |
1.2.10 written by Dimitri van Heesch,
© 1997-2001