1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::CatmullRomSpline
28 An implementation of Catmull-Rom splines
29 (sometimes known as Overhauser splines).
31 In this implementation, the end tangents are created automatically
34 In matrix form, the \e local interpolation on the interval t=[0..1] is
37 P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
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
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.
51 A future implementation could also handle closed splines.
54 http://www.algorithmist.net/catmullrom.html provides a nice
60 \*---------------------------------------------------------------------------*/
62 #ifndef CatmullRomSpline_H
63 #define CatmullRomSpline_H
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 /*---------------------------------------------------------------------------*\
73 Class CatmullRomSpline Declaration
74 \*---------------------------------------------------------------------------*/
76 class CatmullRomSpline
80 // Private Member Functions
82 //- Disallow default bitwise copy construct
83 CatmullRomSpline(const CatmullRomSpline&);
85 //- Disallow default bitwise assignment
86 void operator=(const CatmullRomSpline&);
93 //- Construct from components
96 const pointField& knots,
97 const bool notImplementedClosed = false
103 //- Return the point position corresponding to the curve parameter
105 point position(const scalar lambda) const;
107 //- Return the point position corresponding to the local parameter
108 // 0 <= lambda <= 1 on the given segment
109 point position(const label segment, const scalar lambda) const;
111 //- Return the length of the curve
112 scalar length() const;
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 } // End namespace Foam
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 // ************************************************************************* //