Geom::Bezier Class Reference
#include <bezier.h>
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) | |
| Bezier & | operator= (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 |
| Coord & | operator[] (unsigned ix) |
| Coord const & | operator[] (unsigned ix) const |
| void | setPoint (unsigned ix, double val) |
| std::vector< Coord > | valueAndDerivatives (Coord t, unsigned n_derivs) const |
| The size of the returned vector equals n_derivs+1. | |
| std::pair< Bezier, Bezier > | subdivide (Coord t) const |
| std::vector< double > | roots () const |
| std::vector< double > | roots (Interval const ivl) const |
Protected Member Functions | |
| Bezier (Coord const c[], unsigned ord) | |
Private Attributes | |
| std::valarray< Coord > | c_ |
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
| typedef Coord Geom::Bezier::output_type |
Constructor & Destructor Documentation
| Geom::Bezier::Bezier | ( | Coord const | c[], | |
| unsigned | ord | |||
| ) | [inline, protected] |
| Geom::Bezier::Bezier | ( | const Bezier & | b | ) | [inline] |
| Geom::Bezier::Bezier | ( | Order | ord | ) | [inline] |
| Geom::Bezier::Bezier | ( | Coord | c0 | ) | [inline, explicit] |
Member Function Documentation
| Coord Geom::Bezier::at0 | ( | ) | const [inline] |
| Coord Geom::Bezier::at1 | ( | ) | const [inline] |
| void Geom::Bezier::clear | ( | ) | [inline] |
| unsigned Geom::Bezier::degree | ( | ) | const [inline] |
| bool Geom::Bezier::isConstant | ( | ) | const [inline] |
| bool Geom::Bezier::isFinite | ( | ) | const [inline] |
| bool Geom::Bezier::isZero | ( | ) | const [inline] |
| Coord const& Geom::Bezier::operator[] | ( | unsigned | ix | ) | const [inline] |
| Coord& Geom::Bezier::operator[] | ( | unsigned | ix | ) | [inline] |
| unsigned int Geom::Bezier::order | ( | ) | const [inline] |
Definition at line 128 of file bezier.h.
References c_.
Referenced by at1(), Bezier(), Geom::bezier_to_sbasis(), degree(), Geom::derivative(), Geom::integral(), isConstant(), isFinite(), isZero(), Geom::operator*(), Geom::operator+(), Geom::operator-(), Geom::operator/(), Geom::portion(), Geom::reverse(), roots(), subdivide(), valueAndDerivatives(), and valueAt().
00128 { return c_.size()-1;}
| void Geom::Bezier::resize | ( | unsigned int | n, | |
| Coord | v = 0 | |||
| ) | [inline] |
| 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().
00281 { 00282 std::vector<double> solutions; 00283 find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, ivl[0], ivl[1]); 00284 return solutions; 00285 }
| std::vector<double> Geom::Bezier::roots | ( | ) | const [inline] |
Definition at line 276 of file bezier.h.
References c_, Geom::find_bernstein_roots(), and order().
00276 { 00277 std::vector<double> solutions; 00278 find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, 0.0, 1.0); 00279 return solutions; 00280 }
| void Geom::Bezier::setPoint | ( | unsigned | ix, | |
| double | val | |||
| ) | [inline] |
| 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().
00129 { return c_.size();}
Definition at line 270 of file bezier.h.
References org::w3c::dom::svg::a, b, c_, order(), and Geom::subdivideArr().
| SBasis Geom::Bezier::toSBasis | ( | ) | const [inline] |
Definition at line 293 of file bezier.h.
References Geom::bezier_to_sbasis().
Referenced by Geom::bounds_exact().
00293 { 00294 SBasis sb; 00295 bezier_to_sbasis(sb, (*this)); 00296 return sb; 00297 //return bezier_to_sbasis(&c_[0], order()); 00298 }
| 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().
00242 { 00243 /* This is inelegant, as it uses several extra stores. I think there might be a way to 00244 * evaluate roughly in situ. */ 00245 00246 // initialize return vector with zeroes, such that we only need to replace the non-zero derivs 00247 std::vector<Coord> val_n_der(n_derivs + 1, Coord(0.0)); 00248 00249 // initialize temp storage variables 00250 std::valarray<Coord> d_(order()+1); 00251 for (unsigned i = 0; i < size(); i++) { 00252 d_[i] = c_[i]; 00253 } 00254 00255 unsigned nn = n_derivs + 1; 00256 if(n_derivs > order()) { 00257 nn = order()+1; // only calculate the non zero derivs 00258 } 00259 for (unsigned di = 0; di < nn; di++) { 00260 //val_n_der[di] = (subdivideArr(t, &d_[0], NULL, NULL, order() - di)); 00261 val_n_der[di] = bernsteinValueAt(t, &d_[0], order() - di); 00262 for (unsigned i = 0; i < order() - di; i++) { 00263 d_[i] = (order()-di)*(d_[i+1] - d_[i]); 00264 } 00265 } 00266 00267 return val_n_der; 00268 }
Definition at line 207 of file bezier.h.
References c_, Barcode::Code39Ext::i, n, and order().
Referenced by operator()().
00207 { 00208 int n = order(); 00209 double u, bc, tn, tmp; 00210 int i; 00211 u = 1.0 - t; 00212 bc = 1; 00213 tn = 1; 00214 tmp = c_[0]*u; 00215 for(i=1; i<n; i++){ 00216 tn = tn*t; 00217 bc = bc*(n-i+1)/i; 00218 tmp = (tmp + tn*bc*c_[i])*u; 00219 } 00220 return (tmp + tn*t*c_[n]); 00221 //return subdivideArr(t, &c_[0], NULL, NULL, order()); 00222 }
Friends And Related Function Documentation
| OptInterval bounds_fast | ( | Bezier const & | b | ) | [friend] |
Definition at line 336 of file bezier.h.
00336 { 00337 //TODO: implement better? 00338 std::valarray<Coord> res(a.order() + 1); 00339 if(from == 0) { 00340 if(to == 1) { return Bezier(a); } 00341 subdivideArr(to, &const_cast<Bezier&>(a).c_[0], &res[0], NULL, a.order()); 00342 return Bezier(&res[0], a.order()); 00343 } 00344 subdivideArr(from, &const_cast<Bezier&>(a).c_[0], NULL, &res[0], a.order()); 00345 if(to == 1) return Bezier(&res[0], a.order()); 00346 std::valarray<Coord> res2(a.order()+1); 00347 subdivideArr((to - from)/(1 - from), &res[0], &res2[0], NULL, a.order()); 00348 return Bezier(&res2[0], a.order()); 00349 }
Member Data Documentation
std::valarray<Coord> Geom::Bezier::c_ [private] |
Definition at line 114 of file bezier.h.
Referenced by at0(), at1(), Bezier(), clear(), Geom::derivative(), isConstant(), isFinite(), isZero(), operator=(), operator[](), order(), resize(), roots(), setPoint(), size(), subdivide(), valueAndDerivatives(), and valueAt().
The documentation for this class was generated from the following file:
