# HG changeset patch # User alpar # Date 1105914686 0 # Node ID 320a0f083ca13166bfa7f70240ebf7adee8dce37 # Parent 8043b93e5973f884b7429ddb27f71a0ef274337b Functions added to compute the gradient of Bezier curve. diff -r 8043b93e5973 -r 320a0f083ca1 src/lemon/bezier.h --- a/src/lemon/bezier.h Sun Jan 16 22:29:28 2005 +0000 +++ b/src/lemon/bezier.h Sun Jan 16 22:31:26 2005 +0000 @@ -21,7 +21,7 @@ ///\file ///\brief Classes to compute with Bezier curves. /// -///Up to now this file is internally used by \ref graph_to_eps.h +///Up to now this file is used internally by \ref graph_to_eps.h /// ///\author Alpar Juttner @@ -58,7 +58,11 @@ { return Bezier1(conv(p1,p2,t),p2); } - Bezier1 operator()(double a,double b) { return before(b).after(a/b); } + Bezier1 revert() { return Bezier1(p2,p1);} + Bezier1 operator()(double a,double b) { return before(b).after(a/b); } + xy grad() { return p2-p1; } + xy grad(double t) { return grad(); } + }; class Bezier2 : public BezierBase @@ -87,8 +91,10 @@ xy r(conv(p2,p3,t)); return Bezier2(conv(q,r,t),r,p3); } + Bezier2 revert() { return Bezier2(p3,p2,p1);} Bezier2 operator()(double a,double b) { return before(b).after(a/b); } - + Bezier1 grad() { return Bezier1(2.0*(p2-p1),2.0*(p3-p2)); } + xy grad(double t) { return grad()(t); } }; class Bezier3 : public BezierBase @@ -130,8 +136,10 @@ xy c(conv(a,b,t)); return Bezier3(c,b,r,p4); } + Bezier3 revert() { return Bezier3(p4,p3,p2,p1);} Bezier3 operator()(double a,double b) { return before(b).after(a/b); } - + Bezier2 grad() { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); } + xy grad(double t) { return grad()(t); } }; } //END OF NAMESPACE LEMON