Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

vec Class Reference

vec: A class for 3-dimensional vectors. More...

#include <starlab_vector.h>

List of all members.

Public Member Functions

 vec (real c=0)
 Default: initialize to (0,0,0). Note that vec(1) is (1,1,1).
 vec (real x, real y, real z)
 Initialize to (x,y,z).
realoperator[] (int i)
 Element access.
void print ()
 Print to cout. Note that cout << vec alwo works.
vec operator- ()
 Unary -.
real operator * (const vec &b)
 Dot product.
vec operator^ (const vec &b)
 Outer product.
vec operator+ (const vec &b)
 Vector +.
vec operator- (const vec &b)
 Vector -.
vec operator * (const real b)
 Real postmultiply.
vec operator+ (const real b)
 Real postadd.
vecoperator+= (const vec &b)
 Vector +=.
vecoperator-= (const vec &b)
 Vector -=.
vecoperator *= (const real b)
 Vector *=.
vecoperator/= (const real b)
 Vector /=.

Private Attributes

real element [3]
 3-D coordinates.

Friends

vec operator+ (real, const vec &)
vec operator+ (const vec &, real)
vec operator * (real, const vec &)
 Scalar premultiply.
vec operator * (const vec &, real)
 Scalar postmultiply.
vec operator/ (const vec &, real)
 Scalar divide.
bool operator== (const vec &, const vec &)
 Logical comparison ==.
bool operator!= (const vec &, const vec &)
 Logical comparison !=.
ostream & operator<< (ostream &, const vec &)
 Input.
istream & operator>> (istream &, vec &)
 Output.


Detailed Description

vec: A class for 3-dimensional vectors.

version 1: Dec 1992 Piet Hut, Steve McMillan, Jun Makino
version 2: Jun 2003 Steve McMillan: vector now vec to avoid conflict with upstart STL vector type.

Definition at line 27 of file starlab_vector.h.


Member Function Documentation

real& vec::operator[] int  i  )  [inline]
 

Element access.

[]: Allow array-style access. 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.

Definition at line 54 of file starlab_vector.h.

References element.


The documentation for this class was generated from the following file:
Generated on Wed Jul 20 12:43:39 2005 for Starlab by  doxygen 1.4.3