Vector Class Reference

Modells a vector (or a vertex) in 3-space. More...

#include <Vector.h>

Inheritance diagram for Vector:

Object

List of all members.

Public Member Functions

 Vector ()
 Standard constructor.
 Vector (const Vector &vector)
 Copy constructor.
 Vector (const GLfloat &x, const GLfloat &y, const GLfloat &z)
 Constructor for initialization by value without flag.
 Vector (const GLfloat &x, const GLfloat &y, const GLfloat &z, const bool &vertex)
 Constructor for initialization by value.
const GLfloat getX () const
 Returns the x-coordinate.
const GLfloat getY () const
 Returns the y-coordinate.
const GLfloat getZ () const
 Returns the z-coordinate.
const GLfloat * getXYZ () const
 Returns the coodinates as an array of size 3.
const GLfloat * getXYZW () const
 Returns the coodinates as an array of size 4.
const bool isVertex () const
 Returns true if it is a vertex, false otherwise.
void setX (const GLfloat &x)
 Sets the x-coordinate.
void setY (const GLfloat &y)
 Sets the y-coordinate.
void setZ (const GLfloat &z)
 Sets the z-coordinate.
void setVertex (const bool &vertex)
 Sets the vertex-flag.
void setVector (const Vector &vector)
 Sets all coordinates by reference.
void setXYZFlag (const float &x, const float &y, const float &z, const bool &vertex)
 Sets all coordinates.
const GLfloat getDistanceFromOrigin () const
 Getter for euclidian norm.
void normalize ()
 Changes the vector to the length of one.
Angle convertToYaw () const
 Converts vector to a corresponding yaw angle.
virtual string toString () const
 Returns a textual representation.
virtual string className () const
 Returns the class name of the object.
virtual enum classId classId () const
 Returns the class id of the object.
Vector operatorX (const Vector &v2)
 Calculates the cross product.
Vector operator+= (const Vector &v)
 EVIL! Only use as last resort.
Vector operator-= (const Vector &v)
 EVIL! Only use as last resort.
Vector operator*= (const GLfloat &a)
Vector operator/= (const GLfloat &a)
Vector operator= (const Vector &v)
bool operator== (const Vector &v)
bool operator!= (const Vector &v)

Private Attributes

GLfloat x
 The x-coordinate.
GLfloat y
 The y-coordinate.
GLfloat z
 The z-coordinate.
bool vertex
 The flag for vertices: false if it is a vector, true if it is a vertex.

Friends

Vector operator+ (const Vector &v1, const Vector &v2)
 EVIL! Only use as last resort.
Vector operator- (const Vector &v)
Vector operator- (const Vector &v1, const Vector &v2)
 EVIL! Only use as last resort.
Vector operator* (const Vector &v, const float &a)
Vector operator* (const float &a, const Vector &v)
float operator* (const Vector &v1, const Vector &v2)
Vector operator/ (const Vector &v, const float &a)
Vector operator/ (const float &a, const Vector &v)


Detailed Description

Modells a vector (or a vertex) in 3-space.

Provides basic mathematical vector functionality i.e. cross product, normalization.


Constructor & Destructor Documentation

Vector::Vector (  ) 

Standard constructor.

Creates an zero vector (no dimension!)

Vector::Vector ( const Vector vector  ) 

Copy constructor.

Parameters:
vector The vector which shall be duplicated

Vector::Vector ( const GLfloat &  x,
const GLfloat &  y,
const GLfloat &  z 
)

Constructor for initialization by value without flag.

Sets the vertex flag to false

Parameters:
x The x-component
y The y-component
z The z-component

Vector::Vector ( const GLfloat &  x,
const GLfloat &  y,
const GLfloat &  z,
const bool &  vertex 
)

Constructor for initialization by value.

Parameters:
x The x-component
y The y-component
z The z-component
vertex The vertex-Flag


Member Function Documentation

const GLfloat Vector::getX (  )  const

Returns the x-coordinate.

Returns:
The x-coordinate

const GLfloat Vector::getY (  )  const

Returns the y-coordinate.

Returns:
The y-coordinate

const GLfloat Vector::getZ (  )  const

Returns the z-coordinate.

Returns:
The z-coordinate

