3 #define GLM_ENABLE_EXPERIMENTAL
18 using int2 = glm::tvec2< int >;
19 using int3 = glm::tvec3< int >;
26 using bool2 = glm::tvec2< bool >;
27 using bool3 = glm::tvec3< bool >;
30 using uchar4 = glm::tvec4< unsigned char >;
37 template<
typename Type >
40 glm::tvec2< Type >
Read(
const char * source,
Context const * context )
const
42 return glm::tvec2< Type >( 0, 0 );
45 std::string
Write( glm::tvec2< Type > val,
Context const * context )
const
47 return SS() <<
"(" << val.x <<
", " << val.y <<
")" <<
SS::str();
51 template<
typename Type >
54 glm::tvec3< Type >
Read(
const char * source,
Context const * context )
const
56 return glm::tvec3< Type >( 0, 0, 0 );
59 std::string
Write( glm::tvec3< Type > val,
Context const * context )
const
61 return SS() <<
"(" << val.x <<
", " << val.y <<
", " << val.z <<
")" <<
SS::str();
65 template<
typename Type >
68 glm::tvec4< Type >
Read(
const char * source,
Context const * context )
const
70 return glm::tvec4< Type >( 0, 0, 0, 0 );
73 std::string
Write( glm::tvec4< Type > val,
Context const * context )
const
75 return SS() <<
"(" << val.x <<
", " << val.y <<
", " << val.z <<
", " << val.w <<
")" <<
SS::str();
89 return SS() <<
"(" << val.w <<
" | " << val.x <<
", " << val.y <<
", " << val.z <<
")" <<
SS::str();
104 std::array< std::array< std::string, 4 >, 4 > parts;
105 std::array< size_t, 4 > widths;
108 for(
size_t x = 0; x < 4; x++ )
109 for(
size_t y = 0; y < 4; y++ )
111 std::stringstream ss;
112 ss << std::setprecision( 3 ) << val[ x ][ y ];
113 parts[ y ][ x ] = ss.str();
114 auto w = parts[ y ][ x ].length();
115 if( widths[ x ] < w )
119 std::stringstream out;
123 for(
size_t i = 0; i < widths[ 0 ] + widths[ 1 ] + widths[ 2 ] + widths[ 3 ] + 6; i++ )
125 out <<
" ╮" << std::endl;
128 out <<
"│ ( " << std::setw( widths[ 0 ] ) << parts[ 0 ][ 0 ] <<
", " << std::setw( widths[ 1 ] ) << parts[ 0 ][ 1 ] <<
", " << std::setw( widths[ 2 ] ) << parts[ 0 ][ 2 ] <<
", " << std::setw( widths[ 3 ] ) << parts[ 0 ][ 3 ] <<
" ) │" << std::endl;
129 out <<
"│ ( " << std::setw( widths[ 0 ] ) << parts[ 1 ][ 0 ] <<
", " << std::setw( widths[ 1 ] ) << parts[ 1 ][ 1 ] <<
", " << std::setw( widths[ 2 ] ) << parts[ 1 ][ 2 ] <<
", " << std::setw( widths[ 3 ] ) << parts[ 1 ][ 3 ] <<
" ) │" << std::endl;
130 out <<
"│ ( " << std::setw( widths[ 0 ] ) << parts[ 2 ][ 0 ] <<
", " << std::setw( widths[ 1 ] ) << parts[ 2 ][ 1 ] <<
", " << std::setw( widths[ 2 ] ) << parts[ 2 ][ 2 ] <<
", " << std::setw( widths[ 3 ] ) << parts[ 2 ][ 3 ] <<
" ) │" << std::endl;
131 out <<
"│ ( " << std::setw( widths[ 0 ] ) << parts[ 3 ][ 0 ] <<
", " << std::setw( widths[ 1 ] ) << parts[ 3 ][ 1 ] <<
", " << std::setw( widths[ 2 ] ) << parts[ 3 ][ 2 ] <<
", " << std::setw( widths[ 3 ] ) << parts[ 3 ][ 3 ] <<
" ) │" << std::endl;
135 for(
size_t i = 0; i < widths[ 0 ] + widths[ 1 ] + widths[ 2 ] + widths[ 3 ] + 6; i++ )
151 return glm::distance( from, to );
156 if( distance == std::numeric_limits< Interpolator_float >::infinity() )
159 if( glm::distance( to, from ) <= distance )
162 return std::pair( from + glm::normalize( to - from ) * distance,
Interpolator_float( 0.0 ) );
174 float distance_sq = glm::length2( glm::row( diff, 0 ) ) + glm::length2( glm::row( diff, 1 ) ) + glm::length2( glm::row( diff, 2 ) ) + glm::length2( glm::row( diff, 3 ) );
175 return sqrt( distance_sq );
181 float current_distance_sq = glm::length2( glm::row( diff, 0 ) ) + glm::length2( glm::row( diff, 1 ) ) + glm::length2( glm::row( diff, 2 ) ) + glm::length2( glm::row( diff, 3 ) );
182 float current_distance = sqrt( current_distance_sq );
186 result[ 0 ][ 0 ] = from[ 0 ][ 0 ] + diff[ 0 ][ 0 ] / current_distance * distance;
187 result[ 0 ][ 1 ] = from[ 0 ][ 1 ] + diff[ 0 ][ 1 ] / current_distance * distance;
188 result[ 0 ][ 2 ] = from[ 0 ][ 2 ] + diff[ 0 ][ 2 ] / current_distance * distance;
189 result[ 0 ][ 3 ] = from[ 0 ][ 3 ] + diff[ 0 ][ 3 ] / current_distance * distance;
191 result[ 1 ][ 0 ] = from[ 1 ][ 0 ] + diff[ 1 ][ 0 ] / current_distance * distance;
192 result[ 1 ][ 1 ] = from[ 1 ][ 1 ] + diff[ 1 ][ 1 ] / current_distance * distance;
193 result[ 1 ][ 2 ] = from[ 1 ][ 2 ] + diff[ 1 ][ 2 ] / current_distance * distance;
194 result[ 1 ][ 3 ] = from[ 1 ][ 3 ] + diff[ 1 ][ 3 ] / current_distance * distance;
196 result[ 2 ][ 0 ] = from[ 2 ][ 0 ] + diff[ 2 ][ 0 ] / current_distance * distance;
197 result[ 2 ][ 1 ] = from[ 2 ][ 1 ] + diff[ 2 ][ 1 ] / current_distance * distance;
198 result[ 2 ][ 2 ] = from[ 2 ][ 2 ] + diff[ 2 ][ 2 ] / current_distance * distance;
199 result[ 2 ][ 3 ] = from[ 2 ][ 3 ] + diff[ 2 ][ 3 ] / current_distance * distance;
201 result[ 3 ][ 0 ] = from[ 3 ][ 0 ] + diff[ 3 ][ 0 ] / current_distance * distance;
202 result[ 3 ][ 1 ] = from[ 3 ][ 1 ] + diff[ 3 ][ 1 ] / current_distance * distance;
203 result[ 3 ][ 2 ] = from[ 3 ][ 2 ] + diff[ 3 ][ 2 ] / current_distance * distance;
204 result[ 3 ][ 3 ] = from[ 3 ][ 3 ] + diff[ 3 ][ 3 ] / current_distance * distance;
214 return std::pair( left.x, left.y ) < std::pair( right.x, right.y );
222 return std::pair( left.y, left.x ) < std::pair( right.y, right.x );
230 out <<
"( " << val.x <<
", " << val.y <<
" )";
236 out <<
"( " << val.x <<
", " << val.y <<
", " << val.z <<
" )";
242 out <<
"( " << val.x <<
", " << val.y <<
" )";
248 out <<
"( " << val.x <<
", " << val.y <<
", " << val.z <<
" )";
254 out <<
"( " << val.x <<
", " << val.y <<
", " << val.z <<
", " << val.w <<
" )";
260 out <<
"( " << val.x <<
", " << val.y <<
" )";
266 out <<
"( " << val.x <<
", " << val.y <<
", " << val.z <<
" )";
272 out <<
"( " << val.x <<
", " << val.y <<
", " << val.z <<
", " << val.w <<
" )";