forked from zalohasa/GrblHoming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpolator.cpp
51 lines (44 loc) · 937 Bytes
/
interpolator.cpp
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
#include "interpolator.h"
/*
* Basic interpolator class that all interpolators must derive from
*
* Gonzalo López 2014
*
*/
double Interpolator::normaliceValue(double min, double max, double value) const
{
return (value - min) / (max - min);
}
double Interpolator::getXValue(int index) const
{
if (index < nValuesX)
{
return xValues[index];
}
return 0;
}
double Interpolator::getYValue(int index) const
{
if (index < nValuesY)
{
return yValues[index];
}
return 0;
}
double Interpolator::calculateOffset(double newZValue)
{
double initialValue = xyValues[0]; //Original Z value at (0,0);
return initialValue - newZValue + initialOffset;
}
double Interpolator::yGridSize()
{
if (nValuesY > 1)
return yValues[1] - yValues[0];
return 0;
}
double Interpolator::xGridSize()
{
if (nValuesX > 1)
return xValues[1] - xValues[0];
return 0;
}