ARSTD::Vector3 Class Reference

List of all members.

Public Member Functions

 Vector3 ()
 Vector3 (const double &x, const double &y, const double &z)
double getLength () const
double getSquaredLength () const
const Vector3normalize ()
Vector3 getNormalized () const
double getAngleBetween (const Vector3 &vec) const
Vector3 getPerpendicular () const

Public Attributes

double x
 The first component.
double y
 The second component.
double z
 The third component.
double r
 Alias of first component.
double g
 Alias of second component.
double b
 Alias of third component.

Related Functions

(Note that these are not member functions.)

double operator * (const Vector3 &vec1, const Vector3 &vec2)
Vector3 operator% (const Vector3 &vec1, const Vector3 &vec2)
Vector3 operator+ (const Vector3 &lhs, const Vector3 &rhs)
Vector3 operator- (const Vector3 &lhs, const Vector3 &rhs)
Vector3 operator * (const Vector3 &lhs, const double &rhs)
Vector3 operator * (const double &lhs, const Vector3 &rhs)
bool operator== (const Vector3 &lhs, const Vector3 &rhs)

Detailed Description

This class implements a 3-dimensional vector.


Constructor & Destructor Documentation

ARSTD::Vector3::Vector3 (  ) 

Default constructor. Sets all members to zero

ARSTD::Vector3::Vector3 ( const double &  x,
const double &  y,
const double &  z 
)

Constructor, that initializes the members with the parameters.

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


Member Function Documentation

double ARSTD::Vector3::getLength (  )  const

Returns the length of the vector.

Returns:
length of the vector

double ARSTD::Vector3::getSquaredLength (  )  const

Returns the squared length of the vector. Because the calculation of the length of a vector needs a squareroot operation this method can be used to calc with squared values.

Returns:
Squared length of the vector.

const Vector3& ARSTD::Vector3::normalize (  ) 

Normalizes the vector to a length of 1.

Precondition:
this->length != 0.0
Postcondition:
this->length() is 1
Returns:
The normalized vector

Vector3 ARSTD::Vector3::getNormalized (  )  const

Returns the normalized version of this vector.

Precondition:
this->length != 0.0
Postcondition:
this->length() is 1
Returns:
The normalized vector

double ARSTD::Vector3::getAngleBetween ( const Vector3 vec  )  const

Returns the angle between this and vec in degree.

Parameters:
vec The vector to which the angle should be calculated.
Returns:
The angle in degree.

Vector3 ARSTD::Vector3::getPerpendicular (  )  const

Returns a variable but perpendicular oriented vector to *this.

Returns:
The perpendicular vector.
Precondition:
The length have to be not zero.


Friends And Related Function Documentation

double operator * ( const Vector3 vec1,
const Vector3 vec2 
) [related]

Calculates and returns the dot product of a pair of vectors

Parameters:
vec1 The first vector
vec2 The second vector
Returns:
The dot product

Vector3 operator% ( const Vector3 vec1,
const Vector3 vec2 
) [related]

Calculates and returns the cross product of a pair of vectors.

Parameters:
vec1 The first vector
vec2 The second vector
Returns:
The cross product as Vector3

Vector3 operator+ ( const Vector3 lhs,
const Vector3 rhs 
) [related]

Adds two vectors

Parameters:
lhs The first vector
rhs The second vector
Returns:
The result of the operation

Vector3 operator- ( const Vector3 lhs,
const Vector3 rhs 
) [related]

Subtracts two vectors

Parameters:
lhs The first vector
rhs The second vector
Returns:
The result of the operation points from rhs to lhs.

Vector3 operator * ( const Vector3 lhs,
const double &  rhs 
) [related]

Multiplies a scalar by each component of a vector

Parameters:
lhs The vector
rhs The scalar
Returns:
The result of the operation

Vector3 operator * ( const double &  lhs,
const Vector3 rhs 
) [related]

Multiplies a scalar by each component of a vector

Parameters:
rhs The vector
lhs The scalar
Returns:
The result of the operation

bool operator== ( const Vector3 lhs,
const Vector3 rhs 
) [related]

Compares two vectors.

Parameters:
lhs The first vector
rhs The second vector
Returns:
true, if the vectors are considered equal, false otherwise


Generated at 2 Jan 2007 for project CodeSubWars. www.codesubwars.org