Logo Search packages:      
Sourcecode: inkscape version File versions

OptInterval Geom::bounds_fast ( const SBasis &  sb,
int  order 
)

Find a small interval that bounds a

Parameters:
a sbasis function
Returns:
inteval

Definition at line 92 of file sbasis-roots.cpp.

                                                     {
#endif
    Interval res(0,0); // an empty sbasis is 0.

    for(int j = sb.size()-1; j>=order; j--) {
        double a=sb[j][0];
        double b=sb[j][1];

        double v, t = 0;
        v = res[0];
        if (v<0) t = ((b-a)/v+1)*0.5;
        if (v>=0 || t<0 || t>1) {
            res[0] = std::min(a,b);
        }else{
            res[0]=lerp(t, a+v*t, b);
        }

        v = res[1];
        if (v>0) t = ((b-a)/v+1)*0.5;
        if (v<=0 || t<0 || t>1) {
            res[1] = std::max(a,b);
        }else{
            res[1]=lerp(t, a+v*t, b);
        }
    }
    if (order>0) res*=pow(.25,order);
    return res;
}


Generated by  Doxygen 1.6.0   Back to index