Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

Vec4 Class Reference

#include <vec4.h>

List of all members.


Detailed Description

The vector class.

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.

Author:
Stephen Bridges
Todo:
Decide about fourth cell/thingy.


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.
Vec4operator= (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.
Vec4operator+= (const Vec4 &other)
 += operator, all cells
Vec4 operator- (const Vec4 &other) const
 Subtracts, all cells.
Vec4operator-= (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.
Vec4operator/= (const float &other)
 Note: prints to cerr on divbyzero.
Vec4 operator * (const float &other) const
 Multiplication.
Vec4operator *= (const float &other)
 Multiplication.
Vec4 operator * (const Matrix4x4 &other) const
 This is just a wrapper for the *= operator.
Vec4operator *= (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.


Member Function Documentation

float Vec4::Length void   ) 
 

Calculates the length of the vector.

Note: This ignores the fourth var.

Returns:
Length as float.

Here is the call graph for this function:

int Vec4::mainDir void   ) 
 

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.

Returns:
An integer indicating which cell/axis is largest

Vec4 & Vec4::operator *= const Matrix4x4 other  ) 
 

Multiply by matrix.

Rather vitally important, some might say. This assumes the bottom row of the matrix will be uninteresting.

float Vec4::operator() unsigned int  i  )  const [inline]
 

Indexing operator.

This takes indices into the vector and returns a copy of the correct cell.

Parameters:
i Down.
Returns:
Copy of cell.

float & Vec4::operator() unsigned int  i  )  [inline]
 

Indexing operator.

This takes indices into the vector and returns a reference to the correct cell.

Parameters:
i Down.
Returns:
Changable reference.

Vec4 Vec4::operator- void   )  const
 

Unary negating operator.

Does not negate 4th cell, as that just seems silly.

Vec4 & Vec4::operator= const Vec4 other  ) 
 

Equals operator.

Returns a reference for somethin = something = something lines.

void Vec4::rotate float  xin,
float  yin,
float  zin
 

Rotates a vector.

Hopefully can be replaced with an affine transform. Now will 100% radian goodness. No degrees here!

float Vec4::SqrLength void   )  [inline]
 

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.

Returns:
Squared Length as float.


Member Data Documentation

float Vec4::v[4]
 

The data array.

Currently publically available.


The documentation for this class was generated from the following files:
Generated on Mon Jan 3 15:14:20 2005 for Graviton by  doxygen 1.3.9.1