-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterpolations.h
269 lines (224 loc) · 9.79 KB
/
Interpolations.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#ifndef INTERPOLATIONS_H_INCLUDED
#define INTERPOLATIONS_H_INCLUDED
#define INTERPOLATION_LINEAIRE 0
#define INTERPOLATION_COSINUS 1
#define INTERPOLATION_BEZIER 2
#define INTERPOLATION_INCONNUE 255
#include "glew.h"
#include <GLFW/glfw3.h>
#include "math.h"
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include "Courbe_Bezier_Plan.h"
using namespace std;
class Interpolations
{
public:
static float interpolation_lineaire_f(float a,float b,float t);
static double interpolation_lineaire_d(double a,double b,double t);
static void interpolation_lineaire_2f(float* a,float* b,float t,float* res);
static void interpolation_lineaire_2d(double* a,double* b,double t,double* res);
static void interpolation_lineaire_3f(float* a,float* b,float t,float* res);
static void interpolation_lineaire_4f(float* a,float* b,float t,float* res);
static void interpolation_lineaire_3d(double* a,double* b,double t,double* res);
static float interpolation_cosinusoidale_f(float a,float b,float t);
static double interpolation_cosinusoidale_d(double a,double b,double t);
static void interpolation_cosinusoidale_2f(float* a,float* b,float t,float* res);
static void interpolation_cosinusoidale_2d(double* a,double* b,double t,double* res);
static void interpolation_cosinusoidale_3f(float* a,float* b,float t,float* res);
static void interpolation_cosinusoidale_4f(float* a,float* b,float t,float* res);
static void interpolation_cosinusoidale_3d(double* a,double* b,double t,double* res);
};
#define ENVELOPPE_INTERPOLATION_OK 0
class Enveloppe_Interpolation: public Interpolations
{
public:
uint16_t erreur;
uint8_t type_interpolation;
private:
float* points;
uint32_t nbrPoints;
public:
Enveloppe_Interpolation(float* p_points,uint32_t p_nbrPoints,uint8_t p_type=INTERPOLATION_LINEAIRE);
~Enveloppe_Interpolation();
float renvoie_valeur(float t);
};
#define INTERPOLATION_PARAMETRE_OK 0
#define INTERPOLATION_PARAMETRE_ERREUR_MEMOIRE 1
class Interpolation_Parametre: public Interpolations
{
public:
uint16_t erreur;
float t0;
float valeur_depart;
float valeur_fin;
float duree;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
Enveloppe_Interpolation* enveloppe;
bool drapeau_en_cours;
public:
Interpolation_Parametre(float p_t0,float p_depart,float p_fin,float p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL,Enveloppe_Interpolation* p_enveloppe=NULL);
~Interpolation_Parametre();
void determine_parametres(float p_t0,float p_depart,float p_fin,float p_duree,uint8_t p_type=INTERPOLATION_INCONNUE,Courbe_Bezier_Plan* p_courbe=NULL,Enveloppe_Interpolation* p_enveloppe=NULL);
void determine_courbe_Bezier(Courbe_Bezier_Plan* p_courbe);
void reset();
float renvoie_valeur_parametre(float t);
};
#define SI_TYPE_TEMPS_DUREES 0 //Les indications temporelles sont des durées
#define SI_TYPE_TEMPS_REPERES 1 //Les indications temporelles sont des repères sur une ligne temporelle.
class Suite_Interpolations :public Interpolations
{
public:
float t0;
float duree_totale;
float* tableau_valeurs;
uint8_t* tableau_types;
Courbe_Bezier_Plan** tableau_courbes;
uint16_t nbrEtapes;
bool drapeau_en_cours;
bool drapeau_bouclage;
public:
Suite_Interpolations(float p_t0,float* p_valeurs, uint8_t* p_types,uint16_t p_nbrEtapes,bool p_bouclage=false,uint8_t type_temps=SI_TYPE_TEMPS_DUREES,Courbe_Bezier_Plan** p_courbes=NULL);
~Suite_Interpolations();
void inverse();
void maj_duree_totale();
void determine_t0(float p_t0);
float renvoie_valeur(float t);
};
class Suite_Interpolations_3f :public Interpolations
{
public:
float t0;
float duree_totale;
float* tableau_valeurs;
uint8_t* tableau_types;
Courbe_Bezier_Plan** tableau_courbes;
uint16_t nbrEtapes;
bool drapeau_en_cours;
bool drapeau_bouclage;
public:
Suite_Interpolations_3f(float p_t0,float* p_valeurs, uint8_t* p_types,uint16_t p_nbrEtapes,bool p_bouclage=false,uint8_t type_temps=SI_TYPE_TEMPS_DUREES,Courbe_Bezier_Plan** p_courbes=NULL);
~Suite_Interpolations_3f();
void maj_duree_totale();
void determine_t0(float p_t0);
void renvoie_valeurs(float t,float* resultat );
};
class Interpolation_Parametre_2f: public Interpolations
{
public:
uint16_t erreur;
float t0;
float valeur_depart[2];
float valeur_fin[2];
float duree;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
public:
Interpolation_Parametre_2f(float p_t0,float* p_depart,float* p_fin,float p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_2f();
void determine_parametres(float p_t0,float* p_depart,float* p_fin,float p_duree,uint8_t p_type=INTERPOLATION_INCONNUE,Courbe_Bezier_Plan* p_courbe=NULL);
void renvoie_valeur_parametre(float t, float* resultat);
};
class Interpolation_Parametre_2d: public Interpolations
{
public:
uint16_t erreur;
double t0;
double valeur_depart[2];
double valeur_fin[2];
double duree;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
public:
Interpolation_Parametre_2d(double p_t0,double* p_depart,double* p_fin,double p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_2d();
void determine_parametres(double p_t0,double* p_depart,double* p_fin,double p_duree,uint8_t p_type,Courbe_Bezier_Plan* p_courbe=NULL);
void renvoie_valeur_parametre(double t, double* resultat);
};
class Interpolation_Parametre_3f: public Interpolations
{
public:
uint16_t erreur;
float t0;
float valeur_depart[3];
float valeur_fin[3];
float duree;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
public:
Interpolation_Parametre_3f(float p_t0,float* p_depart,float* p_fin,float p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_3f();
void determine_parametres(float p_t0,float* p_depart,float* p_fin,float p_duree,uint8_t p_type,Courbe_Bezier_Plan* p_courbe=NULL);
void determine_valeurs(float* p_depart, float* p_fin);
void determine_valeurs_depart(float* p_depart);
void determine_valeurs_fin(float* p_fin);
void determine_courbe_Bezier(Courbe_Bezier_Plan* p_courbe);
void renvoie_valeur_parametre(float t, float* resultat);
};
class Interpolation_Parametre_multi: public Interpolations
{
public:
uint16_t erreur;
float t0;
float valeur_depart[256];
float valeur_fin[256];
float duree;
uint16_t num_parametres;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
public:
Interpolation_Parametre_multi(float p_t0,float* p_depart,float* p_fin,uint16_t numParams,float p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_multi();
void determine_parametres(float p_t0,float* p_depart,float* p_fin,float p_duree,uint8_t p_type,Courbe_Bezier_Plan* p_courbe=NULL);
void determine_valeurs(float* p_depart, float* p_fin);
void determine_valeurs_depart(float* p_depart);
void determine_valeurs_fin(float* p_fin);
void determine_courbe_Bezier(Courbe_Bezier_Plan* p_courbe);
void renvoie_valeur_parametre(float t, float* resultat);
};
class Interpolation_Parametre_3d: public Interpolations
{
public:
uint16_t erreur;
double t0;
double valeur_depart[3];
double valeur_fin[3];
double duree;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
public:
Interpolation_Parametre_3d(double p_t0,double* p_depart,double* p_fin,double p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_3d();
void determine_parametres(double p_t0,double* p_depart,double* p_fin,double p_duree,uint8_t p_type,Courbe_Bezier_Plan* p_courbe=NULL);
void renvoie_valeur_parametre(double t, double* resultat);
};
class Interpolation_Parametre_rvba: public Interpolations
{
public:
uint16_t erreur;
float t0;
uint32_t valeur_depart;
uint32_t valeur_fin;
float duree;
bool drapeau_en_cours;
uint8_t type_interpolation;
Courbe_Bezier_Plan* courbe_bezier;
float rvba_depart[4];
float rvba_fin[4];
private:
public:
Interpolation_Parametre_rvba(float p_t0,uint32_t p_depart,uint32_t p_fin,float p_duree,uint8_t p_type=INTERPOLATION_LINEAIRE,Courbe_Bezier_Plan* p_courbe=NULL);
~Interpolation_Parametre_rvba();
void determine_parametres(float p_t0,uint32_t p_depart,uint32_t p_fin,float p_duree,uint8_t p_type,Courbe_Bezier_Plan* p_courbe=NULL);
uint32_t renvoie_valeur_parametre(float t);
};
#endif // INTERPOLATIONS_H_INCLUDED