A class representing axis-aligned rectangles, boxes, hypercubes, ...
Overview
A box is defined by two n-dimensional points. For example, a rectangle has a dimension of 2. The two points give a minimum bound and a non-inclusive maximum bound. More precisely, let a box be given by p = (x_1,...,x_n) and q = (y_1,...,y_n). A point r = (z_1,...,z_n) is inside the box if for all 1 <= i <= n it holds that x_i <=
z_i < y_i. This representation makes it easy to specify empty boxes: For example, a rectangle defined by (1,2), (1,2) is empty.
Constructors and getters
A box can be constructed in two ways:
There are getters and setters for both representations as well:
std::cout << box.
pos() <<
", " << box.max() <<
'\n';
std::cout << box.pos() << ", " << box.size() << '\n';
Header files
| Header file | Description |
object_fwd.hpp | Contains fcppt::math::box::object's declaration. |
object_decl.hpp | Contains fcppt::math::box::object's definition. |
object_impl.hpp | Contains the definition of fcppt::math::box::object's member functions. |
object.hpp | Includes object_fwd.hpp, object_decl.hpp and object_impl.hpp. |
comparison.hpp | Contains all comparison operators. |
output.hpp | Contains operator<<. |
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N >::vector | fcppt::math::box::center (fcppt::math::box::object< T, N > const &_box) |
| | Returns the center of the box.
|
| template<typename T, fcppt::math::size_type N> |
| bool | fcppt::math::box::operator== (fcppt::math::box::object< T, N > const &_a, fcppt::math::box::object< T, N > const &_b) |
| | Compare two boxes componentwise using value_type's operator==.
|
| template<typename T, fcppt::math::size_type N> |
| bool | fcppt::math::box::operator!= (fcppt::math::box::object< T, N > const &_a, fcppt::math::box::object< T, N > const &_b) |
| | Compare two boxes componentwise using value_type's operator!=.
|
| template<typename T, fcppt::math::size_type N> |
| bool | fcppt::math::box::componentwise_equal (fcppt::math::box::object< T, N > const &_v1, fcppt::math::box::object< T, N > const &_v2, T const _epsilon) |
| | Compare two boxes component-wise using an epsilon.
|
| template<typename T, fcppt::math::size_type N> |
| bool | fcppt::math::box::contains (fcppt::math::box::object< T, N > const &_outer, fcppt::math::box::object< T, N > const &_inner) |
| | Test if one box is completely inside another box.
|
| template<typename T, typename S, fcppt::math::size_type N> |
| bool | fcppt::math::box::contains_point (fcppt::math::box::object< T, N > const &_box, fcppt::math::vector::object< T, N, S > const &_point) |
| | Test if a box contains a point.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::array::object< fcppt::math::vector::static_< T, N >, fcppt::math::power_of_2< std::size_t >(N)> | fcppt::math::box::corner_points (fcppt::math::box::object< T, N > const &_box) |
| | Returns the 2^N corner points (vertices) of the given box.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::vector::static_< T, N > | fcppt::math::box::distance (fcppt::math::box::object< T, N > const &_box1, fcppt::math::box::object< T, N > const &_box2) |
| | Calculates the interval distance between all box dimensions.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::extend_bounding_box (fcppt::math::box::object< T, N > const _box, typename fcppt::math::box::object< T, N >::vector const _pos) |
| | Extend a box to fit a point in it.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::extend_bounding_box (fcppt::math::box::object< T, N > const &_box1, fcppt::math::box::object< T, N > const &_box2) |
| | Take the bounding box of two boxes.
|
| template<typename Box, typename Function> |
| Box | fcppt::math::box::init_dim (Function const &_function) |
| | Initializes a box from pairs of positions and sizes.
|
| template<typename Box, typename Function> |
| Box | fcppt::math::box::init_max (Function const &_function) |
| | Initializes a box from pairs of min and max positions.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::intersection (fcppt::math::box::object< T, N > const &_a, fcppt::math::box::object< T, N > const &_b) |
| | Calculates the intersection of two boxes (which is, again, a box).
|
| template<typename T, fcppt::math::size_type N> |
| bool | fcppt::math::box::intersects (fcppt::math::box::object< T, N > const &_a, fcppt::math::box::object< T, N > const &_b) |
| | Tests if two boxes intersect.
|
| template<fcppt::math::size_type Index, typename T, fcppt::math::size_type N> |
| fcppt::tuple::object< T, T > | fcppt::math::box::interval (fcppt::math::box::object< T, N > const &_box) |
| | Creates an interval from a box.
|
| template<typename Box> |
| Box | fcppt::math::box::null () |
| | Returns the null box.
|
| template<typename T, fcppt::math::size_type N, typename Ch, typename Traits> |
| std::basic_ostream< Ch, Traits > & | fcppt::math::box::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::math::box::object< T, N > const &_box) |
| | Outputs a box to a basic_ostream.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::shrink (fcppt::math::box::object< T, N > const &_box, typename fcppt::math::box::object< T, N >::vector const &_absolute_values) |
| | Shrink a box towards its center using an absolute value.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::stretch_absolute (fcppt::math::box::object< T, N > const &_box, typename fcppt::math::box::object< T, N >::vector const &_absolute_values) |
| | Stretch a box around its center using an absolute value.
|
| template<typename T, fcppt::math::size_type N> |
| fcppt::math::box::object< T, N > | fcppt::math::box::stretch_relative (fcppt::math::box::object< T, N > const &_box, typename fcppt::math::box::object< T, N >::vector const &_factors) |
| | Stretch a box around its center by a given factor.
|
| template<typename Dest, typename Conv, typename T, fcppt::math::size_type N> |
| Dest | fcppt::math::box::structure_cast (fcppt::math::box::object< T, N > const &_src) |
| | Converts a box into a different box of the same dimension using Conv.
|