#include <matrix.h>
Public Member Functions | |
Vector () | |
Default constructor. Initializes vector to (0,0,0). | |
Vector (float s) | |
Constructor initializing all elements to the given value. | |
Vector (float _x, float _y, float _z) | |
Constructor initializing vector to (x,y,z). | |
Vector (const Point &p) | |
Constructor initializing the vector from a point. | |
virtual | ~Vector () |
Destructor. Does nothing. | |
float | operator() (int i) const |
Returns a copy of the element at position (i). | |
float & | operator() (int i) |
Returns a reference to the element at position (i). | |
Vector | operator+ (const Vector &v) const |
Addition of two vectors. | |
Vector & | operator+= (const Vector &v) |
Addition of two vectors in place. | |
Vector | operator- () const |
Negation of vector. | |
Vector | operator- (const Vector &v) const |
Subtraction of two vectors. | |
Vector & | operator-= (const Vector &v) |
Subtraction of two vectors in place. | |
Vector | operator * (float s) const |
Multiplication of vector by scalar. | |
Vector & | operator *= (float s) |
Multiplication by scalar in place. | |
Vector | operator/ (float s) const |
Division of vector by scalar. | |
Vector & | operator/= (float s) |
Division by scalar in place. | |
float | dot (const Vector &v) const |
Dot product of two vectors. | |
float | operator * (const Vector &v) const |
Dot product of two vectors (short form). | |
Vector | cross (const Vector &v) const |
Cross product of two vectors. | |
Vector | operator% (const Vector &v) const |
Cross product of two vectors (short form). | |
float | length () const |
Returns length of vector. | |
float | length2 () const |
Returns square length of vector. | |
Vector & | normalize () |
Normalize vector to unit length. | |
Public Attributes | |
float | x |
First component. | |
float | y |
Second component. | |
float | z |
Third component. | |
Friends | |
Vector | operator * (float s, const Vector &v) |
Multiplication of scalar by vector. | |
std::ostream & | operator<< (std::ostream &os, const Vector &A) |
Write elements to an output stream. |