Boost logo

Geometry :

Subject: [geometry] convex_hull - 3D possible?
From: Oliver Weinheimer (mail_at_[hidden])
Date: 2014-06-05 05:18:43


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?

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))

--
View this message in context: http://boost-geometry.203548.n3.nabble.com/convex-hull-3D-possible-tp4026100.html
Sent from the Boost Geometry mailing list archive at Nabble.com.

Geometry list run by mateusz at loskot.net