#include <vec4.h>
It is stored as an array so ,that it can be, e.g. loaded directly into an OpenGL function. The fourth float is ignored when convenient, such as cross products and such. Dunno about lengths though. By default, not, perhaps.
Public Member Functions | |
Vec4 () | |
Default constructor zeroes array. | |
Vec4 (float *in) | |
Constructor for array of floats. | |
Vec4 (float x, float y, float z, float w) | |
Constructor for four seperate floats. | |
~Vec4 () | |
Empty destructor. | |
Vec4 (const Vec4 &other) | |
Copy constructor. | |
Vec4 & | operator= (const Vec4 &other) |
Equals operator. | |
float & | operator() (unsigned int i) |
Indexing operator. | |
float | operator() (unsigned int i) const |
Indexing operator. | |
Vec4 | operator+ (const Vec4 &other) const |
Add vectors, all cells. | |
Vec4 & | operator+= (const Vec4 &other) |
+= operator, all cells | |
Vec4 | operator- (const Vec4 &other) const |
Subtracts, all cells. | |
Vec4 & | operator-= (const Vec4 &other) |
Subtracts, all cells. | |
Vec4 | operator- (void) const |
Unary negating operator. | |
Vec4 | operator/ (const float &other) const |
Note: prints to cerr on divbyzero. | |
Vec4 & | operator/= (const float &other) |
Note: prints to cerr on divbyzero. | |
Vec4 | operator * (const float &other) const |
Multiplication. | |
Vec4 & | operator *= (const float &other) |
Multiplication. | |
Vec4 | operator * (const Matrix4x4 &other) const |
This is just a wrapper for the *= operator. | |
Vec4 & | operator *= (const Matrix4x4 &other) |
Multiply by matrix. | |
bool | operator== (const Vec4 &other) const |
Equality tester. | |
bool | operator!= (const Vec4 &other) const |
Inequality tester. | |
void | Zero (void) |
Zeroes array. | |
void | Print (void) |
Prints vector (as row) to cout. | |
float | Length (void) |
Calculates the length of the vector. | |
float | SqrLength (void) |
Calculates the square of the length of the vector. | |
void | Normalise (void) |
Make length of vector zero. | |
void | Clean (void) |
Clean out values that are near zero. | |
int | mainDir (void) |
Gives the axis in which the vector is most strongly pointing. | |
void | rotate (float xin, float yin, float zin) |
Rotates a vector. | |
Public Attributes | |
float | v [4] |
The data array. |
|
Calculates the length of the vector. Note: This ignores the fourth var.
|
Here is the call graph for this function:
|
Gives the axis in which the vector is most strongly pointing. This seems a bit esoteric, but useful in collision detection for projecting triangles onto 2D surfaces as choosing the axis carefully can increase accuracy.
|
|
Multiply by matrix. Rather vitally important, some might say. This assumes the bottom row of the matrix will be uninteresting. |
|
Indexing operator. This takes indices into the vector and returns a copy of the correct cell.
|
|
Indexing operator. This takes indices into the vector and returns a reference to the correct cell.
|
|
Unary negating operator. Does not negate 4th cell, as that just seems silly. |
|
Equals operator. Returns a reference for somethin = something = something lines. |
|
Rotates a vector. Hopefully can be replaced with an affine transform. Now will 100% radian goodness. No degrees here! |
|
Calculates the square of the length of the vector. Note: This ignores the fourth var. It is also more efficient with no pesky sqrt()s. Inlined as we'll probably call it a lot.
|
|
The data array. Currently publically available. |