Vector4 Class Reference
[libbiarc]

The Vector4 class is a 4 dimensional Vector class with floating point coordinates. More...

#include <include/Vector4.h>

List of all members.

Public Member Functions

 Vector4 ()
 Vector4 (const float x, const float y, const float z, const float w)
 Vector4 (const float v[4])
 Vector4 (const Vector4 &v)
 Vector4 (const Vector3 &v, const float f)
 ~Vector4 ()
float & operator[] (const int c)
const float & operator[] (const int c) const
Vector4zero ()
void getValues (float &X, float &Y, float &Z, float &W) const
Vector4setValues (const float X, const float Y, const float Z, const float W)
Vector4setValues (const float v[4])
float dot (const Vector4 &v) const
float norm () const
float norm2 () const
Vector4normalize ()
float max ()
float min ()
Vector4 reflect (const Vector4 &v) const
Vector4 operator* (const Vector4 &v) const
Vector4 operator+ (const Vector4 &v) const
Vector4 operator- (const Vector4 &v) const
Vector4 operator- () const
Vector4operator+= (const Vector4 &v)
Vector4operator-= (const Vector4 &v)
Vector4operator*= (const float s)
Vector4operator/= (const float s)
int operator== (const Vector4 &v) const
int operator!= (const Vector4 &v) const
void print (ostream &out) const

Static Public Attributes

static const unsigned int type = 4

Friends

Vector4 operator* (const Vector4 &v, float d)
Vector4 operator* (float d, const Vector4 &v)
Vector4 operator/ (const Vector4 &v, float d)
ostream & operator<< (ostream &out, const Vector4 &v)
istream & operator>> (istream &in, Vector4 &v)


Detailed Description

The Vector4 class is a 4 dimensional Vector class with floating point coordinates.

This class provides storage for a 4 dimensional vector aswell as arithmetic operations on vectors, like the dot product, the cross product, the length of the vector in 4-dimensions.

See also:
class Vector3

Constructor & Destructor Documentation

Vector4::Vector4 (  ) 

Constructs an empty vector initialized to zero.

See also:
zero().

Referenced by operator*(), operator+(), and operator-().

Vector4::Vector4 ( const float  x,
const float  y,
const float  z,
const float  w 
)

Constructs a Vector4 instance from x, y, z and w.

Vector4::Vector4 ( const float  v[4]  ) 

Constructs a Vector4 with initial values from v.

Vector4::Vector4 ( const Vector4 v  ) 

Constructs a copy of v.

Vector4::Vector4 ( const Vector3 v,
const float  f 
)

Construct a Vector4 object from a Vector3 v and a float f.

Vector4::~Vector4 (  ) 

The destructor has nothing to do


Member Function Documentation

float & Vector4::operator[] ( const int  c  )  [inline]

Index operator. Returns modifiable x, y or z coordinate of the vector.

See also:
getValue() and setValue().

float Vector4::operator[] ( const int  c  )  const [inline]

Index operator. Returns x, y or z coordinate of vector.

See also:
getValue() and setValue().

Vector4 & Vector4::zero (  ) 

Sets all vector components to zero

Referenced by Matrix4::Matrix4(), and Matrix4::zero().

void Vector4::getValues ( float &  X,
float &  Y,
float &  Z,
float &  W 
) const

Recover the vector components and put them into X, Y, Z and W.

Vector4 & Vector4::setValues ( const float  X,
const float  Y,
const float  Z,
const float  W 
)

Set the vector to <X,Y,Z,W>. Returns a reference to itself.

Vector4 & Vector4::setValues ( const float  v[4]  ) 

Set new coordinates from the given array v. Returns a reference to itself.

float Vector4::dot ( const Vector4 v  )  const

Returns the dot product between the current vector and v.

References _v.

float Vector4::norm (  )  const

Computes and returns the length of the vector.

$|v|=\sqrt{x^2+y^2+z^2+w^2}.$

See also:
norm2(), normalize().

Referenced by normalize().

float Vector4::norm2 (  )  const

Computes and returns the squared norm of the vector.

$|v|^2=x^2+y^2+z^2+w^2.$

See also:
norm(), normalize().

Vector4 & Vector4::normalize (  ) 

Normalizes the current vector and returns a reference to itself

If the vector has zero norm, a warning message is posted to the error output and the Vector4 is Not modified.

See also:
norm(), norm2().

References norm().

Referenced by reflect().

float Vector4::max (  ) 

Returns the largest component of the current vector.

float Vector4::min (  ) 

Returns the smallest component of the current vector.

Vector4 Vector4::reflect ( const Vector4 ref_ax  )  const

Returns the mirror vector according to the given axe ref_ax. The reference axe needs not to be normalized, since this is done automatically.

References normalize(), and Matrix4::outer().

Vector4 Vector4::operator* ( const Vector4 v  )  const

Returns a Vector4 that is the dot product of this vector and v.

References _v, and Vector4().

Vector4 Vector4::operator+ ( const Vector4 v  )  const

Sum of the vector with v.

References Vector4().

Vector4 Vector4::operator- ( const Vector4 v  )  const

Returns the difference between this vector and v.

References Vector4().

Vector4 Vector4::operator- (  )  const

Returns a new Vector4 that points in the opposite direction.

References Vector4().

Vector4 & Vector4::operator+= ( const Vector4 v  ) 

Adds the vector v to this vector and returns an instance to itself.

Vector4 & Vector4::operator-= ( const Vector4 v  ) 

Substracts the vector v from this vector and returns an instance to itself.

Vector4 & Vector4::operator*= ( const float  s  ) 

Assign operator. Does the same as the copy constructor.

Multiplies this vector's components by s and returns an instance to itself.

Vector4 & Vector4::operator/= ( const float  s  ) 

Divides this vector's components by s and returns an instance to itself.

int Vector4::operator== ( const Vector4 v  )  const

Comparison operator. Returns 1 if the current vector and v are the same. Returns 0 otherwise.

int Vector4::operator!= ( const Vector4 v  )  const

If the current vector and v are not equal, this function returns 1, and 0 otherwise.

void Vector4::print ( ostream &  out  )  const

Prints the components of this vector in a formatted way onto the stream out.


Friends And Related Function Documentation

Vector4 operator* ( const Vector4 v,
float  d 
) [friend]

Returns a Vector4 that is this vector scaled by a scalar s.

Returns a Vector4 that is the vector v scaled by a scalar d.

Vector4 operator* ( float  d,
const Vector4 v 
) [friend]

Returns a Vector4, that is the vector v scaled by a scalar s.

Vector4 operator/ ( const Vector4 v,
float  d 
) [friend]

Returns a Vector4 whose components are divided by d.

Friend function that returns the vector v whose components are scaled by d.

ostream & Vector4::operator<< ( ostream &  out,
const Vector4 v 
) [friend]

Overloaded left shift operator. Returns the Vector v as an ostream that can be written to a file or to standart output.

See also:
print()

ostream & Vector4::operator>> ( istream &  out,
Vector4 v 
) [friend]

Overloaded right shift operator. Initialize vector v with istream out.

See also:
print() operator<<()


The documentation for this class was generated from the following files:

Generated on Mon Feb 8 17:22:36 2010 for libbiarc by  doxygen 1.5.6