T interpolate( fcppt::container::grid::object< T, N, A > const &_grid, fcppt::math::vector::static_< F, N > const &_floating_point_position, Interpolator const &_interpolator ) { typedef fcppt::container::grid::object< T, N, A > grid_type; typedef fcppt::container::grid::pos_type< grid_type > integer_vector_type; typedef std::array< integer_vector_type, fcppt::math::power_of_2< std::size_t >( N ) > binary_vector_array_type; typedef typename binary_vector_array_type::size_type binary_vector_array_type_size_type; typedef F vector_value_type; integer_vector_type const floored( fcppt::math::vector::to_unsigned( fcppt::math::vector::structure_cast< typename grid_type::signed_pos, fcppt::cast::float_to_int_fun >( _floating_point_position ) ) ); binary_vector_array_type binary_vectors( fcppt::math::vector::bit_strings< fcppt::type_traits::value_type< integer_vector_type >, N >() ); for( integer_vector_type &i : binary_vectors ) i += floored; return fcppt::container::grid::detail::interpolate< integer_vector_type::dim_wrapper::value >( _grid, binary_vectors, fcppt::literal< binary_vector_array_type_size_type >( 0 ), fcppt::math::vector::mod( _floating_point_position, fcppt::literal< vector_value_type >( 1 ) ).get_unsafe(), _interpolator ); }
typename Grid::value_type interpolate( Grid const &grid, Vector const &floating_point_position, Interpolator const &interpolator) { typedef typename Grid::pos integer_vector_type; typedef std::array < integer_vector_type, fcppt::literal< std::size_t >( 1u ) << integer_vector_type::dim_wrapper::value > binary_vector_array_type; typedef typename binary_vector_array_type::size_type binary_vector_array_type_size_type; typedef typename Vector::value_type vector_value_type; integer_vector_type const floored( fcppt::math::vector::to_unsigned( fcppt::math::vector::structure_cast< typename Grid::signed_pos, fcppt::cast::float_to_int_fun >( floating_point_position ) ) ); binary_vector_array_type binary_vectors( fcppt::math::generate_binary_vectors < typename integer_vector_type::value_type, integer_vector_type::dim_wrapper::value >()); for( integer_vector_type &i : binary_vectors ) i += floored; return fcppt::container::grid::detail::interpolate< integer_vector_type::dim_wrapper::value >( grid, binary_vectors, fcppt::literal< binary_vector_array_type_size_type >( 0 ), fcppt::math::vector::mod( floating_point_position, fcppt::literal< vector_value_type >( 1 ) ), interpolator ); }