#include <bezier.h>

List of all members.

Classes

struct  Order

Public Types

typedef Coord output_type

Public Member Functions

unsigned int order () const
unsigned int size () const
 Bezier ()
 Bezier (const Bezier &b)
Bezieroperator= (Bezier const &other)
 Bezier (Order ord)
 Bezier (Coord c0)
 Bezier (Coord c0, Coord c1)
 Bezier (Coord c0, Coord c1, Coord c2)
 Bezier (Coord c0, Coord c1, Coord c2, Coord c3)
void resize (unsigned int n, Coord v=0)
void clear ()
unsigned degree () const
bool isZero () const
bool isConstant () const
bool isFinite () const
Coord at0 () const
Coord at1 () const
Coord valueAt (double t) const
Coord operator() (double t) const
SBasis toSBasis () const
Coordoperator[] (unsigned ix)
Coord const & operator[] (unsigned ix) const
void setPoint (unsigned ix, double val)
std::vector< CoordvalueAndDerivatives (Coord t, unsigned n_derivs) const
 The size of the returned vector equals n_derivs+1.
std::pair< Bezier, Beziersubdivide (Coord t) const
std::vector< doubleroots () const
std::vector< doubleroots (Interval const ivl) const

Protected Member Functions

 Bezier (Coord const c[], unsigned ord)

Private Attributes

std::valarray< Coordc_

Friends

Bezier portion (const Bezier &a, Coord from, Coord to)
OptInterval bounds_fast (Bezier const &b)
Bezier derivative (const Bezier &a)

Detailed Description

Definition at line 112 of file bezier.h.


Member Typedef Documentation

Definition at line 185 of file bezier.h.


Constructor & Destructor Documentation

Geom::Bezier::Bezier ( Coord const   c[],
unsigned  ord 
) [inline, protected]

Definition at line 123 of file bezier.h.

                                          : c_(c, ord+1){
        //std::copy(c, c+order()+1, &c_[0]);
    }

Geom::Bezier::Bezier (  )  [inline]

Definition at line 131 of file bezier.h.

{}

Geom::Bezier::Bezier ( const Bezier b  )  [inline]

Definition at line 132 of file bezier.h.

:c_(b.c_) {}

Geom::Bezier::Bezier ( Order  ord  )  [inline]

Definition at line 149 of file bezier.h.

References order(), and Geom::Bezier::Order::order.

                      : c_(0., ord.order+1) {
        assert(ord.order ==  order());
    }

Geom::Bezier::Bezier ( Coord  c0  )  [inline, explicit]

Definition at line 153 of file bezier.h.

References c_.

                              : c_(0., 1) {
        c_[0] = c0;
    }

Geom::Bezier::Bezier ( Coord  c0,
Coord  c1 
) [inline]

Definition at line 158 of file bezier.h.

References c_.

                               : c_(0., 2) {
        c_[0] = c0; c_[1] = c1;
    }

Geom::Bezier::Bezier ( Coord  c0,
Coord  c1,
Coord  c2 
) [inline]

Definition at line 163 of file bezier.h.

References c_.

                                         : c_(0., 3) {
        c_[0] = c0; c_[1] = c1; c_[2] = c2;
    }

Geom::Bezier::Bezier ( Coord  c0,
Coord  c1,
Coord  c2,
Coord  c3 
) [inline]

Definition at line 168 of file bezier.h.

References c_.

                                                   : c_(0., 4) {
        c_[0] = c0; c_[1] = c1; c_[2] = c2; c_[3] = c3;
    }


Member Function Documentation

Coord Geom::Bezier::at0 (  )  const [inline]

Definition at line 204 of file bezier.h.

References c_.

{ return c_[0]; }

Coord Geom::Bezier::at1 (  )  const [inline]

Definition at line 205 of file bezier.h.

References c_, and order().

{ return c_[order()]; }

void Geom::Bezier::clear (  )  [inline]

Definition at line 177 of file bezier.h.

References c_.

    {
        c_.resize(0);
    }

unsigned Geom::Bezier::degree (  )  const [inline]

Definition at line 182 of file bezier.h.

References order().

{ return order(); }

bool Geom::Bezier::isConstant (  )  const [inline]

Definition at line 192 of file bezier.h.

References c_, Barcode::Code39Ext::i, and order().

                                   {
        for(unsigned i = 1; i <= order(); i++) {
            if(c_[i] != c_[0]) return false;
        }
        return true;
    }

bool Geom::Bezier::isFinite (  )  const [inline]

Definition at line 198 of file bezier.h.

References c_, Barcode::Code39Ext::i, IS_FINITE, and order().

                                 {
        for(unsigned i = 0; i <= order(); i++) {
            if(!IS_FINITE(c_[i])) return false;
        }
        return true;
    }

bool Geom::Bezier::isZero (  )  const [inline]

Definition at line 186 of file bezier.h.

References c_, Barcode::Code39Ext::i, and order().

                               {
        for(unsigned i = 0; i <= order(); i++) {
            if(c_[i] != 0) return false;
        }
        return true;
    }

Coord Geom::Bezier::operator() ( double  t  )  const [inline]

Definition at line 223 of file bezier.h.

References valueAt().

{ return valueAt(t); }

Bezier& Geom::Bezier::operator= ( Bezier const &  other  )  [inline]

Definition at line 133 of file bezier.h.

References c_.

                                           {
        if ( c_.size() != other.c_.size() ) {
            c_.resize(other.c_.size());
        }
        c_ = other.c_;
        return *this;
    }

