![]() |
Trax3 3.1.0
trax track library
|
The spat and the dim libraries work together seemlessly to provide for our railway simulation what it calls 'the space'. A Position<Length> represents a point in this space; a Vector<One> represents a direction. Together they form a Frame<Length,One> that represents a complete frame of reference and allows for easy transformations. A velocity can be expressed as a Vector<Velocity>, an acceleration as a Vector<Acceleration>. A force might be a VectorBundle<Length,Force>, giving us both the point of application and the force vector itself.
In general the trax library uses Frame<Length,One> as a frame of reference, instead of matrices. This makes it possible to work with dimensionated values:
The Frame maintains a Position of dimension 'Length' and three Vectors of dimension 'One'. The three vectors are of unit length and orthogonal to each other, representing the three axes of our frame of reference. If you have a point P1, defined relative to a Frame F, it converts to global coordinates by:
A distance vector V betweent two points in space would transform like this:
To use spatial structures with dimensionated values:
Do also look at the tests in the test suit for further examples.