-
-
Save ThePhD/5fb0b979a355f87c3760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <Furrovine++/Mathema.h> | |
namespace Furrovine { | |
struct wrap_addresser { | |
template <typename Ta, typename Tu> | |
auto operator()( Ta&& a, Tu&& upper ) { | |
return modulus( std::forward<Ta>( a ), std::forward<Tu>( upper ) ); | |
} | |
}; | |
struct clamp_addresser { | |
template <typename Ta, typename Tu> | |
auto operator()( Ta&& a, Tu&& upper ) { | |
typedef typename std::decay<Ta>::type Tad; | |
return std::min( std::max( static_cast<Tad>( 0 ), std::forward<Ta>( a ) ), std::forward<Tu>( upper ) ); | |
} | |
}; | |
struct mirror_addresser { | |
template <typename Ta, typename Tu> | |
auto operator()( Ta&& a, Tu&& upper ) { | |
auto mult = ( a / upper ); | |
typedef decltype( mult ) mult_t; | |
auto x = static_cast<mult_t>( modulus( mult, static_cast<mult_t>( 2 ) ) < 1 ); | |
x = ( 2 * x ) - 1; | |
return ( a - ( upper * mult ) ) * x; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment