contrib/brl/bbas/bvgl/bvgl_articulated_poly.h
Go to the documentation of this file.
00001 #ifndef bvgl_articulated_poly_h_
00002 #define bvgl_articulated_poly_h_
00003 //-----------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \brief A polyline with articulated joints
00007 //
00008 // \author
00009 //  J.L. Mundy - January 13, 2007
00010 //
00011 //-----------------------------------------------------------------------------
00012 #include <vcl_vector.h>
00013 #include <vgl/algo/vgl_h_matrix_2d.h>
00014 #include <vsol/vsol_point_2d_sptr.h>
00015 #include <vsol/vsol_polyline_2d.h>
00016 #include "bvgl_articulated_poly_sptr.h"
00017 
00018 //-----------------------------------------------------------------------------
00019 class bvgl_articulated_poly : public vsol_polyline_2d
00020 {
00021  public:
00022   bvgl_articulated_poly(const unsigned n_joints);
00023   bvgl_articulated_poly(const unsigned n_joints, vcl_vector<double> const& link_lengths);
00024   bvgl_articulated_poly(const bvgl_articulated_poly& poly);
00025   ~bvgl_articulated_poly() {}
00026 
00027   vgl_h_matrix_2d<double> joint_transform(unsigned joint) const
00028     {return joint_transforms_[joint];}
00029 
00030   //: angle between joint and joint+1
00031   double joint_angle(unsigned joint) const;
00032 
00033   //: link from joint to joint+1
00034   double link_length(unsigned joint) const;
00035 
00036   vsol_point_2d_sptr joint_position(const unsigned joint) const;
00037 
00038   //:Transform the articulation
00039   void transform(vcl_vector<double > const& delta_joint_angle);
00040 
00041   void sub_manifold_transform(const double t,
00042                               vcl_vector<double > const& basis_angles);
00043 
00044 
00045   //:Compute the Lie distance between two articulations
00046   static double lie_distance(bvgl_articulated_poly const& ap1,
00047                              bvgl_articulated_poly const& ap2) ;
00048 
00049   //: Projection onto the sub manifold
00050   static bvgl_articulated_poly_sptr
00051     projection(bvgl_articulated_poly_sptr const& target,
00052                vcl_vector<double > const& manifold_basis);
00053 
00054   //:debug support
00055   void print();
00056   void print_xforms();
00057 
00058  private:
00059   //: called when the state of the polygon changes
00060   void update();
00061   bvgl_articulated_poly() {} //not available
00062   //:the inverse joint transforms for the current state of the articulation
00063   vcl_vector<vgl_h_matrix_2d<double> > joint_transforms_;
00064 };
00065 
00066 #endif // bvgl_articulated_poly_h_