1 #include "ExportOrdinalsSmooth.h"
7 #include "Transformation.h"
17 vector<SplinePair> &xy)
const
19 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportOrdinalsSmooth::loadSplinePairsWithoutTransformation";
21 Points::const_iterator itrP;
22 for (itrP = points.begin(); itrP != points.end(); itrP++) {
23 const Point &point = *itrP;
35 vector<SplinePair> &xy)
const
37 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportOrdinalsSmooth::loadSplinePairsWithTransformation";
39 Points::const_iterator itrP;
40 for (itrP = points.begin(); itrP != points.end(); itrP++) {
41 const Point &point = *itrP;
54 const vector<SplinePair> &xy,
55 double pointsInterval)
const
57 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportOrdinalsSmooth::ordinalsAtIntervalsGraph";
59 const double NUM_SMALLER_INTERVALS = 1000;
62 ExportValuesOrdinal ordinals;
69 double integratedSeparation = 0;
70 QPointF posLast (xy [0].x(),
76 double tMin = t.front();
77 double tMax = t.back();
80 int iTLastInterval = 0;
81 for (
int iT = 0; iT < NUM_SMALLER_INTERVALS; iT++) {
83 double t = tMin + ((tMax - tMin) * iT) / (NUM_SMALLER_INTERVALS - 1.0);
87 QPointF posNew = QPointF (pairNew.
x(),
90 QPointF posDelta = posNew - posLast;
91 double integratedSeparationDelta = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
92 integratedSeparation += integratedSeparationDelta;
94 while (integratedSeparation >= pointsInterval) {
102 sInterp = (double) pointsInterval / (
double) integratedSeparation;
104 double tInterp = (1.0 - sInterp) * tLast + sInterp * t;
106 integratedSeparation -= pointsInterval;
109 ordinals.push_back (tInterp);
117 if (iTLastInterval < NUM_SMALLER_INTERVALS - 1) {
120 ordinals.push_back (tMax);
SplinePair interpolateCoeff(double t) const
Return interpolated y for specified x.
Cubic interpolation given independent and dependent value vectors.
double y() const
Get method for y.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
void loadSplinePairsWithTransformation(const Points &points, const Transformation &transformation, std::vector< double > &t, std::vector< SplinePair > &xy) const
Load t (=ordinal) and xy (=screen position) spline pairs, converting screen coordinates to graph coor...
void loadSplinePairsWithoutTransformation(const Points &points, std::vector< double > &t, std::vector< SplinePair > &xy) const
Load t (=ordinal) and xy (=screen position) spline pairs, without any conversion to graph coordinates...
ExportValuesOrdinal ordinalsAtIntervalsGraph(const std::vector< double > &t, const std::vector< SplinePair > &xy, double pointsInterval) const
Perform the interpolation on the arrays loaded by the other methods.
double x() const
Get method for x.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
ExportOrdinalsSmooth()
Single constructor.
Single X/Y pair for cubic spline interpolation initialization and calculations.