Logo Search packages:      
Sourcecode: inkscape version File versions

Piecewise< SBasis > Geom::interpolate ( std::vector< double >  times,
std::vector< double >  values,
unsigned  smoothness 
)

Retruns a Piecewise SBasis with prescribed values at prescribed times.

Parameters:
times,: vector of times at which the values are given. Should be sorted in increasing order.
values,: vector of prescribed values. Should have the same size as times and be sorted accordingly.
smoothness,: (defaults to 1) regularity class of the result: 0=piecewise linear, 1=continuous derivative, etc...

Definition at line 350 of file sbasis-math.cpp.

References Geom::Piecewise< T >::cuts, and Geom::Piecewise< T >::push().

                                                                                                     {
    assert ( values.size() == times.size() );
    if ( values.size() == 0 ) return Piecewise<SBasis>();
    if ( values.size() == 1 ) return Piecewise<SBasis>(values[0]);//what about time??

    SBasis sk = shift(Linear(1.),smoothness);
    SBasis bump_in = integral(sk);
    bump_in -= bump_in.at0();
    bump_in /= bump_in.at1();
    SBasis bump_out = reverse( bump_in );
    
    Piecewise<SBasis> result;
    result.cuts.push_back(times[0]);
    for (unsigned i = 0; i<values.size()-1; i++){
        result.push(bump_out*values[i]+bump_in*values[i+1],times[i+1]);
    }
    return result;
}


Generated by  Doxygen 1.6.0   Back to index