# Kstars

houghline.h
1/*
2 SPDX-FileCopyrightText: 2019 Patrick Molenaar <pr_molenaar@hotmail.com>
3
5*/
6
7#ifndef HOUGHLINE_H_
8#define HOUGHLINE_H_
9
10#include <QLineF>
11#include <QPointF>
12#include <stdio.h>
13#include <qmath.h>
14
15/**
16 * @class HoughLine
17 * Line representation for HoughTransform
18 * Based on the java implementation found on http://vase.essex.ac.uk/software/HoughTransform
19 * @author Patrick Molenaar
20 * @version 1.0
21 */
22class HoughLine : public QLineF
23{
24 public:
25 enum IntersectResult {
26 PARALLEL,
27 COINCIDENT,
28 NOT_INTERESECTING,
29 INTERESECTING
30 };
31
32 HoughLine(double theta, double r, int width, int height, int score);
33 virtual ~HoughLine() = default;
34 QPointF RotatePoint(int x1, double r, double theta, int width, int height);
35 IntersectResult Intersect(const HoughLine& other_line, QPointF& intersection);
36 bool DistancePointLine(const QPointF& point, QPointF& intersection, double& distance);
37 int getScore() const;
38 double getR() const;
39 double getTheta() const;
40 void setTheta(const double theta);
41
42 HoughLine& operator=(const HoughLine &other)
43 {
44 theta = other.getTheta();
45 r = other.getR();
46 score = other.getScore();
47 setP1(other.p1());
48 setP2(other.p2());
49 return *this;
50 }
51
52 bool operator<(const HoughLine &other) const
53 {
54 return (score < other.getScore());
55 }
56
57 static bool compareByScore(const HoughLine *line1,const HoughLine *line2);
58 static bool compareByTheta(const HoughLine *line1,const HoughLine *line2);
59 static void getSortedTopThreeLines(QVector<HoughLine*> &houghLines, QVector<HoughLine*> &top3Lines);
60
61 void printHoughLine();
62 void Offset(const int offsetX, const int offsetY);
63
64 private:
65 double Magnitude(const QPointF& point1, const QPointF& point2);
66
67 int score;
68 double theta;
69 double r;
70 QPointF beginPoint;
71 QPointF endPoint;
72};
73
74#endif
Line representation for HoughTransform Based on the java implementation found on http://vase....
Definition houghline.h:23
IntersectResult Intersect(const HoughLine &other_line, QPointF &intersection)
Sources for intersection and distance calculations came from http://paulbourke.net/geometry/pointline...
Definition houghline.cpp:94
HoughLine(double theta, double r, int width, int height, int score)
Initialises the hough line.
Definition houghline.cpp:16
void setP1(const QPointF &p1)
void setP2(const QPointF &p2)
qreal x1() const const
This file is part of the KDE documentation.