Boost logo

Boost :

From: Hugo Duncan (hugoduncan_at_[hidden])
Date: 2007-03-20 09:19:54


We recently wrote some code that did some computaional mechanics and had
several bugs due to mixing frames of reference. Prompted by recent
discussions of affine spaces, I have developed some simple classes for
tracking different spaces, points and displacements at compile time.

    struct frame1 {};
    struct frame2 {};
    typedef ublas::bounded_vector<double,3> vector;

    typedef math::point<vector, frame1> point;
    typedef math::displacement<vector, frame1> displacement;

    point p1(ublas::scalar_vector<double>(3,1.));
    point p2(ublas::scalar_vector<double>(3,1.));
    displacement d1(ublas::scalar_vector<double>(3,1.));

    d1=p1+d1; //fails
    p1=p1+p1; //fails

    vector p3(ublas::scalar_vector<double>(3,1.));
    vector d2(ublas::scalar_vector<double>(3,1.));
    math::point_ref<frame2>(p3)+=d1; // fails
    math::point_ref<frame1>(p3)+=math::displacement_ref<frame2>(d2); //

The code is available in the math-geometry section of the boost vault at
as affine-0.0.3.tar.gz

Comments welcome on the utility of the approach and on the design are most


Boost list run by bdawes at, gregod at, cpdaniel at, john at