...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
assign to a box inverse infinite
The assign_inverse function initialize a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small. This is a convenient starting point to collect the minimum bounding box of a geometry.
template<typename Geometry> void assign_inverse(Geometry & geometry)
Type |
Concept |
Name |
Description |
---|---|---|---|
Geometry & |
Any type fulfilling a Geometry Concept |
geometry |
A model of the specified concept |
Either
#include <boost/geometry.hpp>
Or
#include <boost/geometry/algorithms/assign.hpp>
Usage of assign_inverse and expand to conveniently determine bounding 3D box of two points
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/box.hpp> #include <boost/geometry/geometries/point.hpp> using namespace boost::geometry; int main() { typedef model::point<float, 3, cs::cartesian> point; typedef model::box<point> box; box all; assign_inverse(all); std::cout << dsv(all) << std::endl; expand(all, point(0, 0, 0)); expand(all, point(1, 2, 3)); std::cout << dsv(all) << std::endl; return 0; }
Output:
((3.40282e+038, 3.40282e+038, 3.40282e+038), (-3.40282e+038, -3.40282e+038, -3.40282e+038)) ((0, 0, 0), (1, 2, 3))