GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_interpolator.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #include "glc_interpolator.h"
26 
27 using namespace glc;
28 
30 : m_InterpolType(INTERPOL_LINEAIRE)
31 , m_StepCount(1)
32 {
33 
34 }
35 
37 // Set Function
39 void GLC_Interpolator::SetInterpolMat(int NbrPas, const GLC_Vector3d &VectDepart, const GLC_Vector3d &VectArrive
40  , INTERPOL_TYPE Interpolation)
41 {
42  m_InterpolType= Interpolation;
43  if (NbrPas != 0)
44  m_StepCount= NbrPas;
45 
46  m_StartPoint= VectDepart;
47  m_EndPoint= VectArrive;
48 
50 }
51 
53 {
54  if (m_InterpolType != Interpolation)
55  {
56  m_InterpolType= Interpolation;
57 
59  }
60 }
61 
63 {
64 
65  if ((NbrPas != 0) && (m_StepCount != NbrPas))
66  {
67  m_StepCount= NbrPas;
68 
70  }
71 }
72 
73 void GLC_Interpolator::SetVecteurs(const GLC_Vector3d &VectDepart, const GLC_Vector3d &VectArrive)
74 {
75  m_StartPoint= VectDepart;
76  m_EndPoint= VectArrive;
77 
78 
80 
81 }
82 
84 // Private sevices functions
86 
88 {
89 
90  if (m_StartPoint != m_EndPoint)
91  {
92  switch (m_InterpolType)
93  {
94  case INTERPOL_LINEAIRE:
95  return CalcInterpolLineaireMat();
96  break;
97 
98  case INTERPOL_ANGULAIRE:
99  return CalcInterpolAngulaireMat();
100  break;
101 
102  case INTERPOL_HOMOTETIE:
103  return false;
104  break;
105 
106  default:
107  return false;
108  }
109  }
110  else return false;
111 
112 }
113 
114 
116 {
117 
118  const GLC_Vector3d VectTrans= (m_EndPoint - m_StartPoint) * (1.0 / m_StepCount);
119  if(VectTrans.isNull())
120  {
122  return false;
123  }
124  else
125  {
126  m_InterpolMat.setMatTranslate(VectTrans);
127  return true;
128  }
129 }
130 
132 {
133 
134  const GLC_Vector3d AxeRot(m_StartPoint ^ m_EndPoint);
135 
136  const double Angle= m_EndPoint.angleWithVect(m_StartPoint) / m_StepCount;
137 
138  if (qFuzzyCompare(Angle, 0.0))
139  {
141  return false;
142  }
143  else
144  {
145  m_InterpolMat.setMatRot( AxeRot, Angle);
146  return true;
147  }
148 }
149 
150 
151 

©2005-2013 Laurent Ribon