vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Classes | Namespaces | Functions
map.h File Reference

code to handle out-of-bounds coordinates. More...

#include "unary_functor.h"
#include <assert.h>

Go to the source code of this file.

Classes

struct  vspline::pass_gate< rc_type, _vsize >
 class pass_gate passes it's input to it's output unmodified. More...
 
struct  vspline::reject_gate< rc_type, _vsize >
 reject_gate throws vspline::out_of_bounds for invalid coordinates More...
 
struct  vspline::clamp_gate< rc_type, _vsize >
 clamp gate clamps out-of-bounds values. clamp_gate takes four arguments: the lower and upper limit of the gate, and the values which are returned if the input is outside the range: 'lfix' if it is below 'lower' and 'ufix' if it is above 'upper' More...
 
struct  vspline::mirror_gate< rc_type, _vsize >
 mirror gate 'folds' coordinates into the range. From the infinite number of mirror images resulting from mirroring the input on the bounds, the only one inside the range is picked as the result. When using this gate type with splines with MIRROR boundary conditions, if the shape of the core for the axis in question is M, _lower would be passed 0 and _upper M-1. For splines with REFLECT boundary conditions, we'd pass -0.5 to _lower and M-0.5 to upper, since here we mirror 'between bounds' and the defined range is wider. More...
 
struct  vspline::periodic_gate< rc_type, _vsize >
 the periodic mapping also folds the incoming value into the allowed range. The resulting value will be ( N * period ) from the input value and inside the range, period being upper - lower. For splines done with PERIODIC boundary conditions, if the shape of the core for this axis is M, we'd pass 0 to _lower and M to _upper. More...
 
struct  vspline::map_functor< nd_rc_type, _vsize, gate_types >
 finally we define class mapper which is initialized with a set of gate objects (of arbitrary type) which are applied to each component of an incoming nD coordinate in turn. The trickery with the variadic template argument list is necessary, because we want to be able to combine arbitrary gate types (which have distinct types) to make the mapper as efficient as possible. the only requirement for a gate type is that it has to provide the necessary eval() functions. More...
 
struct  vspline::map_functor< nd_rc_type, _vsize, gate_types >::_map< level, dimension, nd_coordinate_type >
 
struct  vspline::map_functor< nd_rc_type, _vsize, gate_types >::_map< 0, dimension, nd_coordinate_type >
 
struct  vspline::map_functor< nd_rc_type, _vsize, gate_types >::_map< 0, 1, coordinate_type >
 

Namespaces

namespace  vspline
 

Functions

template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::pass_gate< rc_type, _vsize > vspline::pass ()
 factory function to create a pass_gate type functor More...
 
template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::reject_gate< rc_type, _vsize > vspline::reject (rc_type lower, rc_type upper)
 factory function to create a reject_gate type functor given a lower and upper limit for the allowed range. More...
 
template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::clamp_gate< rc_type, _vsize > vspline::clamp (rc_type lower, rc_type upper, rc_type lfix, rc_type rfix)
 factory function to create a clamp_gate type functor given a lower and upper limit for the allowed range, and, optionally, the values to use if incoming coordinates are out-of-range More...
 
template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::clamp_gate< rc_type, _vsize > vspline::clamp (rc_type lower, rc_type upper)
 
template<typename rc_v >
rc_v vspline::v_fmod (rc_v lhs, const typename rc_v::value_type &rhs)
 vectorized fmod function using std::trunc, which is fast, but checking the result to make sure it's always <= rhs. More...
 
template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::mirror_gate< rc_type, _vsize > vspline::mirror (rc_type lower, rc_type upper)
 factory function to create a mirror_gate type functor given a lower and upper limit for the allowed range. More...
 
template<typename rc_type , size_t _vsize = vspline::vector_traits < rc_type > :: size>
vspline::periodic_gate< rc_type, _vsize > vspline::periodic (rc_type lower, rc_type upper)
 factory function to create a periodic_gate type functor given a lower and upper limit for the allowed range. More...
 
template<typename nd_rc_type , size_t _vsize = vspline::vector_traits < nd_rc_type > :: size, class ... gate_types>
vspline::map_functor< nd_rc_type, _vsize, gate_types... > vspline::mapper (gate_types ... args)
 factory function to create a mapper type functor given a set of gate_type objects. Please see vspline::make_safe_evaluator for code to automatically create a mapper object suitable for a specific vspline::bspline. More...
 

Detailed Description

code to handle out-of-bounds coordinates.

Incoming coordinates may not be inside the range which can be evaluated by a functor. There is no one correct way of dealing with out-of-bounds coordinates, so I provide a few common ways of doing it.

If the 'standard' gate types don't suffice, the classes provided here can serve as templates.

The basic type handling the operation is a 'gate type', which 'treats' a single value or single simdized value. For nD coordinates, we use a set of these gate_type objects, one for each component; each one may be of a distinct type specific to the axis the component belongs to.

Application of the gates is via a 'mapper' object, which contains the gate_type objects and applies them to the components in turn.

The mapper object is a functor which converts an arbitrary incoming coordinate into a 'treated' coordinate (or, with REJECT mode, may throw an out_of_bounds exception).

mapper objects are derived from vspline::unary_functor, so they fit in well with other code in vspline and can easily be combined with other unary_functor objects, or used stand-alone. They are used inside vspline to implement the factory function vspline::make_safe_evaluator, which chains a suitable mapper and an evaluator to create an object allowing safe evaluation of a b-spline with arbitrary coordinates where out-of-range coordinates are mapped to the defined range in a way fitting the b-spline's boundary conditions.

Definition in file map.h.