const GLfloat * Vector::getXYZ (  )  const

Returns the coodinates as an array of size 3.

Returns:
An array of size 3 with the x-coordinate at index 0, the y-coordinate at index 1 and the z-coordinate at index 2.

const GLfloat * Vector::getXYZW (  )  const

Returns the coodinates as an array of size 4.

Returns:
An array of size 4 with the x-coordinate at index 0, the y-coordinate at index 1, the z-coordinate at index 2 and 1.0f or 0.0f (Vertex or Vector) at index 4.

const bool Vector::isVertex (  )  const

Returns true if it is a vertex, false otherwise.

Checks wether it is a vertex or a real vector. Returns true if it is a vertex, false otherwise

void Vector::setX ( const GLfloat &  x  ) 

Sets the x-coordinate.

Parameters:
x The new x-coordinate

void Vector::setY ( const GLfloat &  y  ) 

Sets the y-coordinate.

Parameters:
y The new y-coordinate

void Vector::setZ ( const GLfloat &  z  ) 

Sets the z-coordinate.

Parameters:
z The new z-coordinate

void Vector::setVertex ( const bool &  vertex  ) 

Sets the vertex-flag.

Parameters:
vertex The new Vertex-flag

void Vector::setVector ( const Vector vector  ) 

Sets all coordinates by reference.

Parameters:
vector The Vector which shall be duplicated

void Vector::setXYZFlag ( const float &  x,
const float &  y,
const float &  z,
const bool &  vertex 
)

Sets all coordinates.

Parameters:
x The new x-Coordinate of the Vector
y The new y-Coordinate of the Vector
z The new z-Coordinate of the Vector
vertex The new vertex-flag of the Vector

const GLfloat Vector::getDistanceFromOrigin (  )  const

Getter for euclidian norm.

Returns:
The distance of the point from the coordinate systems origin

void Vector::normalize (  ) 

Changes the vector to the length of one.

Changes the vector to the length of one. For the zero vector this method will be ignored.

Angle Vector::convertToYaw (  )  const

Converts vector to a corresponding yaw angle.

Returns:
an angle that corresponds to the yaw of the vector

string Vector::toString (  )  const [virtual]

Returns a textual representation.

Returns:
a string descriping the run-time object

Reimplemented from Object.

string Vector::className (  )  const [virtual]

Returns the class name of the object.

Returns:
a string with the name of the object's class

Reimplemented from Object.

enum classId Vector::classId (  )  const [virtual]

Returns the class id of the object.

Returns:
an id of the object's class

Reimplemented from Object.

Vector Vector::operatorX ( const Vector v2  )  [inline]

Calculates the cross product.

Vector Vector::operator+= ( const Vector v  )  [inline]

EVIL! Only use as last resort.

Vector Vector::operator-= ( const Vector v  )  [inline]

EVIL! Only use as last resort.

Vector Vector::operator*= ( const GLfloat &  a  )  [inline]

Vector Vector::operator/= ( const GLfloat &  a  )  [inline]

Vector Vector::operator= ( const Vector v  )  [inline]

bool Vector::operator== ( const Vector v  )  [inline]

bool Vector::operator!= ( const Vector v  )  [inline]


Friends And Related Function Documentation

Vector operator+ ( const Vector v1,
const Vector v2 
) [friend]

EVIL! Only use as last resort.

Vector operator- ( const Vector v  )  [friend]

Vector operator- ( const Vector v1,
const Vector v2 
) [friend]

EVIL! Only use as last resort.

Vector operator* ( const Vector v,
const float &  a 
) [friend]

Vector operator* ( const float &  a,
const Vector v 
) [friend]

float operator* ( const Vector v1,
const Vector v2 
) [friend]

Vector operator/ ( const Vector v,
const float &  a 
) [friend]

Vector operator/ ( const float &  a,
const Vector v 
) [friend]


Member Data Documentation

GLfloat Vector::x [private]

The x-coordinate.

GLfloat Vector::y [private]

The y-coordinate.

GLfloat Vector::z [private]

The z-coordinate.

bool Vector::vertex [private]

The flag for vertices: false if it is a vector, true if it is a vertex.


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

Generated on Mon Jul 7 13:30:35 2008 for Firefly by  doxygen 1.5.6