Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
ExportOrdinalsStraight Class Reference

Utility class to interpolate points spaced evenly along a piecewise defined curve with line segments between points. More...

#include <ExportOrdinalsStraight.h>

Collaboration diagram for ExportOrdinalsStraight:
Collaboration graph

Public Member Functions

 ExportOrdinalsStraight ()
 Single constructor. More...
 
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation (const Points &points, double pointsInterval) const
 Compute ordinals, without any conversion to graph coordinates. More...
 
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation (const Points &points, const Transformation &transformation, double pointsInterval) const
 Compute ordinals, converting screen coordinates to graph coordinates. More...
 

Detailed Description

Utility class to interpolate points spaced evenly along a piecewise defined curve with line segments between points.

Definition at line 19 of file ExportOrdinalsStraight.h.

Constructor & Destructor Documentation

ExportOrdinalsStraight::ExportOrdinalsStraight ( )

Single constructor.

Definition at line 16 of file ExportOrdinalsStraight.cpp.

17 {
18 }

Member Function Documentation

ExportValuesOrdinal ExportOrdinalsStraight::ordinalsAtIntervalsGraphWithoutTransformation ( const Points points,
double  pointsInterval 
) const

Compute ordinals, without any conversion to graph coordinates.

Definition at line 20 of file ExportOrdinalsStraight.cpp.

22 {
23  LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
24 
25  // Results
26  ExportValuesOrdinal ordinals;
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);
40  QPointF posNew = pointNew.posScreen();
41 
42  QPointF posDelta = posNew - posLast;
43  double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
44 
45  while (distanceAlongSegment < segmentLength) {
46 
47  double sLocal = distanceAlongSegment / segmentLength;
48 
49  ordinals.push_back (ordinalLast + sLocal);
50 
51  distanceAlongSegment += pointsInterval;
52  }
53 
54  distanceAlongSegment -= segmentLength;
55  ordinalLast = pointNew.ordinal();
56  posLast = posNew;
57  }
58 
59  return ordinals;
60 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:25
QPointF posScreen() const
Accessor for screen position.
Definition: Point.cpp:404
log4cpp::Category * mainCat
Definition: Logger.cpp:14
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition: Point.cpp:386
QList< double > ExportValuesOrdinal
ExportValuesOrdinal ExportOrdinalsStraight::ordinalsAtIntervalsGraphWithTransformation ( const Points points,
const Transformation transformation,
double  pointsInterval 
) const

Compute ordinals, converting screen coordinates to graph coordinates.

Definition at line 62 of file ExportOrdinalsStraight.cpp.

65 {
66  LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
67 
68  // Results
69  ExportValuesOrdinal ordinals;
70 
71  // Integrate the distances for the subintervals
72  double distanceAlongSegment = 0;
73  QPointF posLast;
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);
84  QPointF posNew;
85  transformation.transformScreenToRawGraph (pointNew.posScreen(),
86  posNew);
87 
88  QPointF posDelta = posNew - posLast;
89  double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
90 
91  while (distanceAlongSegment < segmentLength) {
92 
93  double sLocal = distanceAlongSegment / segmentLength;
94 
95  ordinals.push_back (ordinalLast + sLocal);
96 
97  distanceAlongSegment += pointsInterval;
98  }
99 
100  ordinalLast = pointNew.ordinal();
101  posLast = posNew;
102  }
103 
104  return ordinals;
105 }
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
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:25
QPointF posScreen() const
Accessor for screen position.
Definition: Point.cpp:404
log4cpp::Category * mainCat
Definition: Logger.cpp:14
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition: Point.cpp:386
QList< double > ExportValuesOrdinal

The documentation for this class was generated from the following files: