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

code to perform combined scaling and translation on coordinates More...

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

Go to the source code of this file.

Classes

struct  vspline::domain_type< coordinate_type, _vsize >
 class domain is a coordinate transformation functor. It provides a handy way to translate an arbitrary range of incoming coordinates to an arbitrary range of outgoing coordinates. This is done with a linear translation function. if the source range is [s0,s1] and the target range is [t0,t1], the translation function s->t is: More...
 

Namespaces

namespace  vspline
 

Functions

template<class coordinate_type , size_t _vsize = vspline::vector_traits<coordinate_type>::vsize>
vspline::domain_type< coordinate_type, _vsize > vspline::domain (const coordinate_type &in_low, const coordinate_type &in_high, const coordinate_type &out_low, const coordinate_type &out_high)
 factory function to create a domain_type type object from the desired lower and upper fix point for incoming coordinates and the lower and upper fix point for outgoing coordinates. the resulting functor maps incoming coordinates in the range of [in_low,in_high] to coordinates in the range of [out_low,out_high] More...
 
template<class coordinate_type , class spline_type , size_t _vsize = vspline::vector_traits<coordinate_type>::vsize>
vspline::domain_type< coordinate_type, _vsize > vspline::domain (const coordinate_type &in_low, const coordinate_type &in_high, const spline_type &bspl)
 factory function to create a domain_type type object from the desired lower and upper reference point for incoming coordinates and a vspline::bspline object providing the lower and upper reference for outgoing coordinates the resulting functor maps incoming coordinates in the range of [ in_low , in_high ] to coordinates in the range of [ bspl.lower_limit() , bspl.upper_limit() ] More...
 
template<class coordinate_type , class spline_type , size_t _vsize = vspline::vector_traits<coordinate_type>::vsize>
vspline::domain_type< coordinate_type, _vsize > vspline::domain (const spline_type &bspl, const coordinate_type &out_low, const coordinate_type &out_high)
 factory function to create a domain_type type object from a vspline::bspline object providing the lower and upper reference for incomoing coordinates and the desired lower and upper reference point for outgoing coordinates the resulting functor maps incoming coordinates in the range of [ bspl.lower_limit() , bspl.upper_limit() ] to coordinates in the range of [ out_low , out_high ] More...
 
template<class coordinate_type , class spline_type , size_t _vsize = vspline::vector_traits<coordinate_type>::vsize>
vspline::domain_type< coordinate_type, _vsize > vspline::domain (const spline_type &bspl_in, const spline_type &bspl_out)
 factory function to create a domain_type type object from a vspline::bspline object providing the lower and upper reference for incomoing coordinates and a vspline::bspline object providing the lower and upper reference for outgoing coordinates the resulting functor maps incoming coordinates in the range of [ bspl_in.lower_limit() , bspl_in.upper_limit() ] to outgoing coordinates in the range of [ bspl_out.lower_limit() , bspl_out.upper_limit() ] More...
 

Detailed Description

code to perform combined scaling and translation on coordinates

This is what might be called collateral code, class domain is not currently used in vspline.

A common requirement is to map coordinates in one range to another range, effectively performing a combined scaling and translation. Given incoming coordinates in a range [ in_low , in_high ] and a desired range for outgoing coordinates of [ out_low , out_high ], and an incoming coordinate c, a vspline::domain performs this operation:

c' = ( c - in_low ) * scale + out_low

where

scale = ( out_high - out_low ) / ( in_high - in_low )

The code can handle arbitrary dimensions, float and double coordinate elementary types, and, optionally, it can perform vectorized operations on vectorized coordinates.

vspline::domain is derived from vspline::unary_functor and can be used like any other vspline::unary_functor. A common use case would be to access a vspline::evaluator with a different coordinate range than the spline's 'natural' coordinates (assuming a 1D spline of floats):

auto _ev = vspline::make_safe_evaluator ( bspl ) ; auto ev = vspline::domain ( bspl , 0 , 100 ) + _ev ;

ev.eval ( coordinate , result ) ;

Here, the domain is built over the spline with an incoming range of [ 0 , 100 ], so evaluating at 100 will be equivalent to evaluating _ev at bspl.upper_limit().

Definition in file domain.h.