Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Unexpected resulst from Polytope distance

Subject: CGAL users discussion list

List archive

[cgal-discuss] Unexpected resulst from Polytope distance


Chronological Thread 
  • From: Martin Uhrin <>
  • To:
  • Subject: [cgal-discuss] Unexpected resulst from Polytope distance
  • Date: Wed, 26 Feb 2014 19:42:37 +0000

I'm getting unexpected results from Polytope_distance_d running a
similar query to this post [1]. Specifically, I'm looking for the
nearest point on a polygon to a given point on the unbounded side of
it. A reduced example:

#include <iostream>
#include <CGAL/MP_Float.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polytope_distance_d.h>
#include <CGAL/Polytope_distance_d_traits_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::MP_Float ET;
typedef CGAL::Polytope_distance_d_traits_2< K, ET, K::RT> DistTraits;
typedef CGAL::Polytope_distance_d< DistTraits> PolyDist;

int main()
{
using namespace CGAL;
using namespace std;
typedef K::Point_2 Point;

Polygon_2<K> p;
p.push_back(Point(1.2, 3.4)); // Construct square
p.push_back(Point(1.1, 3.4));
p.push_back(Point(1.1, 3.5));
p.push_back(Point(1.2, 3.5));

Point q(1.15735, 3.33821);

PolyDist dist(p.vertices_begin(), p.vertices_end(), &q, (&q) + 1);

cout << dist;
PolyDist::Coordinate_iterator it =
dist.realizing_point_p_coordinates_begin();
cout << "Realising p: " << *it;
cout << " " << *++it << "\n";

it = dist.realizing_point_q_coordinates_begin();
cout << "Realising q: " << *it;
cout << " " << *++it << "\n";

return 0;
}

Output:

martin@pico:~/temp/polytope_dist$ g++ poly_dist.cpp -lCGAL
-lboost_thread -lmpfr -lpthread -lgmp -frounding-math -o dist
martin@pico:~/temp/polytope_dist$ ./dist
4
1.2 3.4
1.1 3.4
1.1 3.5
1.2 3.5
1
1.15735 3.33821
Realising p: 0.0115735 0.034
Realising q: 0.0115735 0.0333821

Neither of these realising points seems to have any relation to my input
points.

g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
CGAL 4.3.

I've tried:
* Exact construction kernel (i.e. fully exact Polytope_distance)
* Swapping p & q order in constructor
* Gmpfr ET type

All of which produce the same output.

Any help you can provide is much appreciated,
-Martin

[1]
http://cgal-discuss.949826.n4.nabble.com/Distance-from-a-Convex-hull-3-to-Point-3-tt4656683.html#a4656704

--
Martin Uhrin Tel: +44
207 679 3466
Department of Physics & Astronomy Fax:+44 207 679 0595
University College London

Gower St, London, WC1E 6BT, U.K. http://www.cmmp.ucl.ac.uk



Archive powered by MHonArc 2.6.18.

Top of Page