vector.h

Classes

vector -- (full description)

class vector

Interface

Public Members
vector(real c = 0)
vector(real x, real y, real z)
real & operator [] (int i)
inline void print()
vector operator - ()
real operator * (const vector& b)
vector operator + (const vector &b)
vector operator - (const vector &b)
friend vector operator + (real, const vector & )
friend vector operator + (const vector &, real)
friend vector operator * (real, const vector & )
friend vector operator * (const vector &, real)
friend vector operator / (const vector &, real)
vector& operator += (const vector& b)
vector& operator -= (const vector& b)
vector& operator *= (const real b)
vector& operator /= (const real b)
friend ostream & operator << (ostream & , const vector & )
friend istream & operator >> (istream & , vector & )

Description

----------------------------------------------------------------------------- vector -- a class for 3-dimensional vectors ----------------------------------------------------------------------------- /

vector

Member Description

vector(real c = 0)

Default: initialize to zero.

vector(real x, real y, real z)

real & operator [] (int i)

[]: the return type is declared as a reference (&), so that it can be used on the left-hand side of an asignment, as well as on the right-hand side, i.e. v[1] = 3.14 and x = v[2] are both allowed and work as expected.

inline void print()

vector operator - ()

Unary -

real operator * (const vector& b)

Dot product.

vector operator + (const vector &b)

Vector +, -

vector operator - (const vector &b)

friend vector operator + (real, const vector & )

friend vector operator + (const vector &, real)

friend vector operator * (real, const vector & )

Scalar *, /

friend vector operator * (const vector &, real)

friend vector operator / (const vector &, real)

vector& operator += (const vector& b)

Vector +=, -=, *=, /=

vector& operator -= (const vector& b)

vector& operator *= (const real b)

vector& operator /= (const real b)

friend ostream & operator << (ostream & , const vector & )

Input / Output

friend istream & operator >> (istream & , vector & )