00001
00002 namespace jafar {
00003 namespace geom {
00004 template<int dimension>
00005 double similarity( const Facet<dimension>& f1, const Facet<dimension>& f2)
00006 {
00007 double a1 = f1.perimeter();
00008 double b1 = f2.perimeter();
00009 double sim1 = (a1 > b1) ? (b1 / a1) : (a1 / b1);
00010 double a2 = f1.surface();
00011 double b2 = f2.surface();
00012 double sim2 = (a2 > b2) ? (b2 / a2) : (a2 / b2);
00013 return sim1 * sim2;
00014 }
00015 template<int dimension>
00016 double similarity( const Segment<dimension>& s1, const Segment<dimension>& s2 )
00017 {
00018 double a = s1.length();
00019 double b = s2.length();
00020 return (a > b) ? (b / a) : (a / b);
00021 }
00022 template<int dimension>
00023 double similarity( const PolyLine<dimension>& pl1, const PolyLine<dimension>& pl2 )
00024 {
00025 double a = pl1.perimeter();
00026 double b = pl2.perimeter();
00027 return (a > b) ? (b / a) : (a / b);
00028 }
00029 }
00030 }