FreeFOAM The Cross-Platform CFD Toolkit
CatmullRomSpline.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::CatmullRomSpline
26 
27 Description
28  An implementation of Catmull-Rom splines
29  (sometimes known as Overhauser splines).
30 
31  In this implementation, the end tangents are created automatically
32  by reflection.
33 
34  In matrix form, the @e local interpolation on the interval t=[0..1] is
35  described as follows:
36  @verbatim
37  P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
38  [ 2 -5 4 -1 ] [ P0 ]
39  [ -1 0 1 0 ] [ P1 ]
40  [ 0 2 0 0 ] [ P2 ]
41  @endverbatim
42 
43  Where P-1 and P2 represent the neighbouring points or the extrapolated
44  end points. Simple reflection is used to automatically create the end
45  points.
46 
47  The spline is discretized based on the chord length of the individual
48  segments. In rare cases (sections with very high curvatures), the
49  resulting distribution may be sub-optimal.
50 
51 SeeAlso
52  http://www.algorithmist.net/catmullrom.html provides a nice
53  introduction
54 
55 ToDo
56  A future implementation could also handle closed splines.
57 
58 SourceFiles
59  CatmullRomSpline.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef CatmullRomSpline_H
64 #define CatmullRomSpline_H
65 
66 #include "polyLine.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class CatmullRomSpline Declaration
75 \*---------------------------------------------------------------------------*/
76 
78 :
79  public polyLine
80 {
81  // Private Member Functions
82 
83  //- Disallow default bitwise copy construct
85 
86  //- Disallow default bitwise assignment
87  void operator=(const CatmullRomSpline&);
88 
89 
90 public:
91 
92  // Constructors
93 
94  //- Construct from components
96  (
97  const pointField& knots,
98  const bool notImplementedClosed = false
99  );
100 
101 
102  // Member Functions
103 
104  //- Return the point position corresponding to the curve parameter
105  // 0 <= lambda <= 1
106  point position(const scalar lambda) const;
107 
108  //- Return the point position corresponding to the local parameter
109  // 0 <= lambda <= 1 on the given segment
110  point position(const label segment, const scalar lambda) const;
111 
112  //- Return the length of the curve - not implemented
113  scalar length() const;
114 };
115 
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 } // End namespace Foam
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 #endif
124 
125 // ************************************************************************* //