#include <starlab_vector.h>
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). | |
real & | operator[] (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. | |
vec & | operator+= (const vec &b) |
Vector +=. | |
vec & | operator-= (const vec &b) |
Vector -=. | |
vec & | operator *= (const real b) |
Vector *=. | |
vec & | operator/= (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. |
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.
|
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. |