Vec3 Class Reference

#include <Vec3.h>

List of all members.

Public Member Functions

 Vec3 (const float x=0.0f, const float y=0.0f, const float z=0.0f)
 Vec3 (const Vec3f v)
 ~Vec3 ()
Vec3operator+= (const Vec3 &b)
Vec3 operator+ (const Vec3 &b) const
Vec3 operator- (const Vec3 &b) const
Vec3 operator* (const float b) const
Vec3operator*= (const float b)
Vec3operator/= (const float b)
void rotateXZ (float ry)
void rotateXY (float rz)
void rotateYZ (float rx)
float getLengthSquared () const
float getEuclideanDistance (const Vec3 pos2) const
float getAngle (Vec3 playerPos) const
Vec3f toVec3f () const
std::string toString ()

Public Attributes

float x
float y
float z

Detailed Description

This class provides a triple vector for (X,Y,Z) and matching vector calculations as well, that are mostly useful for 3D rotation calculations. The vector components are internally stored as floats and are directly available for read/write access.

Definition at line 16 of file Vec3.h.


Constructor & Destructor Documentation

Vec3::Vec3 ( const float  x = 0.0f,
const float  y = 0.0f,
const float  z = 0.0f 
) [inline]

constructs a Vec3 with the given vector components. Components may be occluded and are seth then as zero.

Parameters:
the x value to be set
the y value to be set
the z value to be set

Definition at line 37 of file Vec3.h.

Vec3::Vec3 ( const Vec3f  v  )  [inline]

A copy-constructor for a similar vector class Vec3f from the Horde3D framework.

Parameters:
v the vector whose components are to be copied

Definition at line 44 of file Vec3.h.

Vec3::~Vec3 (  )  [inline]

Definition at line 47 of file Vec3.h.


Member Function Documentation

float Vec3::getAngle ( Vec3  playerPos  )  const [inline]

returns the angle between this vector and another vector (at most the player's position)

Parameters:
the player's position
Returns:
the angle between both vectors in degree

Definition at line 193 of file Vec3.h.

float Vec3::getEuclideanDistance ( const Vec3  pos2  )  const [inline]

returns the distance between this vector and another vector within the euclidean 3D space.

Parameters:
pos2 another vector
Returns:
the distance between this vector and another vector. Please note that this values is absolute.

Definition at line 181 of file Vec3.h.

float Vec3::getLengthSquared (  )  const [inline]

returns

Returns:
the sum of all squared components

Definition at line 171 of file Vec3.h.

Vec3 Vec3::operator* ( const float  b  )  const [inline]

this operator does a component-wise multiplication and returns a fresh vector, while this vector is left unchanged.

Parameters:
b the vector which is multiplicated with this vector's components
Returns:
a fresh vector

Definition at line 92 of file Vec3.h.

Vec3& Vec3::operator*= ( const float  b  )  [inline]

this operator does a component-wise multiplication to this vector.

Parameters:
b the vector which is multiplicated with this vector's components
Returns:
this vector but updated

Definition at line 101 of file Vec3.h.

Vec3 Vec3::operator+ ( const Vec3 b  )  const [inline]

this operator does a component-wise addition and returns a fresh vector, while this vector is left unchanged.

Parameters:
b the vector which is added to this vector's components
Returns:
a fresh vector

Definition at line 72 of file Vec3.h.

Vec3& Vec3::operator+= ( const Vec3 b  )  [inline]

this operator does a component-wise addition to this vector

Parameters:
b the vector which is added to this vector
Returns:
this vector but updated

Definition at line 59 of file Vec3.h.

Vec3 Vec3::operator- ( const Vec3 b  )  const [inline]

this operator does a component-wise substraction and returns a fresh vector, while this vector is left unchanged.

Parameters:
b the vector which is substracted from this vector
Returns:
a fresh vector

Definition at line 82 of file Vec3.h.

Vec3& Vec3::operator/= ( const float  b  )  [inline]

this operator does a component-wise division to this vector.

Parameters:
b the vector by which are this vector's components divided
Returns:
this vector but updated

Definition at line 113 of file Vec3.h.

void Vec3::rotateXY ( float  rz  )  [inline]

rotate this vector around the z axis

Parameters:
the angle in degrees by which X and Y shall be rotated

Definition at line 141 of file Vec3.h.

void Vec3::rotateXZ ( float  ry  )  [inline]

rotate this vector around the y axis

Parameters:
the angle in degrees by which X and Z shall be rotated

Definition at line 128 of file Vec3.h.

void Vec3::rotateYZ ( float  rx  )  [inline]

rotate this vector around the x axis

Parameters:
the angle in degrees by which Y and Z shall be rotated

Definition at line 153 of file Vec3.h.

std::string Vec3::toString (  )  [inline]

returns a string with the current component values

Returns:
a string with the current component values

Definition at line 212 of file Vec3.h.

Vec3f Vec3::toVec3f (  )  const [inline]

converts this vector to a Horde3D vector for convenience purposes

Returns:
a fresh Horde3D vector with this vector's component values

Definition at line 204 of file Vec3.h.


Member Data Documentation

float Vec3::x

read/write access the X component

Definition at line 21 of file Vec3.h.

float Vec3::y

read/write access the Y component

Definition at line 25 of file Vec3.h.

float Vec3::z

read/write access the Z component

Definition at line 29 of file Vec3.h.


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

Generated by  doxygen 1.6.2