TexGen
InterpolationLinear.cpp
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#include "PrecompiledHeaders.h"
21#include "InterpolationLinear.h"
22
23using namespace TexGen;
24CInterpolationLinear::CInterpolationLinear(bool bPeriodic, bool bForceInPlaneTangent, bool bForceMasterNodeTangent)
25: CInterpolation(bPeriodic, bForceInPlaneTangent, bForceMasterNodeTangent)
26{
27}
28
30{
31}
32
34: CInterpolation(Element)
35{
36 // TODO: IMPLEMENT ME
37}
38
39/*
40void CInterpolationLinear::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
41{
42}*/
43
44CSlaveNode CInterpolationLinear::GetNode(const vector<CNode> &MasterNodes, int iIndex, double t) const
45{
46 assert(iIndex >= 0 && iIndex < int(MasterNodes.size()-1));
47 // Errors may occur here if the Initialise function was not called before
48 // calling this function. For performance reasons it is necessary to call
49 // initialise once at the start before making calls to this function
50 if ( m_Tangents.empty() )
51 Initialise( MasterNodes );
52 assert(m_Tangents.size() == MasterNodes.size());
53
54 const CNode &Node1 = MasterNodes[iIndex];
55 const CNode &Node2 = MasterNodes[iIndex+1];
56
57 XYZ P1, P2;
58 XYZ T1, T2, U1, U2;
59 XYZ SlaveNodePos, SlaveTangent;
60
61 // This is a rather inefficient way of doing things, these points could be calculated
62 // in the initialise function (optimise if this becomes an issue)
63 P1 = Node1.GetPosition();
64 P2 = Node2.GetPosition();
65 T1 = m_Tangents[iIndex];
66 T2 = m_Tangents[iIndex+1];
67
68 SlaveNodePos = P1 + (P2-P1)*t;
69 SlaveTangent = T1 + (T2-T1)*t;
70
72 SlaveTangent.z = 0;
73
74 Normalise(SlaveTangent);
75
76 CSlaveNode NewNode(SlaveNodePos, SlaveTangent, XYZ());
77
78 InterpolateUp(Node1, Node2, NewNode, t);
79 InterpolateAngle(Node1, Node2, NewNode, t);
80
81 NewNode.SetIndex(iIndex);
82 NewNode.SetT(t);
83
84 return NewNode;
85}
86
87void CInterpolationLinear::Initialise(const vector<CNode> &MasterNodes) const
88{
90}
91
92
93
94
95
96
Abstract base class for describing the yarn path interpolations.
Definition: Interpolation.h:33
static void InterpolateUp(const CNode &Node1, const CNode &Node2, CSlaveNode &SlaveNode, double t)
static void InterpolateAngle(const CNode &Node1, const CNode &Node2, CSlaveNode &SlaveNode, double t)
void CalculateNodeCoordinateSystem(const vector< CNode > &MasterNodes, vector< XYZ > &Tangents) const
CInterpolationLinear(bool bPeriodic=true, bool bForceInPlaneTangent=false, bool bForceMasterNodeTangent=false)
CSlaveNode GetNode(const vector< CNode > &MasterNodes, int iIndex, double t) const
Get a node from parametric function where t is specified.
void Initialise(const vector< CNode > &MasterNodes) const
Calculate the node tangents (use node tangents of they exist) and store them in m_Tangents.
Represents a point on the centreline of a yarn.
Definition: Node.h:28
XYZ GetPosition() const
Definition: Node.h:57
A derivation of the CNode class which contains data specific to slave nodes such as sections.
Definition: SlaveNode.h:30
void SetT(double t)
Definition: SlaveNode.h:71
void SetIndex(int iIndex)
Definition: SlaveNode.h:73
Namespace containing a series of customised math operations not found in the standard c++ library.
WXYZ & Normalise(WXYZ &Quaternion)
Normalise the quaternion and return it.
Definition: mymath.h:609
Struct for representing points in 3D space.
Definition: mymath.h:56
double z
Definition: mymath.h:57