Coord const& Geom::Bezier::operator[] ( unsigned  ix  )  const [inline]

Definition at line 235 of file bezier.h.

References c_.

{ return const_cast<std::valarray<Coord>&>(c_)[ix]; }

Coord& Geom::Bezier::operator[] ( unsigned  ix  )  [inline]

Definition at line 234 of file bezier.h.

References c_.

{ return c_[ix]; }

void Geom::Bezier::resize ( unsigned int  n,
Coord  v = 0 
) [inline]

Definition at line 172 of file bezier.h.

References c_.

    {
        c_.resize (n, v);
    }

std::vector<double> Geom::Bezier::roots (  )  const [inline]

Definition at line 276 of file bezier.h.

References c_, Geom::find_bernstein_roots(), and order().

                                    {
        std::vector<double> solutions;
        find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, 0.0, 1.0);
        return solutions;
    }

std::vector<double> Geom::Bezier::roots ( Interval const   ivl  )  const [inline]

Definition at line 281 of file bezier.h.

References c_, Geom::find_bernstein_roots(), and order().

                                                      {
        std::vector<double> solutions;
        find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, ivl[0], ivl[1]);
        return solutions;
    }

void Geom::Bezier::setPoint ( unsigned  ix,
double  val 
) [inline]

Definition at line 237 of file bezier.h.

References c_.

{ c_[ix] = val; }

unsigned int Geom::Bezier::size (  )  const [inline]

Definition at line 129 of file bezier.h.

References c_.

Referenced by Geom::bounds_fast(), Geom::NL::LFMBezier::instance(), Geom::operator<<(), and valueAndDerivatives().

{ return c_.size();}

std::pair<Bezier, Bezier > Geom::Bezier::subdivide ( Coord  t  )  const [inline]

Definition at line 270 of file bezier.h.

References org::w3c::dom::svg::a, b, c_, order(), and Geom::subdivideArr().

                                                      {
        Bezier a(Bezier::Order(*this)), b(Bezier::Order(*this));
        subdivideArr(t, &const_cast<std::valarray<Coord>&>(c_)[0], &a.c_[0], &b.c_[0], order());
        return std::pair<Bezier, Bezier >(a, b);
    }

SBasis Geom::Bezier::toSBasis (  )  const [inline]

Definition at line 293 of file bezier.h.

References Geom::bezier_to_sbasis().

Referenced by Geom::bounds_exact().

                              {
    SBasis sb;
    bezier_to_sbasis(sb, (*this));
    return sb;
    //return bezier_to_sbasis(&c_[0], order());
}

std::vector<Coord> Geom::Bezier::valueAndDerivatives ( Coord  t,
unsigned  n_derivs 
) const [inline]

The size of the returned vector equals n_derivs+1.

Definition at line 242 of file bezier.h.

References Geom::bernsteinValueAt(), c_, Barcode::Code39Ext::i, order(), and size().

                                                                           {
        /* This is inelegant, as it uses several extra stores.  I think there might be a way to
         * evaluate roughly in situ. */

         // initialize return vector with zeroes, such that we only need to replace the non-zero derivs
        std::vector<Coord> val_n_der(n_derivs + 1, Coord(0.0));

        // initialize temp storage variables
        std::valarray<Coord> d_(order()+1);
        for (unsigned i = 0; i < size(); i++) {
            d_[i] = c_[i];
        }

        unsigned nn = n_derivs + 1;
        if(n_derivs > order()) {
            nn = order()+1; // only calculate the non zero derivs
        }
        for (unsigned di = 0; di < nn; di++) {
            //val_n_der[di] = (subdivideArr(t, &d_[0], NULL, NULL, order() - di));
            val_n_der[di] = bernsteinValueAt(t, &d_[0], order() - di);
            for (unsigned i = 0; i < order() - di; i++) {
                d_[i] = (order()-di)*(d_[i+1] - d_[i]);
            }
        }

        return val_n_der;
    }

Coord Geom::Bezier::valueAt ( double  t  )  const [inline]

Definition at line 207 of file bezier.h.

References c_, Barcode::Code39Ext::i, n, and order().

Referenced by operator()().

                                         {
        int n = order();
        double u, bc, tn, tmp;
        int i;
        u = 1.0 - t;
        bc = 1;
        tn = 1;
        tmp = c_[0]*u;
        for(i=1; i<n; i++){
            tn = tn*t;
            bc = bc*(n-i+1)/i;
            tmp = (tmp + tn*bc*c_[i])*u;
        }
        return (tmp + tn*t*c_[n]);
        //return subdivideArr(t, &c_[0], NULL, NULL, order());
    }


Friends And Related Function Documentation

OptInterval bounds_fast ( Bezier const &  b  )  [friend]

Definition at line 383 of file bezier.h.

                                                 {
    return Interval::fromArray(&const_cast<Bezier&>(b).c_[0], b.size());
}

Bezier derivative ( const Bezier a  )  [friend]

Definition at line 362 of file bezier.h.

                                           {
    //if(a.order() == 1) return Bezier(0.0);
    if(a.order() == 1) return Bezier(a.c_[1]-a.c_[0]);
    Bezier der(Bezier::Order(a.order()-1));

    for(unsigned i = 0; i < a.order(); i++) {
        der.c_[i] = a.order()*(a.c_[i+1] - a.c_[i]);
    }
    return der;
}

Bezier portion ( const Bezier a,
Coord  from,
Coord  to 
) [friend]

Member Data Documentation


The documentation for this class was generated from the following file: