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 |
| std::pair< Bezier, Bezier > | subdivide (Coord t) const |
| std::vector< double > | roots () 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 101 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] |
Definition at line 166 of file bezier.h.
References c_.
Referenced by Geom::sbasis_to_bezier().
00167 { 00168 c_.resize(0); 00169 }
| 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 117 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().
00117 { return c_.size()-1;}
| void Geom::Bezier::resize | ( | unsigned int | n, | |
| Coord | v = 0 | |||
| ) | [inline] |
| std::vector<double> Geom::Bezier::roots | ( | ) | const [inline] |
Definition at line 255 of file bezier.h.
References c_, Geom::find_bernstein_roots(), and order().
Referenced by Geom::roots().
00255 { 00256 std::vector<double> solutions; 00257 find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, 0.0, 1.0); 00258 return solutions; 00259 }
| void Geom::Bezier::setPoint | ( | unsigned | ix, | |
| double | val | |||
| ) | [inline] |
| unsigned int Geom::Bezier::size | ( | ) | const [inline] |
Definition at line 118 of file bezier.h.
References c_.
Referenced by Geom::bounds_fast(), Geom::NL::LFMBezier::instance(), Geom::operator<<(), Geom::sbasis_to_bezier(), and valueAndDerivatives().
00118 { return c_.size();}
Definition at line 249 of file bezier.h.
References org::w3c::dom::svg::a, b, c_, order(), and Geom::subdivideArr().
00249 { 00250 Bezier a(Bezier::Order(*this)), b(Bezier::Order(*this)); 00251 subdivideArr(t, &const_cast<std::valarray<Coord>&>(c_)[0], &a.c_[0], &b.c_[0], order()); 00252 return std::pair<Bezier, Bezier >(a, b); 00253 }
| SBasis Geom::Bezier::toSBasis | ( | ) | const [inline] |
Definition at line 267 of file bezier.h.
References Geom::bezier_to_sbasis().
Referenced by Geom::bounds_exact().
00267 { 00268 SBasis sb; 00269 bezier_to_sbasis(sb, (*this)); 00270 return sb; 00271 //return bezier_to_sbasis(&c_[0], order()); 00272 }
| std::vector<Coord> Geom::Bezier::valueAndDerivatives | ( | Coord | t, | |
| unsigned | n_derivs | |||
| ) | const [inline] |
Definition at line 231 of file bezier.h.
References c_, Barcode::Code39Ext::i, NULL, order(), size(), and Geom::subdivideArr().
00231 { 00232 std::vector<Coord> val_n_der; 00233 std::valarray<Coord> d_(order()+1); 00234 unsigned nn = n_derivs + 1; // the size of the result vector equals n_derivs+1 ... 00235 if(nn > order()) 00236 nn = order()+1; // .. but with a maximum of order() + 1! 00237 for(unsigned i = 0; i < size(); i++) 00238 d_[i] = c_[i]; 00239 for(unsigned di = 0; di < nn; di++) { 00240 val_n_der.push_back(subdivideArr(t, &d_[0], NULL, NULL, order() - di)); 00241 for(unsigned i = 0; i < order() - di; i++) { 00242 d_[i] = (order()-di)*(d_[i+1] - d_[i]); 00243 } 00244 } 00245 val_n_der.resize(n_derivs); 00246 return val_n_der; 00247 }
Definition at line 196 of file bezier.h.
References c_, Barcode::Code39Ext::i, n, and order().
Referenced by operator()().
00196 { 00197 int n = order(); 00198 double u, bc, tn, tmp; 00199 int i; 00200 u = 1.0 - t; 00201 bc = 1; 00202 tn = 1; 00203 tmp = c_[0]*u; 00204 for(i=1; i<n; i++){ 00205 tn = tn*t; 00206 bc = bc*(n-i+1)/i; 00207 tmp = (tmp + tn*bc*c_[i])*u; 00208 } 00209 return (tmp + tn*t*c_[n]); 00210 //return subdivideArr(t, &c_[0], NULL, NULL, order()); 00211 }
Friends And Related Function Documentation
| OptInterval bounds_fast | ( | Bezier const & | b | ) | [friend] |
Definition at line 336 of file bezier.h.
00336 { 00337 //if(a.order() == 1) return Bezier(0.0); 00338 if(a.order() == 1) return Bezier(a.c_[1]-a.c_[0]); 00339 Bezier der(Bezier::Order(a.order()-1)); 00340 00341 for(unsigned i = 0; i < a.order(); i++) { 00342 der.c_[i] = a.order()*(a.c_[i+1] - a.c_[i]); 00343 } 00344 return der; 00345 }
Definition at line 310 of file bezier.h.
00310 { 00311 //TODO: implement better? 00312 std::valarray<Coord> res(a.order() + 1); 00313 if(from == 0) { 00314 if(to == 1) { return Bezier(a); } 00315 subdivideArr(to, &const_cast<Bezier&>(a).c_[0], &res[0], NULL, a.order()); 00316 return Bezier(&res[0], a.order()); 00317 } 00318 subdivideArr(from, &const_cast<Bezier&>(a).c_[0], NULL, &res[0], a.order()); 00319 if(to == 1) return Bezier(&res[0], a.order()); 00320 std::valarray<Coord> res2(a.order()+1); 00321 subdivideArr((to - from)/(1 - from), &res[0], &res2[0], NULL, a.order()); 00322 return Bezier(&res2[0], a.order()); 00323 }
Member Data Documentation
std::valarray<Coord> Geom::Bezier::c_ [private] |
Definition at line 103 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:
