[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13. vcsl: Co-ordinate systems

Chapter summary: Metric entities, co-ordinate systems and transformations.

This non-core Level 2 library vcsl is intended to provide an environment for representing co-ordinate systems, transformations, dimensions, and metric units.

This includes classes for


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.1 Contents


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.1.1 Metric and Dimensional classes


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.1.2 Co-ordinate Systems and Transformations


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.2 Examples

The following example shows how to use and build a set of co-ordinate systems.

 
#include <vcsl/vcsl_cartesian_3d.h>
#include <vcsl/vcsl_rotation_3d.h>
#include <vcsl/vcsl_graph.h>
...
  //: Convenient indices for vectors representing points, etc.
  enum AXES { X, Y, Z, T };

  //: Graph of defined CS (Co-ordinate system)
  // All CS must be added to this graph as they are created.
  vcsl_graph_sptr graphCS = new vcsl_graph;

  //: World Coordinate System
  // Equivalent to the Top view, by definition.
  //
  // A CS for which no parent is defined is absolute.  Logically,
  // there must be one absolute CS which all other directly or
  // indirectly relate to.
  vcsl_spatial_sptr WCS = new vcsl_cartesian_3d;

  // Add WCS to the global map of coordinate systems.
  WCS->set_graph(graphCS);

  // New CS can be defined relative to any point (translation) or
  // axis (rotation) in the parent CS.  But it is so common to do
  // so relative to the X, Y, or Z axes, that it is convenient to
  // define the corresponding vectors:

  //: x-axis vector
  vnl_vector_fixed <double, 3> xA;
  xA[X]=1; xA[Y] = 0; xA[Z] = 0;

  //: y-axis vector
  vnl_vector_fixed <double, 3> yA;
  yA[X]=0; yA[Y] = 1; yA[Z] = 0;

  //: z-axis vector
  vnl_vector_fixed <double, 3> zA;
  zA[X]=0; zA[Y] = 0; zA[Z] = 1;

  //: 90 degree rotation about WCS y-axis
  // Transforms from WCS to right CS
  vcsl_rotation_3d rightXF;
  rightXF.set_static(vnl_math::pi_over_2, yA);

  //: WCS rotated 90 degrees about the y-axis to produce right hand view/CS
  vcsl_spatial_sptr right = new vcsl_cartesian_3d;
  right->set_graph(graphCS);
  right->set_unique(WCS, &rightXF);

  //: Corner of a box with opposite corner at origin of WCS.
  vnl_vector_fixed <double, 3> corner;
  corner[X] = 1; corner[Y] = 2; corner[Z] = 3;

  // By inspection, corner should be (-3,2,1) in 'right' CS
  vnl_vector<double> cornerXF = WCS->from_local_to_cs(corner, right, 0);

  vcl_cout << cornerXF.x() << ", " << cornerXF.y() << ", " << cornerXF.z() << '\n';

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.3 Further Work

  1. Write conversion between classic coordinate systems in the same style as the class vcsl_cylindrical_to_cartesian_3d (singleton pattern)
  2. Add other units and dimensions
  3. In vcsl_transformation, add
     
    //: May `this' have a matrix representation ?
    virtual bool is_linear(void) const=0;
    
    //: Homogeneous matrix of `this' at time `time'
    // REQUIRE: is_valid()
    // REQUIRE: is_linear()
    virtual vnl_matrix<double> matrix_value(const double time, bool type) const;
    

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on May, 1 2013 using texi2html 1.76.