Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BSplineCurve.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009, 2005 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #ifndef _BIAS_BSPLINECURVE_
27 #define _BIAS_BSPLINECURVE_
28 #include <Base/Common/BIASpragmaStart.hh>
29 
30 #include <cmath>
31 #include <vector>
32 #include "Base/Debug/Debug.hh"
33 #include "Base/Image/Image.hh"
34 #include "Base/ImageUtils/ImageDraw.hh"
35 #include "Base/Math/Matrix.hh"
36 #include "Base/Math/Vector.hh"
37 #include "Base/Math/Vector2.hh"
38 
39 
40 
41 namespace BIAS {
42  /** @class BSplineCurve
43  @ingroup g_mathalgo
44  @brief this class is intended for drawing of quadratic and cubic
45  regular B-Splines from given control points.
46 
47  this class is intended for drawing of quadratic and cubic regular
48  B-Splines from given control points. The Spline doesnt interpolate through
49  the control points!!!
50 
51  The Implementation of BSplineCurve is faster then BSpline. If you only want
52  to draw a BSpline you should use this implementation.
53 
54  usage:
55  -# void SetControlPoints(&cPnts)
56  for quadratic closed Bspline set cPnt[n],cPnt[0],...,cPnt[n],cPnt[0]
57  for cubic closed Bspline set cPnt[n],cPnt[0],...,cPnt[n],cPnt[0],cPnt[1]
58  -# void InitXXXUniformBSpline() - computes coefficientvectors for all knots
59  -# void XXXUniformSpline(Vector2<double> &res, double t ) - computes
60  point on the curve (0<=t<=1)
61  t=0 returns the first computed knot of the first segment
62  t=1 returns the last computed knot of the last segment
63 
64  see also 'Computer Graphics & Geometric Modeling' from David Salomon
65  chapter 4.16
66 
67  @author Marcel Lilienthal, Mai 2005
68  */
69 
70  class BIASMathAlgo_EXPORT BSplineCurve : public Debug
71  {
72 
73  public:
74  BSplineCurve();
76 
77  /**
78  set the control points, which control the interpolating curve
79  */
80  inline void SetControlPoints(std::vector<BIAS::Vector2<double> > &cPnt){
81  cPnts_=cPnt;
82 #ifdef BIAS_DEBUG
83  initializedCubic_=false;
84  initializedQuadratic_=false;
85 #endif
86  };
87 
88  /**
89  @brief computes coefficients for all segments of a quadratic uniform
90  B-spline
91 
92  this function computes the coefficients for all sements of a quadratic
93  uniform B-spline and saves these coefficients in protected vectors
94  xCoeff_, yCoeff_
95  method is discribed in David Salomons "Computer Graphic & Geometric
96  Modelling" chapter 4.16.2
97 
98  @author Marcel Lilienthal, Mai 2005
99  */
100  void InitQuadraticUniformBSpline();
101 
102  /**
103  @brief computes coefficients for all segments of a cubic uniform B-spline
104 
105  this function computes the coefficients for all sements of a cubic
106  uniform B-spline and saves these coefficients in protected vectors
107  xCoeff_, yCoeff_.
108  method is discribed in David Salomons "Computer Graphic & Geometric
109  Modelling" chapter 4.16.4
110 
111  @author Marcel Lilienthal, Mai 2005
112  */
113  void InitCubicUniformBSpline();
114 
115  /**
116  @brief computes the point on a quadratic uniform B-spline curve at time t
117 
118  this function computes the point on a quadratic uniform B-spline curve at
119  time t. method is discribed in David Salomons "Computer Graphic &
120  Geometric Modelling" chapter 4.16.2.
121  the value of t must be between 0 and 1.
122  t is used to compute the corresponding segment and the t_ for the result
123  segment.
124 
125  @param res - reference to the result (return value)
126  @param t - time value of which point is to be calculated
127  @author Marcel Lilienthal, Mai 2005
128  */
129  void QuadraticUniformBSpline(Vector2<double> &res, double t);
130 
131  /**
132  @brief computes the point on a cubic uniform B-spline curve at time t
133 
134  this function computes the point on a cubic uniform B-spline curve at time
135  t. method is discribed in David Salomons "Computer Graphic & Geometric
136  Modelling" chapter 4.16.2.
137  the value of t must be between 0 and 1.
138  t is used to compute the corresponding segment and the t_ for the result
139  segment.
140 
141  @param res - reference to the result (return value)
142  @param t - time value of which point is to be calculated
143  @author Marcel Lilienthal, Mai 2005
144  */
145  void CubicUniformBSpline(Vector2<double> &res, double t);
146 
147 
148  protected:
149 
150 #ifdef BIAS_DEBUG
153 #endif
154  std::vector<BIAS::Vector2<double> > cPnts_;//control Points
155  std::vector<BIAS::Vector<double> > xCoeff_;//coefficient x Vec
156  std::vector<BIAS::Vector<double> > yCoeff_;//coefficient y Vec
157 
158  };//class
159 
160 }//namespace
161 
162 
163 #include <Base/Common/BIASpragmaEnd.hh>
164 #endif
std::vector< BIAS::Vector2< double > > cPnts_
this class is intended for drawing of quadratic and cubic regular B-Splines from given control points...
Definition: BSplineCurve.hh:70
void SetControlPoints(std::vector< BIAS::Vector2< double > > &cPnt)
set the control points, which control the interpolating curve
Definition: BSplineCurve.hh:80
std::vector< BIAS::Vector< double > > xCoeff_
std::vector< BIAS::Vector< double > > yCoeff_