|
5.0.0
Freundlich's C++ toolkit
|
A class representing axis-aligned rectangles, boxes, hypercubes, ...
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.
A box can be constructed in two ways:
A minimum point and a non-inclusive maximum point:
A minimum point and a size:
There are getters and setters for both representations as well:
| 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<<. |
Classes | |
| struct | fcppt::math::box::has_dim< Box, Dim > |
| Metafunction to check the dimension of a box. More... | |
| struct | fcppt::math::box::is_box< T > |
| Metafunction to test if a type is a box type. More... | |
| class | fcppt::math::box::object< T, N > |
| A class representing axis aligned boxes, cubes, hypercubes, ... More... | |
Typedefs | |
| template<typename T> | |
| using | fcppt::math::box::rect = fcppt::math::box::object<T, 2> |
| Typedefs a two dimensional box (a rect) | |
Functions | |
| 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. | |
| using fcppt::math::box::rect = fcppt::math::box::object<T, 2> |
Typedefs a two dimensional box (a rect)
| T | The box's value_type |
| 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.
| N | The box's dimension |
| T | The box's value_type |
Note that this might not calculate the box's "real" center, since the calculation is performed using T, which might be integral.
|
inline |
Compare two boxes component-wise using an epsilon.
Componentwise in this context means: Compare the positions and the sizes component-wise. For each component of the position and the size, check if the components differ by more than the specified epsilon. If so, return false.
|
inline |
Test if one box is completely inside another box.
| _outer | The outer (larger) box |
| _inner | The inner (smaller) box |
|
inline |
Test if a box contains a point.
| 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.
| 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.
| 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.
| 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.
The result will either be the same box (if the point is contained in the box) or a box that's just big enough to hold the given point.
|
inline |
Initializes a box from pairs of positions and sizes.
Initializes an object of type Box by calling _function for every index. The result _function must be a tuple where the first element is the position and the second element is the size.
| Box | Must be a box |
| Function | A (polymorphic) function of type fcppt::tuple::object<Box::value_type, Box::value_type> (Index) |
|
inline |
Initializes a box from pairs of min and max positions.
Initializes an object of type Box by calling _function for every index. The result _function must be a fcppt::tuple::object where the first element is the min position and the second element is the max position.
| Box | Must be a box |
| Function | A (polymorphic) function of type fcppt::tuple::object<Box::value_type,Box::value_type> (Index) |
| 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)
If there is no intersection, the null box will be returned.
|
inline |
Tests if two boxes intersect.
|
inline |
Creates an interval from a box.
|
inline |
Returns the null box.
|
inline |
Compare two boxes componentwise using value_type's operator!=
| 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.
| N | The box's dimension |
| T | The box's value_type |
The format will be
(position,size)
|
inline |
Compare two boxes componentwise using value_type's operator==
| 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.
| 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.
| 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.
| 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.
| T | The original box's value_type |
| Dest | The destination box's value_type |
| N | The box's dimension |