TexGen
InterpolationCubic.h
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#pragma once
21#include "Interpolation.h"
22
23namespace TexGen
24{
25 using namespace std;
26
29 {
30 public:
31 CInterpolationCubic(bool bPeriodic = true, bool bForceInPlaneTangent = false, bool bForceMasterNodeTangent = false);
32 CInterpolationCubic(TiXmlElement &Element);
34
35 CInterpolation* Copy() const { return new CInterpolationCubic(*this); }
36 string GetType() const { return "CInterpolationCubic"; }
37// void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const;
38
40 void Initialise(const vector<CNode> &MasterNodes) const;
41
43 CSlaveNode GetNode(const vector<CNode> &MasterNodes, int iIndex, double t) const;
44
45 protected:
48 {
49 CUBICEQUATION(double a, double b, double c, double d)
50 : m_a(a)
51 , m_b(b)
52 , m_c(c)
53 , m_d(d)
54 {}
55
56 double Evaluate(double x) const
57 {
58 return (((m_d*x)+m_c)*x+m_b)*x+m_a;
59 }
60
61 double EvaluateDerivative(double x) const
62 {
63 return ((3*m_d*x)+2*m_c)*x+m_b;
64 }
65
66 protected:
67 double m_a, m_b, m_c, m_d;
68 };
69
70 static void GetPeriodicCubicSplines(const vector<double> &Knots, vector<CUBICEQUATION> &Cubics);
71 static void GetNaturalCubicSplines(const vector<double> &Knots, vector<CUBICEQUATION> &Cubics);
72
73 mutable vector<CUBICEQUATION> m_XCubics;
74 mutable vector<CUBICEQUATION> m_YCubics;
75 mutable vector<CUBICEQUATION> m_ZCubics;
76 };
77
78}; // namespace TexGen
#define CLASS_DECLSPEC
Definition: Misc.h:35
Cubic spline interpolation for yarn paths.
string GetType() const
Derived class should return the class name.
vector< CUBICEQUATION > m_XCubics
vector< CUBICEQUATION > m_YCubics
vector< CUBICEQUATION > m_ZCubics
CInterpolation * Copy() const
This is a function to allow copying of derived classes correctly.
Abstract base class for describing the yarn path interpolations.
Definition: Interpolation.h:33
A derivation of the CNode class which contains data specific to slave nodes such as sections.
Definition: SlaveNode.h:30
Namespace containing a series of customised math operations not found in the standard c++ library.
Struct to represent a cubic equation.
CUBICEQUATION(double a, double b, double c, double d)