Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// CODE
- include "math";
- function lerp(a,b,t){return a+(b-a)*t;}
- from = 5;
- to = 7;
- factor = 0.5;
- x = from;
- delta = 0.1;
- println( "from = 5, to = 7, factor = 0.5" );
- println( "10 frames" );
- for( i = 0; i < 10; ++i )
- {
- x = lerp( x, to, 1 - pow( factor, delta ) );
- println( "frame "$i+1$" / 10: "$x );
- }
- x = from;
- delta = 0.05;
- println( "20 frames" );
- for( i = 0; i < 20; ++i )
- {
- x = lerp( x, to, 1 - pow( factor, delta ) );
- println( "frame "$i+1$" / 10: "$x );
- }
- //// RESULTS
- from = 5, to = 7, factor = 0.5
- 10 frames
- frame 1 / 10: 5.13393
- frame 2 / 10: 5.2589
- frame 3 / 10: 5.3755
- frame 4 / 10: 5.48428
- frame 5 / 10: 5.58579
- frame 6 / 10: 5.68049
- frame 7 / 10: 5.76886
- frame 8 / 10: 5.8513
- frame 9 / 10: 5.92823
- frame 10 / 10: 6
- 20 frames
- frame 1 / 10: 5.06813
- frame 2 / 10: 5.13393
- frame 3 / 10: 5.1975
- frame 4 / 10: 5.2589
- frame 5 / 10: 5.31821
- frame 6 / 10: 5.3755
- frame 7 / 10: 5.43083
- frame 8 / 10: 5.48428
- frame 9 / 10: 5.53591
- frame 10 / 10: 5.58579
- frame 11 / 10: 5.63396
- frame 12 / 10: 5.68049
- frame 13 / 10: 5.72544
- frame 14 / 10: 5.76886
- frame 15 / 10: 5.81079
- frame 16 / 10: 5.8513
- frame 17 / 10: 5.89043
- frame 18 / 10: 5.92823
- frame 19 / 10: 5.96474
- frame 20 / 10: 6
- ////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement