next up previous
Next: About this document ... Up: t_see_world Previous: t_see_world

8.3. Doing it really right

If you want to be current, you can use the Standard Type Library (STL), which has now been officially adopted as part of C++. There is a vector class vector that is handy. To access it, use

#include <vector.h> or

#include <vector> depending on the compiler.

You can still define vec3 and mat33 for convenience, as derived classes:

class vec3: public vector<double>
{
public:
    vec3():vector<double>(3){}
};

class mat33: public vector<vec3>
{
public:
    mat33():vector<vec3>(3){}
};

One advantage is that vector is already debugged. Another is that you don't need to write copy constructors and assignment operators, since the default ones work properly already on vectors. Also, [] is already defined for vectors.

You do still need to write the * operator for matrices and for a vector times a matrix. Also, if you want to be able to have debugging output you still need to write an ostream operator for vectors and another one for matrices. In addition, you'll need to write the functions identity33(), rot3, and cartesian


Kirby A. Baker 2002-02-21