A 3-vector useful for postions etc. More...
#include <Vec.h>
Public Member Functions | |
| Vec () | |
| Dummy constructor needed by STL containers. | |
| Vec (double x0, double x1, double x2) | |
| Construct a 3-vector from three doubles. | |
| double | operator* (const Vec &v) const |
| Dot product. | |
| Vec | operator* (const double &s) const |
| Multiplication with scalar. | |
| Vec | operator+ (const Vec &v) const |
| Add two Vecs. | |
| Vec | operator- (const Vec &v) const |
| Subtract two Vecs. | |
| Vec | operator- () const |
| Unary minus. | |
| Vec & | operator+= (const Vec &v) |
| Add a Vec to this one. | |
| Vec & | operator-= (const Vec &v) |
| Subtract a vec from this one. | |
| Vec & | operator*= (double s) |
| Multiply this vec with a scalar. | |
| Vec & | operator/= (double s) |
| Divide this Vec with a scalar. | |
| double | operator[] (int n) const |
| const indexing | |
| double & | operator[] (int n) |
| Non-const indexing. | |
Public Attributes | |
| double | x [3] |
| The actual data. | |
Friends | |
| Vec | Cross (const Vec &v1, const Vec &v2) |
| Cross product of two Vecs. | |
| double | Length2 (const Vec &v) |
| The length of a Vec. | |
| void | Vaxpy (double a, const Vec &x, Vec &y) |
| Increment y with a times x. | |
| ostream & | operator<< (ostream &out, const Vec &v) |
| Print a Vec. | |
| istream & | operator>> (istream &in, Vec &v) |
| Read a Vec. | |
A 3-vector useful for postions etc.
The only data is the three positions (and there are no virtual functions), so the memory layout of an array of Vecs will be x0, y0, z0, x1, y1, z1, x2, ...
Almost all operations are inline for speed.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |