...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Construct a box with inverse infinite coordinates.
The make_inverse function initializes a 2D or 3D box with large coordinates, the min corner is very large, the max corner is very small. This is useful e.g. in combination with the expand function, to determine the bounding box of a series of geometries.
template<typename Geometry> Geometry make_inverse()
Type |
Concept |
Name |
Description |
---|---|---|---|
Geometry |
Any type fulfilling a Geometry Concept |
- |
Must be specified |
The constructed geometry, here: a box
Either
#include <boost/geometry.hpp>
Or
#include <boost/geometry/algorithms/make.hpp>
Usage of make_inverse and expand to conveniently determine bounding box of several objects
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/box.hpp> #include <boost/geometry/geometries/point_xy.hpp> using namespace boost::geometry; int main() { typedef model::d2::point_xy<double> point; typedef model::box<point> box; box all = make_inverse<box>(); std::cout << dsv(all) << std::endl; expand(all, make<box>(0, 0, 3, 4)); expand(all, make<box>(2, 2, 5, 6)); std::cout << dsv(all) << std::endl; return 0; }
Output:
((1.79769e+308, 1.79769e+308), (-1.79769e+308, -1.79769e+308)) ((0, 0), (5, 6))