#include <include/Vector4.h>
Public Member Functions | |
Vector4 () | |
Vector4 (const float x, const float y, const float z, const float w) | |
Vector4 (const float v[4]) | |
Vector4 (const Vector4 &v) | |
Vector4 (const Vector3 &v, const float f) | |
~Vector4 () | |
float & | operator[] (const int c) |
const float & | operator[] (const int c) const |
Vector4 & | zero () |
void | getValues (float &X, float &Y, float &Z, float &W) const |
Vector4 & | setValues (const float X, const float Y, const float Z, const float W) |
Vector4 & | setValues (const float v[4]) |
float | dot (const Vector4 &v) const |
float | norm () const |
float | norm2 () const |
Vector4 & | normalize () |
float | max () |
float | min () |
Vector4 | reflect (const Vector4 &v) const |
Vector4 | operator* (const Vector4 &v) const |
Vector4 | operator+ (const Vector4 &v) const |
Vector4 | operator- (const Vector4 &v) const |
Vector4 | operator- () const |
Vector4 & | operator+= (const Vector4 &v) |
Vector4 & | operator-= (const Vector4 &v) |
Vector4 & | operator*= (const float s) |
Vector4 & | operator/= (const float s) |
int | operator== (const Vector4 &v) const |
int | operator!= (const Vector4 &v) const |
void | print (ostream &out) const |
Static Public Attributes | |
static const unsigned int | type = 4 |
Friends | |
Vector4 | operator* (const Vector4 &v, float d) |
Vector4 | operator* (float d, const Vector4 &v) |
Vector4 | operator/ (const Vector4 &v, float d) |
ostream & | operator<< (ostream &out, const Vector4 &v) |
istream & | operator>> (istream &in, Vector4 &v) |
This class provides storage for a 4 dimensional vector aswell as arithmetic operations on vectors, like the dot product, the cross product, the length of the vector in 4-dimensions.
Vector4::Vector4 | ( | ) |
Constructs an empty vector initialized to zero.
Referenced by operator*(), operator+(), and operator-().
Vector4::Vector4 | ( | const float | x, | |
const float | y, | |||
const float | z, | |||
const float | w | |||
) |
Constructs a Vector4 instance from x, y, z and w.
Vector4::Vector4 | ( | const float | v[4] | ) |
Constructs a Vector4 with initial values from v.
Vector4::Vector4 | ( | const Vector4 & | v | ) |
Constructs a copy of v.
Vector4::Vector4 | ( | const Vector3 & | v, | |
const float | f | |||
) |
Vector4::~Vector4 | ( | ) |
The destructor has nothing to do
float & Vector4::operator[] | ( | const int | c | ) | [inline] |
Index operator. Returns modifiable x, y or z coordinate of the vector.
float Vector4::operator[] | ( | const int | c | ) | const [inline] |
Index operator. Returns x, y or z coordinate of vector.
Vector4 & Vector4::zero | ( | ) |
Sets all vector components to zero
Referenced by Matrix4::Matrix4(), and Matrix4::zero().
void Vector4::getValues | ( | float & | X, | |
float & | Y, | |||
float & | Z, | |||
float & | W | |||
) | const |
Recover the vector components and put them into X, Y, Z and W.
Vector4 & Vector4::setValues | ( | const float | X, | |
const float | Y, | |||
const float | Z, | |||
const float | W | |||
) |
Set the vector to <X,Y,Z,W>. Returns a reference to itself.
Vector4 & Vector4::setValues | ( | const float | v[4] | ) |
Set new coordinates from the given array v. Returns a reference to itself.
float Vector4::dot | ( | const Vector4 & | v | ) | const |
Returns the dot product between the current vector and v.
References _v.
float Vector4::norm | ( | ) | const |
Computes and returns the length of the vector.
Referenced by normalize().
float Vector4::norm2 | ( | ) | const |
Vector4 & Vector4::normalize | ( | ) |
float Vector4::max | ( | ) |
Returns the largest component of the current vector.
float Vector4::min | ( | ) |
Returns the smallest component of the current vector.
Returns the mirror vector according to the given axe ref_ax. The reference axe needs not to be normalized, since this is done automatically.
References normalize(), and Matrix4::outer().
Sum of the vector with v.
References Vector4().
Returns the difference between this vector and v.
References Vector4().
Vector4 Vector4::operator- | ( | ) | const |
Adds the vector v to this vector and returns an instance to itself.
Substracts the vector v from this vector and returns an instance to itself.
Vector4 & Vector4::operator*= | ( | const float | s | ) |
Assign operator. Does the same as the copy constructor.
Multiplies this vector's components by s and returns an instance to itself.
Vector4 & Vector4::operator/= | ( | const float | s | ) |
Divides this vector's components by s and returns an instance to itself.
int Vector4::operator== | ( | const Vector4 & | v | ) | const |
Comparison operator. Returns 1 if the current vector and v are the same. Returns 0 otherwise.
int Vector4::operator!= | ( | const Vector4 & | v | ) | const |
If the current vector and v are not equal, this function returns 1, and 0 otherwise.
void Vector4::print | ( | ostream & | out | ) | const |
Prints the components of this vector in a formatted way onto the stream out.
Returns a Vector4, that is the vector v scaled by a scalar s.
Returns a Vector4 whose components are divided by d.
Friend function that returns the vector v whose components are scaled by d.
ostream & Vector4::operator<< | ( | ostream & | out, | |
const Vector4 & | v | |||
) | [friend] |
Overloaded left shift operator. Returns the Vector v as an ostream that can be written to a file or to standart output.
ostream & Vector4::operator>> | ( | istream & | out, | |
Vector4 & | v | |||
) | [friend] |
Overloaded right shift operator. Initialize vector v with istream out.