X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Finterpolator.hh;fp=src%2Fmoof%2Finterpolator.hh;h=83dd0c9bdf095d1f289f8d8ec15896c294afd0b5;hp=0a7aa012b480747e69c7e3577c1c6f3c8546f9f8;hb=574af38ed616d1adfa5e6ce35f67cda1f707f89d;hpb=6c9943707d4f33035830eba0587a61a34eaecbc2 diff --git a/src/moof/interpolator.hh b/src/moof/interpolator.hh index 0a7aa01..83dd0c9 100644 --- a/src/moof/interpolator.hh +++ b/src/moof/interpolator.hh @@ -1,13 +1,11 @@ -/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +/*] Copyright (c) 2009-2011, Charles McGarvey [***************************** **] All rights reserved. * -* vi:ts=4 sw=4 tw=75 -* * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * -**************************************************************************/ +*****************************************************************************/ #ifndef _MOOF_INTERPOLATOR_HH_ #define _MOOF_INTERPOLATOR_HH_ @@ -40,10 +38,9 @@ public: { stop = 0, /// Interpolator will stop when done. repeat = 1, /// Interpolator will go back to the beginning. - oscillate = 2 /// Interpolator will reverse direction. + oscillate = 2 /// Interpolator will reverse direction. }; - /** * Construct an uninitialized interpolator. */ @@ -57,7 +54,8 @@ public: * \param t The duration of the interpolation. * \param mode The interpolation mode. */ - interpolator(const T& a, const T& b, scalar t = 1.0, mode mode = stop) : + interpolator(const T& a, const T& b, + scalar t = 1.0, mode mode = stop) : state_(a), prior_(a), a_(a), @@ -86,7 +84,6 @@ public: is_done_ = false; } - /** * Update the interpolation state with a timeslice. * \param t The total time in seconds. @@ -104,42 +101,40 @@ public: { switch (mode_) { - case stop: - alpha_ = SCALAR(1.0); - is_done_ = true; - break; - case repeat: - alpha_ -= SCALAR(1.0); - break; - case oscillate: - alpha_ = SCALAR(2.0) - alpha_; - scale_ = -scale_; - break; + case stop: + alpha_ = SCALAR(1.0); + is_done_ = true; + break; + case repeat: + alpha_ -= SCALAR(1.0); + break; + case oscillate: + alpha_ = SCALAR(2.0) - alpha_; + scale_ = -scale_; + break; } } else if (alpha_ < 0.0) { switch (mode_) { - case stop: - alpha_ = SCALAR(0.0); - is_done_ = true; - break; - case repeat: - alpha_ += SCALAR(1.0); - break; - case oscillate: - alpha_ = -alpha_; - scale_ = -scale_; - break; + case stop: + alpha_ = SCALAR(0.0); + is_done_ = true; + break; + case repeat: + alpha_ += SCALAR(1.0); + break; + case oscillate: + alpha_ = -alpha_; + scale_ = -scale_; + break; } } - state_ = function_(a_, b_, alpha_); } } - /** * Get the interpolated value. * \return The interpolated value. @@ -169,7 +164,6 @@ public: return is_done_; } - private: T state_; @@ -195,7 +189,6 @@ struct linear_interpolation_function } }; - typedef interpolator lerp_scalar;