00001 #ifndef INCLUDE_LINEARENVELOPE_H
00002 #define INCLUDE_LINEARENVELOPE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "Envelope.h"
00037 #include <map>
00038
00039
00040 namespace Loris {
00041
00042
00043
00044
00068
00069 class LinearEnvelope : public Envelope, private std::map< double, double >
00070 {
00071
00072 public:
00073
00074
00077 LinearEnvelope( void );
00078
00085 explicit LinearEnvelope( double initialValue );
00086
00087
00088
00089
00090
00093 virtual LinearEnvelope * clone( void ) const;
00094
00100 virtual double valueAt( double t ) const;
00101
00102
00103
00111 void insert( double time, double value );
00112
00119 void insertBreakpoint( double time, double value )
00120 { insert( time, value ); }
00121
00122
00127 LinearEnvelope & operator+=( double offset );
00128
00133 LinearEnvelope & operator-=( double offset )
00134 {
00135 return operator+=( -offset );
00136 }
00137
00143 LinearEnvelope & operator*=( double scale );
00144
00150 LinearEnvelope & operator/=( double div )
00151 {
00152 return operator*=( 1.0 / div );
00153 }
00154
00155
00156
00157 using std::map< double, double >::size;
00158 using std::map< double, double >::empty;
00159 using std::map< double, double >::clear;
00160 using std::map< double, double >::begin;
00161 using std::map< double, double >::end;
00162 using std::map< double, double >::size_type;
00163 using std::map< double, double >::value_type;
00164 using std::map< double, double >::iterator;
00165 using std::map< double, double >::const_iterator;
00166
00167 };
00168
00169
00170
00171
00174 inline
00175 LinearEnvelope operator+( LinearEnvelope env, double offset )
00176 {
00177 env += offset;
00178 return env;
00179 }
00180
00183 inline
00184 LinearEnvelope operator+( double offset, LinearEnvelope env )
00185 {
00186 env += offset;
00187 return env;
00188 }
00189
00192 inline
00193 LinearEnvelope operator-( LinearEnvelope env, double offset )
00194 {
00195 env -= offset;
00196 return env;
00197 }
00198
00201 inline
00202 LinearEnvelope operator-( double offset, LinearEnvelope env )
00203 {
00204 env *= -1.0;
00205 env += offset;
00206 return env;
00207 }
00208
00211 inline
00212 LinearEnvelope operator*( LinearEnvelope env, double scale )
00213 {
00214 env *= scale;
00215 return env;
00216 }
00217
00220 inline
00221 LinearEnvelope operator*( double scale, LinearEnvelope env )
00222 {
00223 env *= scale;
00224 return env;
00225 }
00226
00229 inline
00230 LinearEnvelope operator/( LinearEnvelope env, double div )
00231 {
00232 env /= div;
00233 return env;
00234 }
00235
00239 LinearEnvelope operator/( double scale, LinearEnvelope env );
00240
00241
00242 }
00243
00244 #endif