Changeset 209:765619b7cbb2 in lemon for lemon/bits/bezier.h
- Timestamp:
- 07/13/08 20:51:02 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/bezier.h
r184 r209 1 /* -*- C++-*-1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 45 45 Bezier1() {} 46 46 Bezier1(Point _p1, Point _p2) :p1(_p1), p2(_p2) {} 47 47 48 48 Point operator()(double t) const 49 49 { … … 55 55 return Bezier1(p1,conv(p1,p2,t)); 56 56 } 57 57 58 58 Bezier1 after(double t) const 59 59 { … … 88 88 return Bezier2(p1,q,conv(q,r,t)); 89 89 } 90 90 91 91 Bezier2 after(double t) const 92 92 { … … 111 111 Bezier3(Point _p1, Point _p2, Point _p3, Point _p4) 112 112 : p1(_p1), p2(_p2), p3(_p3), p4(_p4) {} 113 Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)), 114 113 Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)), 114 p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {} 115 115 Bezier3(const Bezier2 &b) : p1(b.p1), p2(conv(b.p1,b.p2,2.0/3.0)), 116 117 118 Point operator()(double t) const 116 p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {} 117 118 Point operator()(double t) const 119 119 { 120 120 // return Bezier2(conv(p1,p2,t),conv(p2,p3,t),conv(p3,p4,t))(t); 121 121 return ((1-t)*(1-t)*(1-t))*p1+(3*t*(1-t)*(1-t))*p2+ 122 122 (3*t*t*(1-t))*p3+(t*t*t)*p4; 123 123 } 124 124 Bezier3 before(double t) const … … 132 132 return Bezier3(p1,p,a,c); 133 133 } 134 134 135 135 Bezier3 after(double t) const 136 136 { … … 147 147 Bezier2 grad() const { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); } 148 148 Bezier2 norm() const { return Bezier2(3.0*rot90(p2-p1), 149 150 149 3.0*rot90(p3-p2), 150 3.0*rot90(p4-p3)); } 151 151 Point grad(double t) const { return grad()(t); } 152 152 Point norm(double t) const { return rot90(grad(t)); } 153 153 154 154 template<class R,class F,class S,class D> 155 R recSplit(F &_f,const S &_s,D _d) const 155 R recSplit(F &_f,const S &_s,D _d) const 156 156 { 157 157 const Point a=(p1+p2)/2; … … 165 165 return _s(f1,f2); 166 166 } 167 167 168 168 }; 169 169
Note: See TracChangeset
for help on using the changeset viewer.