
Geometry : 
Subject: Re: [geometry] convex_hull  3D possible?
From: Menelaos Karavelas (menelaos.karavelas_at_[hidden])
Date: 20140605 05:24:56
Hi Oliver.
On 05/06/2014 12:18 Î¼Î¼, Oliver Weinheimer wrote:
> I am trying to use boost::geometry::convex_hull in 3D.
> The convex hull of a cuboid should be the cuboid itself.
> But i get just 5 instead of 8 points for the convex hull in my example code.
> What is wrong with the code?
I think that convex hull is implemented only for 2D geometries.
> Code:
>
> typedef boost::geometry::model::point<double, 3,
> boost::geometry::cs::cartesian> point3D;
> typedef boost::geometry::model::multi_point<point3d> points3d;
>
> points3d all_points;
> boost::geometry::append(all_points,point3d(0,0,0));
> boost::geometry::append(all_points,point3d(1,0,0));
> boost::geometry::append(all_points,point3d(1,1,0));
> boost::geometry::append(all_points,point3d(0,1,0));
> boost::geometry::append(all_points,point3d(0,1,1));
> boost::geometry::append(all_points,point3d(1,1,1));
> boost::geometry::append(all_points,point3d(1,0,1));
> boost::geometry::append(all_points,point3d(0,0,1));
>
> points3d hull3d;
> boost::geometry::convex_hull(all_points, hull3d);
>
> using boost::geometry::dsv;
> std::cout
> << "all_points: " << dsv(all_points) << std::endl
> << "hull: " << dsv(hull3d) << std::endl;
>
> std::cout << "size of all points: " << all_points.size() << std::endl;
> std::cout << "size of hull3d: " << hull3d.size() << std::endl;
>
> Output:
>
> all_points: ((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 1, 1), (1, 1,
> 1), (1, 0, 1), (0, 0, 1))
> hull: ((0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 0, 1), (0, 0, 0))
The 3rd coordinate is basically thrown away. What you get is the convex
hull of the projections of the points on the xyplane, represented
though with your original 3D points.
 m.
>
>
> 
> View this message in context: http://boostgeometry.203548.n3.nabble.com/convexhull3Dpossibletp4026100.html
> Sent from the Boost Geometry mailing list archive at Nabble.com.
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry
Geometry list run by mateusz at loskot.net