1.1 --- a/lemon/bezier.h Tue Jul 12 16:16:19 2005 +0000
1.2 +++ b/lemon/bezier.h Tue Jul 12 16:17:16 2005 +0000
1.3 @@ -58,11 +58,13 @@
1.4 {
1.5 return Bezier1(conv(p1,p2,t),p2);
1.6 }
1.7 - Bezier1 revert() { return Bezier1(p2,p1);}
1.8 - Bezier1 operator()(double a,double b) { return before(b).after(a/b); }
1.9 - xy grad() { return p2-p1; }
1.10 - xy grad(double) { return grad(); }
1.11
1.12 + Bezier1 revert() const { return Bezier1(p2,p1);}
1.13 + Bezier1 operator()(double a,double b) const { return before(b).after(a/b); }
1.14 + xy grad() const { return p2-p1; }
1.15 + xy norm() const { return rot90(p2-p1); }
1.16 + xy grad(double) const { return grad(); }
1.17 + xy norm(double t) const { return rot90(grad(t)); }
1.18 };
1.19
1.20 class Bezier2 : public BezierBase
1.21 @@ -91,10 +93,12 @@
1.22 xy r(conv(p2,p3,t));
1.23 return Bezier2(conv(q,r,t),r,p3);
1.24 }
1.25 - Bezier2 revert() { return Bezier2(p3,p2,p1);}
1.26 - Bezier2 operator()(double a,double b) { return before(b).after(a/b); }
1.27 - Bezier1 grad() { return Bezier1(2.0*(p2-p1),2.0*(p3-p2)); }
1.28 - xy grad(double t) { return grad()(t); }
1.29 + Bezier2 revert() const { return Bezier2(p3,p2,p1);}
1.30 + Bezier2 operator()(double a,double b) const { return before(b).after(a/b); }
1.31 + Bezier1 grad() const { return Bezier1(2.0*(p2-p1),2.0*(p3-p2)); }
1.32 + Bezier1 norm() const { return Bezier1(2.0*rot90(p2-p1),2.0*rot90(p3-p2)); }
1.33 + xy grad(double t) const { return grad()(t); }
1.34 + xy norm(double t) const { return rot90(grad(t)); }
1.35 };
1.36
1.37 class Bezier3 : public BezierBase
1.38 @@ -136,10 +140,29 @@
1.39 xy c(conv(a,b,t));
1.40 return Bezier3(c,b,r,p4);
1.41 }
1.42 - Bezier3 revert() { return Bezier3(p4,p3,p2,p1);}
1.43 - Bezier3 operator()(double a,double b) { return before(b).after(a/b); }
1.44 - Bezier2 grad() { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); }
1.45 - xy grad(double t) { return grad()(t); }
1.46 + Bezier3 revert() const { return Bezier3(p4,p3,p2,p1);}
1.47 + Bezier3 operator()(double a,double b) const { return before(b).after(a/b); }
1.48 + Bezier2 grad() const { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); }
1.49 + Bezier2 norm() const { return Bezier2(3.0*rot90(p2-p1),
1.50 + 3.0*rot90(p3-p2),
1.51 + 3.0*rot90(p4-p3)); }
1.52 + xy grad(double t) const { return grad()(t); }
1.53 + xy norm(double t) const { return rot90(grad(t)); }
1.54 +
1.55 + template<class R,class F,class S,class D>
1.56 + R recSplit(F &_f,const S &_s,D _d) const
1.57 + {
1.58 + const xy a=(p1+p2)/2;
1.59 + const xy b=(p2+p3)/2;
1.60 + const xy c=(p3+p4)/2;
1.61 + const xy d=(a+b)/2;
1.62 + const xy e=(b+c)/2;
1.63 + const xy f=(d+e)/2;
1.64 + R f1=_f(Bezier3(p1,a,d,e),_d);
1.65 + R f2=_f(Bezier3(e,d,c,p4),_d);
1.66 + return _s(f1,f2);
1.67 + }
1.68 +
1.69 };
1.70
1.71 } //END OF NAMESPACE LEMON