#include <include/Vector3.h>
Public Member Functions | |
Vector3 () | |
Vector3 (const float x, const float y, const float z) | |
Vector3 (const float v[3]) | |
Vector3 (const Vector3 &v) | |
~Vector3 () | |
float & | operator[] (const int c) |
const float & | operator[] (const int c) const |
Vector3 & | zero () |
void | getValues (float &X, float &Y, float &Z) const |
Vector3 & | setValues (const float X, const float Y, const float Z) |
Vector3 & | setValues (const float v[3]) |
float | dot (const Vector3 &v) const |
Vector3 | cross (const Vector3 &v) const |
float | norm () const |
float | norm2 () const |
Vector3 & | normalize () |
float | max () |
float | min () |
Vector3 | reflect (const Vector3 &v) const |
Vector3 | rotPtAroundAxis (float angle, Vector3 axis) const |
Vector3 | operator* (const Vector3 &v) const |
Vector3 | operator+ (const Vector3 &v) const |
Vector3 | operator- (const Vector3 &v) const |
Vector3 | operator- () const |
Vector3 & | operator+= (const Vector3 &v) |
Vector3 & | operator-= (const Vector3 &v) |
Vector3 & | operator*= (const float s) |
Vector3 & | operator/= (const float s) |
int | operator== (const Vector3 &v) const |
int | operator!= (const Vector3 &v) const |
void | print (ostream &out) const |
Static Public Attributes | |
static const unsigned int | type = 3 |
Friends | |
Vector3 | operator* (const Vector3 &v, float d) |
Vector3 | operator* (float d, const Vector3 &v) |
Vector3 | operator/ (const Vector3 &v, float d) |
ostream & | operator<< (ostream &out, const Vector3 &v) |
istream & | operator>> (istream &in, Vector3 &v) |
This class provides storage for a 3 dimensional vector aswell as arithmetic operations on vectors, like the dot product, the cross product, the length of the vector.
Vector3::Vector3 | ( | ) |
Constructs an empty vector initialized to zero.
Referenced by cross(), operator*(), operator+(), and operator-().
Vector3::Vector3 | ( | const float | x, | |
const float | y, | |||
const float | z | |||
) |
Constructs a Vector3 instance from x, y and z.
Vector3::Vector3 | ( | const float | v[3] | ) |
Constructs a Vector3 with initial values from v.
Vector3::Vector3 | ( | const Vector3 & | v | ) |
Constructs a copy of v.
Vector3::~Vector3 | ( | ) |
The destructor has nothing to do
float & Vector3::operator[] | ( | const int | c | ) | [inline] |
Index operator. Returns modifiable x, y or z coordinate of the vector.
float Vector3::operator[] | ( | const int | c | ) | const [inline] |
Index operator. Returns x, y or z coordinate of vector.
Vector3 & Vector3::zero | ( | ) |
Sets all vector components to zero
Referenced by Matrix3::Matrix3(), and Matrix3::zero().
void Vector3::getValues | ( | float & | X, | |
float & | Y, | |||
float & | Z | |||
) | const |
Recover the vector components and put them into X, Y and Z.
Vector3 & Vector3::setValues | ( | const float | X, | |
const float | Y, | |||
const float | Z | |||
) |
Set the vector to <X,Y,Z>. Returns a reference to itself.
Vector3 & Vector3::setValues | ( | const float | v[3] | ) |
Set new coordinates from the given array v. Returns a reference to itself.
float Vector3::dot | ( | const Vector3 & | v | ) | const |
Returns the dot product between the current vector and v.
References _v.
Referenced by Tube< Vector >::makeMesh(), Curve< Vector >::normalVector(), Biarc< Vector >::pointOnArc0(), Biarc< Vector >::pointOnArc1(), and rotPtAroundAxis().
Returns a vector w, that is the result of the cross product between the actual vector and a vector v.
returns
Referenced by Tube< Vector >::makeMesh().
float Vector3::norm | ( | ) | const |
Computes and returns the length of the vector.
Referenced by normalize(), Biarc< Vector >::pointOnArc0(), and Biarc< Vector >::pointOnArc1().
float Vector3::norm2 | ( | ) | const |
Computes and returns the squared norm of the vector.
Referenced by Matrix3::cay().
Vector3 & Vector3::normalize | ( | ) |
Normalizes the current vector and returns a reference to itself
If the vector has zero norm, a warning message is posted to the error output and the Vector3 is Not modified.
References norm().
Referenced by Tube< Vector >::makeMesh(), Biarc< Vector >::pointOnArc0(), Biarc< Vector >::pointOnArc1(), reflect(), and Matrix3::rotAround().
float Vector3::max | ( | ) |
Returns the largest component of the current vector.
float Vector3::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 Matrix3::outer().
Rotate the current point at <x,y,z> around the given rotational axes axis and an angle angle. The value for the angle is given in radians.
References dot().
Referenced by Tube< Vector >::makeMesh().
Sum of the vector with v.
References Vector3().
Returns the difference between this vector and v.
References Vector3().
Vector3 Vector3::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.
Vector3 & Vector3::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.
Vector3 & Vector3::operator/= | ( | const float | s | ) |
Divides this vector's components by s and returns an instance to itself.
int Vector3::operator== | ( | const Vector3 & | v | ) | const |
Comparison operator. Returns 1 if the current vector and v are the same. Returns 0 otherwise.
int Vector3::operator!= | ( | const Vector3 & | v | ) | const |
If the current vector and v are not equal, this function returns 1, and 0 otherwise.
void Vector3::print | ( | ostream & | out | ) | const |
Prints the components of this vector in a formatted way onto the stream out.
Returns a Vector3, that is the vector v scaled by a scalar s.
Returns a Vector3 whose components are divided by d.
Friend function that returns the vector v whose components are scaled by d.
ostream & Vector3::operator<< | ( | ostream & | out, | |
const Vector3 & | 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 & Vector3::operator>> | ( | istream & | out, | |
Vector3 & | v | |||
) | [friend] |
Overloaded right shift operator. Initialize vector v with istream out.