Vector3D Class Reference

A triplet of coordinates in 3D. More...

List of all members.

Public Member Functions

 Vector3D (float x=0.0f, float y=0.0f, float z=0.0f)
 Constructor for the Vector3D.
Vector3Doperator+= (const Vector3D &v)
 Adds a Vector3D.
Vector3Doperator-= (const Vector3D &v)
 Substracts a Vector3D.
Vector3Doperator+= (float f)
 Adds a floating number.
Vector3Doperator-= (float f)
 Substracts a floating number.
Vector3Doperator*= (float f)
 Multiplies by a floating number.
Vector3Doperator/= (float f)
 Divides by a floating number.
Vector3D operator- () const
 Unary - operator of Vector3D.
float & operator[] (size_t index)
 Accesses the Vector3D coordinates in an container like fashion.
const float & operator[] (size_t index) const
 Accesses the Vector3D coordinates in an container like fashion.
void set (float x, float y, float z=0.0f)
 Sets the values of the Vector3D.
float getSqrNorm () const
 Gets the square norm of the Vector3D.
float getNorm () const
 Gets the norm of the Vector3D.
bool normalize ()
 Normalizes the Vector3D.
void revert ()
 Reverts the Vector3D.
void abs ()
 Sets this Vector3D to its absolute values.
void crossProduct (const Vector3D &v)
 Computes the cross product between v and the vector3D and store the result in the vector3D.

Public Attributes

float x
 x coordinate of the vector
float y
 y coordinate of the vector
float z
 z coordinate of the vector

Detailed Description

A triplet of coordinates in 3D.

This class offers a set of methods to manipulate 3D points/vectors.
To make the use of 3D points/vectors easier and more intuitive, some operators are overloaded.
Vector3D are the basic primitive used in SPARK to define 3D points/vectors.

Note that Vector3D coordinates are accessible directly without any setters or getters.

Definition at line 41 of file SPK_Vector3D.h.


Constructor & Destructor Documentation

Vector3D ( float  x = 0.0f,
float  y = 0.0f,
float  z = 0.0f 
)

Constructor for the Vector3D.

Parameters:
x : x coordinate
y : y coordinate
z : z coordinate

Member Function Documentation

void abs (  ) 

Sets this Vector3D to its absolute values.

This method performs these operations :
x = abs(x)
y = abs(y)
z = abs(z)

Since:
1.02.00
void crossProduct ( const Vector3D v  ) 

Computes the cross product between v and the vector3D and store the result in the vector3D.

Parameters:
v : the vector3D used to compute the cross product (*this x v)
float getNorm (  )  const

Gets the norm of the Vector3D.

the norm is defined as sqrt(x * x + y * y + z * z).

Returns:
the norm of the Vector3D

Definition at line 488 of file SPK_Vector3D.h.

float getSqrNorm (  )  const

Gets the square norm of the Vector3D.

the square norm is defined as x * x + y * y + z * z. This method is faster than getNorm() and should be used when possible.

Returns:
the square norm of the Vector3D

Definition at line 483 of file SPK_Vector3D.h.

bool normalize (  ) 

Normalizes the Vector3D.

This method performs these operations :
x /= |v|
y /= |v|
z /= |v|
Note that if the norm is equal to 0, nothing happens and false is returned.

Returns:
true if this Vector3D can be normalized, false otherwise
Vector3D& operator*= ( float  f  ) 

Multiplies by a floating number.

This method performs these operations :
x *= f
y *= f
z *= f

Parameters:
f : the number to multiply the Vector3D by
Returns:
the result Vector3D
Vector3D& operator+= ( float  f  ) 

Adds a floating number.

This method performs these operations :
x += f
y += f
z += f

Parameters:
f : the number to add
Returns:
the result Vector3D
Vector3D& operator+= ( const Vector3D v  ) 

Adds a Vector3D.

This method performs these operations :
x += v.x
y += v.y
z += v.z

Parameters:
v : the Vector3D to add
Returns:
the result Vector3D
Vector3D operator- (  )  const

Unary - operator of Vector3D.

This method performs that operation :
return Vector3D(-x,-y,-z)

return a Vector3D which is the reverse of this Vector3D

Definition at line 493 of file SPK_Vector3D.h.

Vector3D& operator-= ( float  f  ) 

Substracts a floating number.

This method performs these operations :
x -= f
y -= f
z -= f

Parameters:
f : the number to substract
Returns:
the result Vector3D
Vector3D& operator-= ( const Vector3D v  ) 

Substracts a Vector3D.

This method performs these operations :
x -= v.x
y -= v.y
z -= v.z

Parameters:
v : the Vector3D to substract
Returns:
the result Vector3D
Vector3D& operator/= ( float  f  ) 

Divides by a floating number.

This method performs these operations :
x /= f
y /= f
z /= f

Parameters:
f : the number to divide the Vector3D by
Returns:
the result Vector3D
const float& operator[] ( size_t  index  )  const

Accesses the Vector3D coordinates in an container like fashion.

This is the constant version of operator[](size_t)

Parameters:
index : the index of the coordinate to get (from 0 to 2)
Returns:
: the coordinate value at index
Since:
1.03.00
float& operator[] ( size_t  index  ) 

Accesses the Vector3D coordinates in an container like fashion.

  • index 0 is X
  • index 1 is Y
  • index 2 is Z

Note that no check for out of bounds index is performed

Parameters:
index : the index of the coordinate to get (from 0 to 2)
Returns:
: the coordinate value at index
Since:
1.03.00
void revert (  ) 

Reverts the Vector3D.

This method performs these operations :
x = -x
y = -y
z = -z

void set ( float  x,
float  y,
float  z = 0.0f 
)

Sets the values of the Vector3D.

Parameters:
x : x coordinate
y : y coordinate
z : z coordinate

Member Data Documentation

float x

x coordinate of the vector

Definition at line 49 of file SPK_Vector3D.h.

float y

y coordinate of the vector

Definition at line 50 of file SPK_Vector3D.h.

float z

z coordinate of the vector

Definition at line 51 of file SPK_Vector3D.h.


Generated on Wed Apr 27 21:09:26 2011 for SPARK Particle Engine by  doxygen 1.6.1