Files
simgear/simgear/props/easing_functions_test.cxx
Thomas Geymayer c9bbbd18ec New interpolation/animation system.
Inspired by jQuery.animate() properties can be interpolated using
different easing functions and specifying an animation duration.
Additionally animations can be chained to get table-based
animations like with the current SGInterpolator, or also create
looped animations or other more complicated curves.

Currently this system is not used yet, but it is intended to
replace SGInterpolator and allow more advanced animations of
eg. also colors, for example, for the canvas.
2013-03-15 23:37:17 +01:00

55 lines
1.0 KiB
C++

/*
* easing_functions_test.cxx
*
* Output values of all easing functions for plotting and some simple tests.
*
* Created on: 15.03.2013
* Author: tom
*/
#include "easing_functions.hxx"
#include <cmath>
#include <iostream>
#define VERIFY_CLOSE(a, b) \
if( std::fabs(a - b) > 1e-5 ) \
{ \
std::cerr << "failed: line " << __LINE__ << ": "\
<< a << " != " << b\
<< std::endl; \
return 1; \
}
int main(int argc, char* argv[])
{
using simgear::easing_functions;
for( double t = 0; t <= 1; t += 1/32. )
{
if( t == 0 )
{
for( size_t i = 0; easing_functions[i].name; ++i )
std::cout << easing_functions[i].name << " ";
std::cout << '\n';
}
for( size_t i = 0; easing_functions[i].name; ++i )
{
double val = (*easing_functions[i].func)(t);
std::cout << val << " ";
if( t == 0 )
{
VERIFY_CLOSE(val, 0)
}
else if( t == 1 )
{
VERIFY_CLOSE(val, 1)
}
}
std::cout << '\n';
}
return 0;
}