// // interpolate.cc // // Provide smooth steps between values // // Copyright (C) J. Belson 2000.02.03 // #include "interpolate.h" /** * Three floating point values */ interpolate_3f::interpolate_3f(float start1, float start2, float start3, float end1, float end2, float end3, int step) { n1 = start1; n2 = start2; n3 = start3; n1_inc = n2_inc = n3_inc = 0.0; if (step) { n1_inc = (end1 - start1)/step; n2_inc = (end2 - start2)/step; n3_inc = (end3 - start3)/step; } } void interpolate_3f::set(float start1, float start2, float start3, float end1, float end2, float end3, int step) { n1 = start1; n2 = start2; n3 = start3; n1_inc = n2_inc = n3_inc = 0.0; if (step) { n1_inc = (end1 - start1)/step; n2_inc = (end2 - start2)/step; n3_inc = (end3 - start3)/step; } } void interpolate_3f::next(void) { n1 += n1_inc; n2 += n2_inc; n3 += n3_inc; } /** * Two floating point values */ interpolate_2f::interpolate_2f(float start1, float start2, float end1, float end2, int step) { n1 = start1; n2 = start2; n1_inc = n2_inc = 0.0; if (step) { n1_inc = (end1 - start1)/step; n2_inc = (end2 - start2)/step; } } void interpolate_2f::set(float start1, float start2, float end1, float end2, int step) { n1 = start1; n2 = start2; n1_inc = n2_inc = 0.0; if (step) { n1_inc = (end1 - start1)/step; n2_inc = (end2 - start2)/step; } } void interpolate_2f::next(void) { n1 += n1_inc; n2 += n2_inc; } /** * Single floating point */ interpolate_f::interpolate_f(float start, float end, int step) { n = start; n_inc = 0.0; if (step) { n_inc = (end - start)/step; } } void interpolate_f::set(float start, float end, int step) { n = start; n_inc = 0.0; if (step) { n_inc = (end - start)/step; } } void interpolate_f::next(void) { n += n_inc; } /** * Single integer */ interpolate_i::interpolate_i(int start, int end, int steps) { a = start << SHIFT; inc = 0; if (steps) { inc = ((end - start)<