Kstars

houghline.h
1 /*
2  SPDX-FileCopyrightText: 2019 Patrick Molenaar <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
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  */
22 class 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
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)
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
qreal x1() const const
QPointF p1() const const
QPointF p2() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 03:59:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.