#include <vector3d.h>
Public Member Functions | |
vector3d () | |
Default constructor constructs a zero- vector. | |
vector3d (double X, double Y, double Z) | |
Constructor with coordinates. | |
double | operator[] (int i) const |
Return coordinates via index (0,1,2). | |
double & | operator[] (int i) |
Acces vector coordinates via index mode (0,1,2). | |
operator const double * () const | |
Returning the memory address of the vector. | |
vector3d & | operator= (const vector3d &v) |
= operator. | |
vector3d & | operator/= (double k) |
Divides the vector by k. | |
double | squaredNorm () const |
Calculates the squared norm of the vector. | |
double | norm () const |
Calculates the norm of the vector. | |
vector3d | project (const vector3d &a) |
Reurns the projection of the vector on vector a. | |
double | normalize () |
Normalizes the vector. | |
Static Public Member Functions | |
static double | vecAngle (const vector3d &a, const vector3d &b) |
angle (degrees) between vector a and vector b | |
static double | vecRadAngle (const vector3d &a, const vector3d &b) |
angle (radians) between vector a and vector b | |
Public Attributes | |
union { | |
struct { | |
double x | |
double y | |
double z | |
} | |
double c [3] | |
}; | |
Friends | |
vector3d | operator- (const vector3d &a, const vector3d &b) |
Subtracts vector b from vector a. | |
double | operator* (const vector3d &a, const vector3d &b) |
Dot product of vector a and vector b. | |
vector3d | operator* (const vector3d &a, float k) |
Returns the product of the vector a with a scalar k. | |
vector3d | operator* (float k, const vector3d &a) |
Returns the product of the vector a with a scalar k. | |
vector3d | operator+ (const vector3d &a, const vector3d &b) |
Sum of vector a and vector b. | |
vector3d | operator/ (const vector3d &a, double k) |
Division of vector a by k. | |
bool | operator== (const vector3d &a, const vector3d &b) |
Checks wether two vectors are equal. | |
vector3d | cross (const vector3d &a, const vector3d &b) |
crossproduct of vector a and vector b |
vector3d::vector3d | ( | ) | [inline] |
Default constructor constructs a zero- vector.
double& vector3d::operator[] | ( | int | i | ) | [inline] |
Acces vector coordinates via index mode (0,1,2).
(lvalue)
vector3d::operator const double * | ( | ) | const [inline] |
Returning the memory address of the vector.
Useful for passing the vector to openGL functions
vector3d& vector3d::operator/= | ( | double | k | ) | [inline] |
Divides the vector by k.
*
vector3d& operator/=(float k) { x /=k; y /=k; z /=k; return *this; }
Divides the vector by k.
double vector3d::squaredNorm | ( | ) | const [inline] |
Calculates the squared norm of the vector.
double vector3d::norm | ( | ) | const [inline] |
Calculates the norm of the vector.
Reurns the projection of the vector on vector a.
double vector3d::normalize | ( | ) | [inline] |
Normalizes the vector.
If the vector is a null vector (norm() < vector3d_ZERO) the vector is not modified and function returns -1.
Otherwise the former norm of the vector is returned.
angle (degrees) between vector a and vector b
angle (radians) between vector a and vector b
Dot product of vector a and vector b.
Returns the product of the vector a with a scalar k.
Returns the product of the vector a with a scalar k.
Checks wether two vectors are equal.
The two vectors are equal, If the norm of the difference of the two vectors is smaller than vector3d_ZERO
crossproduct of vector a and vector b