Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Point
PointMatchTriplet.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
7
#include "
PointMatchTriplet.h
"
8
9
PointMatchTriplet::PointMatchTriplet
(
int
x
,
10
int
y
,
11
double
correlation
) :
12
m_x (
x
),
13
m_y (
y
),
14
m_correlation (
correlation
)
15
{
16
}
17
18
double
PointMatchTriplet::correlation
()
const
19
{
20
return
m_correlation;
21
}
22
23
bool
PointMatchTriplet::operator<
(
const
PointMatchTriplet
&other)
const
24
{
25
// Sorting algorithm wants to sort by ascending correlation, but we want to sort by descending correlation. We
26
// compensate by comparing correlations numerically and flipping the result
27
28
bool
isLess =
false
;
29
30
if
(m_correlation == other.
correlation
()) {
31
32
// To reduce jumping around, we prefer points on the left when the correlations are equal
33
isLess = (m_x < other.
x
());
34
35
}
else
{
36
37
isLess = !(m_correlation < other.
correlation
());
38
39
}
40
41
return
isLess;
42
}
43
44
QPoint
PointMatchTriplet::point
()
const
45
{
46
return
QPoint (m_x,
47
m_y);
48
}
49
50
int
PointMatchTriplet::x
()
const
51
{
52
return
m_x;
53
}
54
55
int
PointMatchTriplet::y
()
const
56
{
57
return
m_y;
58
}
PointMatchTriplet.h
PointMatchTriplet::PointMatchTriplet
PointMatchTriplet(int x, int y, double correlation)
Single constructor.
Definition
PointMatchTriplet.cpp:9
PointMatchTriplet::correlation
double correlation() const
Get method for correlation.
Definition
PointMatchTriplet.cpp:18
PointMatchTriplet::operator<
bool operator<(const PointMatchTriplet &other) const
Comparison operator for sorting lists of this class using sorting algorithm.
Definition
PointMatchTriplet.cpp:23
PointMatchTriplet::y
int y() const
Get method for y coordinate.
Definition
PointMatchTriplet.cpp:55
PointMatchTriplet::x
int x() const
Get method for x coordinate.
Definition
PointMatchTriplet.cpp:50
PointMatchTriplet::point
QPoint point() const
Return (x,y) coordinates as a point.
Definition
PointMatchTriplet.cpp:44
Generated on
for Engauge Digitizer by
1.17.0