contrib/mul/msm/msm_reflect_shape.cxx
Go to the documentation of this file.
00001 //:
00002 // \file
00003 // \brief Functions to reflect shapes in various ways.
00004 //  Renumbering necessary for symmetric shapes.  For instance,
00005 //  if reflecting a face, the left eye becomes the right eye.
00006 //  This would mangle a model, so we renumber.
00007 // \author Tim Cootes
00008 
00009 #include "msm_reflect_shape.h"
00010 #include <vcl_cassert.h>
00011 
00012 //: Reflect points in the line x=ax, then re-number
00013 //  On exit, new_points[i] = points[relabel[i]] reflected in x=ax
00014 void msm_reflect_shape_along_x(const msm_points& points,
00015                                const vcl_vector<unsigned>& sym_pts,
00016                                msm_points& new_points,
00017                                double ax)
00018 {
00019   unsigned n= points.size();
00020   assert(sym_pts.size()==n);
00021   new_points.set_size(n);
00022   for (unsigned i=0;i<n;++i)
00023   {
00024     vgl_point_2d<double> p=points[i];
00025     double x = ax - (p.x()-ax);
00026     assert(sym_pts[i]<n);
00027     new_points.set_point(sym_pts[i],x,p.y());
00028   }
00029 }
00030