1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::CatmullRomSpline
29 An implementation of Catmull-Rom splines
30 (sometimes known as Overhauser splines).
32 In this implementation, the end tangents are created automatically
35 In matrix form, the @e local interpolation on the interval t=[0..1] is
38 P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
44 Where P-1 and P2 represent the neighbouring points or the extrapolated
45 end points. Simple reflection is used to automatically create the end
48 The spline is discretized based on the chord length of the individual
49 segments. In rare cases (sections with very high curvatures), the
50 resulting distribution may be sub-optimal.
53 http://www.algorithmist.net/catmullrom.html provides a nice
57 A future implementation could also handle closed splines.
62 \*---------------------------------------------------------------------------*/
64 #ifndef CatmullRomSpline_H
65 #define CatmullRomSpline_H
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 /*---------------------------------------------------------------------------*\
75 Class CatmullRomSpline Declaration
76 \*---------------------------------------------------------------------------*/
78 class CatmullRomSpline
82 // Private Member Functions
84 //- Disallow default bitwise copy construct
85 CatmullRomSpline(const CatmullRomSpline&);
87 //- Disallow default bitwise assignment
88 void operator=(const CatmullRomSpline&);
95 //- Construct from components
98 const pointField& knots,
99 const bool notImplementedClosed = false
105 //- Return the point position corresponding to the curve parameter
107 point position(const scalar lambda) const;
109 //- Return the point position corresponding to the local parameter
110 // 0 <= lambda <= 1 on the given segment
111 point position(const label segment, const scalar lambda) const;
113 //- Return the length of the curve - not implemented
114 scalar length() const;
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 } // End namespace Foam
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 // ************************************************************************* //