Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Polytope_distance_d error

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Polytope_distance_d error


Chronological Thread 
  • From: Bernd Gaertner <>
  • To:
  • Subject: Re: [cgal-discuss] Polytope_distance_d error
  • Date: Sun, 10 Jun 2007 18:09:18 +0200

MiTcX wrote:
hi all,

i've a little problem when i try to compute the Polytope_distance_d
between two polygons.
here is my code :

struct Kernel : public CGAL::Cartesian<float> {};

My previous suggestion to replace this with
Cartesian<CGAL::MP_Float> or Cartesian<CGAL::Gmpzf>
is wrong, since the number types in question are not
field types. Homogenous<CGAL::MP_Float> or
Homogenous<CGAL::Gmpzf> are appropriate kernels
here (see also attached file that works with CGAL 3.3).

Sorry about that.

Bernd.
#include <iostream>
#include <CGAL/Homogeneous.h>
#include <CGAL/Gmpzf.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polytope_distance_d.h>
#include <CGAL/Polytope_distance_d_traits_2.h>

typedef CGAL::Homogeneous<double> Kernel;
typedef CGAL::Polytope_distance_d_traits_2<Kernel, CGAL::Gmpzf, double> 
TraitsPolytope;
typedef CGAL::Polytope_distance_d<TraitsPolytope> Polytope_distance;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;

int main() {
    Polygon_2 p;
    p.push_back(Point_2(444,607));
    p.push_back(Point_2(445,97));
    p.push_back(Point_2(448,92));
    p.push_back(Point_2(449,610));
    Polygon_2 p1;
    p1.push_back(Point_2(212,91));
    p1.push_back(Point_2(448,92));
    p1.push_back(Point_2(445,97));
    p1.push_back(Point_2(213,96));
   
    Polytope_distance dist2
      (p.vertices_begin(),
       p.vertices_end(),
       p1.vertices_begin(),
       p1.vertices_end());

    std::cout<< "dist : "
	     << CGAL::to_double(dist2.squared_distance_numerator())/
                CGAL::to_double(dist2.squared_distance_denominator())
	     <<std::endl;

  return 0;

}



Archive powered by MHonArc 2.6.16.

Top of Page