#include <Vector3D.hpp>
Public Member Functions | |
Vector3D () | |
Constructor #1. | |
Vector3D (float x, float y, float z) | |
Constructor #2. | |
Vector3D (const Vector3D &vector) | |
Copy constructor. | |
const float | getX () const |
Get the x coordinate of the vector. | |
const float | getY () const |
Get the y coordinate of the vector. | |
const float | getZ () const |
Get the z coordinate of the vector. | |
void | set (const float x, const float y, const float z) |
Set the coordinates of the vector. | |
void | setX (const float x) |
Set the x coordinate of the vector. | |
void | setY (const float y) |
Set the y coordinate of the vector. | |
void | setZ (const float z) |
Set the z coordinate of the vector. | |
void | from3Array (const float array[3]) |
Set the coordinates of the vector from a 3-element array. | |
const float | getLength () const |
Calculate the length (magnitude) of the vector. | |
Vector3D | normalize () const |
Return a normalized vector which have the same directions as this vector. | |
float | dotProduct (const Vector3D &right) const |
Calculate the dot product of this vector and another one. | |
Vector3D | crossProduct (const Vector3D &right) const |
Calculate the cross product of this vector and another one. | |
Vector3D & | operator= (const Vector3D &arg) |
Set the vector coordinates using an "=" operator. | |
Vector3D | operator+ (const Vector3D &arg) const |
Add a vector using a "+" operator. | |
Vector3D | operator- (const Vector3D &arg) const |
Substract a vector using a "-" operator. | |
Vector3D | operator * (const float arg) const |
Multiply coordinates by a scalar using a "*" operator. | |
Vector3D | operator/ (const float arg) const |
Divide coordinates by a scalar using a "/" operator. | |
void | operator+= (const Vector3D &arg) |
Add the coordinates of a vector to those of this using a "+=" operator. | |
void | operator-= (const Vector3D &arg) |
Substract the coordinates of a vector from those of this using a "-=" operator. | |
void | operator *= (const float arg) |
Multiply the coordinates of this by a scalar using a "*=" operator. | |
void | operator/= (const float arg) |
Divide the coordinates of this by a scalar using a "/=" operator. | |
bool | operator== (const Vector3D &arg) const |
Compare a vector to this. | |
bool | operator!= (const Vector3D &arg) const |
Compare a vector to this. | |
Private Attributes | |
float | m_x |
x coordinate of the vector | |
float | m_y |
y coordinate of the vector | |
float | m_z |
z coordinate of the vector | |
float | m_length |
Length of the vector (0 if not calculated yet). | |
bool | m_lengthChanged |
Indicate if length has been changed since last time it was calculated (it avoids to re-calculate the length too many times). |
syBR::Core::Vector3D::Vector3D | ( | ) |
Constructor #1.
Initialize vector to (0,0,0)
syBR::Core::Vector3D::Vector3D | ( | float | x, | |
float | y, | |||
float | z | |||
) |
Constructor #2.
Initialize vector to specific coordinates
x | X coordinate of the vector | |
y | Y coordinate of the vector | |
z | Z coordinate of the vector |
syBR::Core::Vector3D::Vector3D | ( | const Vector3D & | vector | ) |
Copy constructor.
vector | 3D vector from which coordinates must be copied |
const float syBR::Core::Vector3D::getX | ( | ) | const [inline] |
Get the x coordinate of the vector.
const float syBR::Core::Vector3D::getY | ( | ) | const [inline] |
Get the y coordinate of the vector.
const float syBR::Core::Vector3D::getZ | ( | ) | const [inline] |
Get the z coordinate of the vector.
void syBR::Core::Vector3D::set | ( | const float | x, | |
const float | y, | |||
const float | z | |||
) |
Set the coordinates of the vector.
x | X coordinate of the vector | |
y | Y coordinate of the vector | |
z | Z coordinate of the vector |
void syBR::Core::Vector3D::setX | ( | const float | x | ) |
Set the x coordinate of the vector.
x | X coordinate of the vector |
void syBR::Core::Vector3D::setY | ( | const float | y | ) |
Set the y coordinate of the vector.
y | Y coordinate of the vector |
void syBR::Core::Vector3D::setZ | ( | const float | z | ) |
Set the z coordinate of the vector.
z | Z coordinate of the vector |
void syBR::Core::Vector3D::from3Array | ( | const float | array[3] | ) |
Set the coordinates of the vector from a 3-element array.
array | Array containing the (x,y,z) coordinates |
const float syBR::Core::Vector3D::getLength | ( | ) | const |
Calculate the length (magnitude) of the vector.
Vector3D syBR::Core::Vector3D::normalize | ( | ) | const |
Return a normalized vector which have the same directions as this vector.
float syBR::Core::Vector3D::dotProduct | ( | const Vector3D & | right | ) | const |
Calculate the dot product of this vector and another one.
right | Second vector used for calculating the dot product |
Calculate the cross product of this vector and another one.
right | Second vector used for calculating the cross product |
Set the vector coordinates using an "=" operator.
arg | New coordinates to set |
Add a vector using a "+" operator.
arg | Coordinates to add |
Substract a vector using a "-" operator.
arg | Coordinates to substract |
Vector3D syBR::Core::Vector3D::operator * | ( | const float | arg | ) | const |
Multiply coordinates by a scalar using a "*" operator.
arg | Scalar to multiply by |
Vector3D syBR::Core::Vector3D::operator/ | ( | const float | arg | ) | const |
Divide coordinates by a scalar using a "/" operator.
arg | Scalar to divide by |
void syBR::Core::Vector3D::operator+= | ( | const Vector3D & | arg | ) |
Add the coordinates of a vector to those of this using a "+=" operator.
arg | Coordinates to add |
void syBR::Core::Vector3D::operator-= | ( | const Vector3D & | arg | ) |
Substract the coordinates of a vector from those of this using a "-=" operator.
arg | Coordinates to substract |
void syBR::Core::Vector3D::operator *= | ( | const float | arg | ) |
Multiply the coordinates of this by a scalar using a "*=" operator.
arg | Coordinates to multiply by |
void syBR::Core::Vector3D::operator/= | ( | const float | arg | ) |
Divide the coordinates of this by a scalar using a "/=" operator.
arg | Scalar to divide by |
bool syBR::Core::Vector3D::operator== | ( | const Vector3D & | arg | ) | const |
Compare a vector to this.
arg | Vector to compare to |
bool syBR::Core::Vector3D::operator!= | ( | const Vector3D & | arg | ) | const |
Compare a vector to this.
arg | Vector to compare to |
float syBR::Core::Vector3D::m_x [private] |
x coordinate of the vector
float syBR::Core::Vector3D::m_y [private] |
y coordinate of the vector
float syBR::Core::Vector3D::m_z [private] |
z coordinate of the vector
float syBR::Core::Vector3D::m_length [private] |
Length of the vector (0 if not calculated yet).
bool syBR::Core::Vector3D::m_lengthChanged [private] |
Indicate if length has been changed since last time it was calculated (it avoids to re-calculate the length too many times).
Copyright © 2008 by Sebastien Frippiat
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008