Subject: CGAL users discussion list
List archive
- From: Martin Uhrin <>
- To:
- Subject: Re: [cgal-discuss] Unexpected resulst from Polytope distance
- Date: Wed, 26 Feb 2014 13:10:23 -0800 (PST)
I've just realised where my error is.
For anyone in this situation in the future: I hadn't read the manual [1]
properly, specifically:
"Note
The coordinates have a rational representation, i.e. the first d
elements of the iterator range are the numerators and the (d+1)-st element
is the common denominator. "
So indeed the (d+1)^th element contained the denominator that when applied
gives the correct answer.
Apologies for jumping the gun on posting.
-Martin
[1]
http://doc.cgal.org/latest/Polytope_distance_d/classCGAL_1_1Polytope__distance__d.html#a8f75d3a4cfec3ea036c88b8fe8c37381
Martin Uhrin wrote
> 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
> martin.uhrin.10@.ac
> Gower St, London, WC1E 6BT, U.K. http://www.cmmp.ucl.ac.uk
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
Martin Uhrin wrote
> 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
> martin.uhrin.10@.ac
> Gower St, London, WC1E 6BT, U.K. http://www.cmmp.ucl.ac.uk
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Unexpected-resulst-from-Polytope-distance-tp4658871p4658872.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Unexpected resulst from Polytope distance, Martin Uhrin, 02/26/2014
- Re: [cgal-discuss] Unexpected resulst from Polytope distance, Martin Uhrin, 02/26/2014
Archive powered by MHonArc 2.6.18.