Engauge Digitizer 2
Loading...
Searching...
No Matches
ExportOrdinalsStraight.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
8#include "Logger.h"
9#include <qdebug.h>
10#include <qmath.h>
11#include <QPointF>
12#include "Transformation.h"
13
14using namespace std;
15
19
21 double pointsInterval) const
22{
23 LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
24
25 // Results
27
28 // Integrate the distances for the subintervals
29 double distanceAlongSegment = 0;
30 QPointF posLast (points [0].posScreen().x(),
31 points [0].posScreen().y());
32 double ordinalLast = 0;
33
34 // Simplest method to find the intervals is to break up the curve into many smaller intervals, and then aggregate them
35 // into intervals that, as much as possible, have the desired length. Simplicity wins out over accuracy in this
36 // approach - accuracy is sacrificed to achieve simplicity
37 for (int iP = 0; iP < points.count(); iP++) {
38
39 const Point &pointNew = points.at (iP);
41
43 double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
44
46
48
49 ordinals.push_back (ordinalLast + sLocal);
50
52 }
53
55 ordinalLast = pointNew.ordinal();
57 }
58
59 return ordinals;
60}
61
63 const Transformation &transformation,
64 double pointsInterval) const
65{
66 LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
67
68 // Results
70
71 // Integrate the distances for the subintervals
72 double distanceAlongSegment = 0;
74 transformation.transformScreenToRawGraph (points [0].posScreen(),
75 posLast);
76 double ordinalLast = 0;
77
78 // Simplest method to find the intervals is to break up the curve into many smaller intervals, and then aggregate them
79 // into intervals that, as much as possible, have the desired length. Simplicity wins out over accuracy in this
80 // approach - accuracy is sacrificed to achieve simplicity
81 for (int iP = 0; iP < points.count(); iP++) {
82
83 const Point &pointNew = points.at (iP);
85 transformation.transformScreenToRawGraph (pointNew.posScreen(),
86 posNew);
87
89 double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
90
92
94
95 ordinals.push_back (ordinalLast + sLocal);
96
98 }
99
100 ordinalLast = pointNew.ordinal();
101 posLast = posNew;
102 }
103
104 return ordinals;
105}
const int INNER_RADIUS_MIN
QList< double > ExportValuesOrdinal
log4cpp::Category * mainCat
Definition Logger.cpp:14
QList< Point > Points
Definition Points.h:13
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation(const Points &points, double pointsInterval) const
Compute ordinals, without any conversion to graph coordinates.
ExportOrdinalsStraight()
Single constructor.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation(const Points &points, const Transformation &transformation, double pointsInterval) const
Compute ordinals, converting screen coordinates to graph coordinates.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition Point.h:26
QPointF posScreen() const
Accessor for screen position.
Definition Point.cpp:404
Affine transformation between screen and graph coordinates, based on digitized axis points.
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18