Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

geometry.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/List.h>
36 #include <ogdf/basic/Hashing.h>
37 #include <ogdf/basic/Math.h>
38 #include <ogdf/basic/EpsilonTest.h>
39 #include <cfloat>
40 
41 namespace ogdf {
42 
43 extern const EpsilonTest OGDF_GEOM_ET;
44 
46 enum class Orientation {
47  topToBottom,
48  bottomToTop,
49  leftToRight,
51 };
52 
53 inline
54  double DRound(const double &d, int prec = 0)
55 {
56  if (prec == 0)
57  return floor(d + 0.5);
58  double factor = pow(10.0, ((double) prec));
59  return DRound(d * factor, 0) / factor;
60 }
61 
70 template <class NUMBER>
72 {
73 public:
75  using numberType = NUMBER;
76 
77  NUMBER m_x;
78  NUMBER m_y;
79 
81 
86 
88  GenericPoint(NUMBER x, NUMBER y) : m_x(x), m_y(y) { }
89 
91  GenericPoint(const GenericPoint &p) : m_x(p.m_x), m_y(p.m_y) { }
92 
95  m_x = p.m_x;
96  m_y = p.m_y;
97  return *this;
98  }
99 
101  bool operator==(const GenericPoint &p) const {
102  return m_x == p.m_x && m_y == p.m_y;
103  }
104 
106  bool operator!=(const GenericPoint &p) const {
107  return m_x != p.m_x || m_y != p.m_y;
108  }
109 
110  bool operator<(const GenericPoint &p) {
111  return (m_x < p.m_x || (m_x == p.m_x && m_y < p.m_y));
112  }
113 
114  bool operator>(const GenericPoint &p) {
115  return !operator<(p);
116  }
117 
119  double angle(GenericPoint q, GenericPoint r) const
120  {
121  const double dx1 = q.m_x - m_x, dy1 = q.m_y - m_y;
122  const double dx2 = r.m_x - m_x, dy2 = r.m_y - m_y;
123 
124  // two vertices on the same place!
125  if ((dx1 == 0 && dy1 == 0)
126  || (dx2 == 0 && dy2 == 0)) {
127  return 0.0;
128  }
129 
130  const double norm = (dx1*dx1+dy1*dy1)*(dx2*dx2+dy2*dy2);
131  const double cosphi = (dx1*dx2+dy1*dy2) / sqrt(norm);
132  if (cosphi >= 1.0) return 0;
133  if (cosphi <= -1.0) return Math::pi;
134 
135  double phi = acos(cosphi);
136 
137  if (dx1*dy2 < dy1*dx2) phi = -phi;
138  if (phi < 0) phi += 2*Math::pi;
139 
140  return phi;
141  }
142 
145  {
146  return angle(q, r)*360.0/(2*Math::pi);
147  }
148 };//class GenericPoint
149 
150 
156 class OGDF_EXPORT IPoint : public GenericPoint<int>
157 {
158 public:
160  IPoint() : GenericPoint<int>(0,0) { }
161 
163  IPoint(int x, int y) : GenericPoint<int>(x,y) { }
164 
166  IPoint(const IPoint &ip) : GenericPoint<int>(ip) { }
167 
169  double distance(const IPoint &p) const;
170 };//class IPoint
171 
172 
174 OGDF_EXPORT ostream &operator<<(ostream &os, const IPoint &ip);
175 
176 
177 template<> class DefHashFunc<IPoint>
178 {
179 public:
180  int hash(const IPoint &ip) const {
181  return 7*ip.m_x + 23*ip.m_y;
182  }
183 };
184 
185 
194 class OGDF_EXPORT IPolyline : public List<IPoint> {
195 public:
197  IPolyline() { }
198 
200  IPolyline(const IPolyline &ipl) : List<IPoint>(ipl) { }
201 
205  return *this;
206  }
207 
209  double length() const;
210 };
211 
212 
213 
219 class OGDF_EXPORT DPoint : public GenericPoint<double>
220 {
221 public:
223  DPoint() : GenericPoint<double>(0,0) { }
224 
226  DPoint(double x, double y) : GenericPoint<double>(x,y) { }
227 
229  DPoint(const DPoint &dp) : GenericPoint<double>(dp) { }
230 
232  bool operator==(const DPoint &dp) const {
233  return OGDF_GEOM_ET.equal(m_x, dp.m_x) && OGDF_GEOM_ET.equal(m_y,dp.m_y);
234  }
235 
237  double norm() const {
238  return sqrt(m_x*m_x + m_y*m_y);
239  }
240 
242  DPoint operator+(const DPoint &p) const;
243 
245  DPoint operator-(const DPoint &p) const;
246 
247  DPoint &operator+=(const DPoint &p) {
248  m_x += p.m_x;
249  m_y += p.m_y;
250  return *this;
251  }
252 
253  DPoint &operator-=(const DPoint &p) {
254  m_x -= p.m_x;
255  m_y -= p.m_y;
256  return *this;
257  }
258 
259  DPoint &operator*=(double c) {
260  m_x *= c;
261  m_y *= c;
262  return *this;
263  }
264 
265  DPoint &operator/=(double c) {
266  m_x /= c;
267  m_y /= c;
268  return *this;
269  }
270 
271  friend DPoint operator*(double c, const DPoint &p) {
272  return DPoint(c*p.m_x, c*p.m_y);
273  }
274 
276  double distance(const DPoint &p) const;
277 };
278 
280 OGDF_EXPORT ostream &operator<<(ostream &os, const DPoint &dp);
281 
282 
286 class OGDF_EXPORT DVector : public DPoint {
287 public:
288 
290  DVector() : DPoint() { }
291 
293  DVector(double x, double y) : DPoint(x, y) { }
294 
296  DVector(const DVector &dv) : DPoint(dv) { }
297 
299  DVector(const DPoint &dv) : DPoint(dv) { }
300 
302  DVector operator=(const DPoint &ip) {
303  if (this != &ip)
304  {
305  m_x = ip.m_x;
306  m_y = ip.m_y;
307  }
308  return *this;
309  }
310 
312  DVector operator+(const DVector &dv) const;
313 
315  DVector operator-(const DVector &dv) const;
316 
318  DVector operator*(const double val) const;
319 
321  DVector operator/(const double val) const;
322 
324  double length() const;
325 
327  double operator^(const DVector &dv) const;
328 
330  double operator*(const DVector &dv) const;
331 
338  DVector orthogonal() const;
339 };
340 
341 
342 
350 class OGDF_EXPORT DPolyline : public List<DPoint> {
351  static const double s_prec;
352 public:
354  DPolyline() { }
355 
357  DPolyline(const DPolyline &dpl) : List<DPoint>(dpl) { }
358 
362  return *this;
363  }
364 
366  double length() const;
367 
375  DPoint position(const double fraction, double len = -1.0) const;
376 
378  void unify();
379 
381  void normalize();
382 
384  void normalize(DPoint src, //start point of the edge
385  DPoint tgt); //end point of the edge
386 
388  void convertToInt();
389 
390 #if 0
391  void reConvertToDouble();
392 #endif
393 };
394 
395 
400 
401 protected:
404 
405 public:
406 
408  DLine() : m_start(), m_end() {}
409 
411  DLine(const DPoint &p1, const DPoint &p2) : m_start(p1), m_end(p2) {}
412 
414  DLine(const DLine &dl) : m_start(dl.m_start), m_end(dl.m_end) {}
415 
417  DLine(double x1, double y1, double x2, double y2) {
418  m_start.m_x = x1; m_start.m_y = y1; m_end.m_x = x2; m_end.m_y = y2;
419  }
420 
422  bool operator==(const DLine &dl) const {
423  return m_start == dl.m_start && m_end == dl.m_end;
424  }
425 
427  bool operator!=(const DLine &dl) const {
428  return !(*this == dl);
429  }
430 
432  DLine &operator= (const DLine &dl) {
433  if (this != &dl) { // don't assign myself
434  m_start = dl.m_start;
435  m_end = dl.m_end;
436  }
437  return *this;
438  }
439 
441  const DPoint &start() const { return m_start; }
442 
444  const DPoint &end() const { return m_end; }
445 
447  double dx() const { return m_end.m_x - m_start.m_x; }
448 
450  double dy() const { return m_end.m_y - m_start.m_y; }
451 
453  double slope() const { return (dx() == 0) ? numeric_limits<double>::max() : dy()/dx(); }
454 
456  double yAbs() const { return (dx() == 0) ? numeric_limits<double>::max() : m_start.m_y - (slope() * m_start.m_x); }
457 
459  bool isVertical() const { return OGDF_GEOM_ET.equal(dx(), 0.0); }
460 
462  bool isHorizontal() const { return OGDF_GEOM_ET.equal(dy(), 0.0); }
463 
471  bool intersection(const DLine &line, DPoint &inter, bool endpoints = true) const;
472 
473  bool intersectionOfLines(const DLine &line, DPoint &inter) const;
474 
476  bool contains(const DPoint &p) const;
477 
479  double length() const {
480  return m_start.distance(m_end);
481  }
482 
492  int horIntersection(const double horAxis, double &crossing) const;
493 
494  // gives the intersection with the vertical axis 'verAxis', returns the number of intersections
495  // 0 = no, 1 = one, 2 = infinity or both end-points, e.g. parallel on this axis
505  int verIntersection(const double verAxis, double &crossing) const;
506 };
507 
509 OGDF_EXPORT ostream &operator<<(ostream &os, const DLine &dl);
510 
511 
516 
517  friend OGDF_EXPORT ostream &operator<<(ostream &os, const DRect &dr);
518 
519 protected:
522 
523 public:
525  DRect() = default;
526 
528  DRect(const DPoint &p1, const DPoint &p2)
529  : m_p1(p1)
530  , m_p2(p2)
531  { normalize(); }
532 
534  DRect(const DRect& dr)
535  : m_p1(dr.m_p1)
536  , m_p2(dr.m_p2) {}
537 
539  DRect(double x1, double y1, double x2, double y2)
540  : DRect(DPoint(x1,y1), DPoint(x2,y2)) {}
541 
543  explicit DRect(const DLine &dl)
544  : DRect(dl.start(), dl.end()) {}
545 
546  virtual ~DRect() = default;
547 
549  bool operator==(const DRect &dr) const {
550  return m_p1 == dr.m_p1 && m_p2 == dr.m_p2;
551  }
552 
554  bool operator!=(const DRect &dr) const {
555  return !(*this == dr);
556  }
557 
559  DRect &operator= (const DRect &dr) {
560  if (this != &dr) { // don't assign myself
561  m_p1 = dr.m_p1;
562  m_p2 = dr.m_p2;
563  }
564  return *this;
565  }
566 
568  double width() const {
569  return m_p2.m_x - m_p1.m_x;
570  }
571 
573  double height() const {
574  return m_p2.m_y - m_p1.m_y;
575  }
576 
583  void normalize() {
584  if (width() < 0) swap(m_p2.m_x, m_p1.m_x);
585  if (height() < 0) swap(m_p2.m_y, m_p1.m_y);
586  }
587 
589  const DPoint &p1() const { return m_p1; }
590 
592  const DPoint &p2() const { return m_p2; }
593 
595  const DLine topLine() const {
596  return DLine( DPoint(m_p1.m_x, m_p2.m_y), DPoint(m_p2.m_x, m_p2.m_y));
597  }
598 
600  const DLine rightLine() const {
601  return DLine( DPoint(m_p2.m_x, m_p2.m_y), DPoint(m_p2.m_x, m_p1.m_y));
602  }
603 
605  const DLine leftLine() const {
606  return DLine( DPoint(m_p1.m_x, m_p1.m_y), DPoint(m_p1.m_x, m_p2.m_y));
607  }
608 
610  const DLine bottomLine() const {
611  return DLine( DPoint(m_p2.m_x, m_p1.m_y), DPoint(m_p1.m_x, m_p1.m_y));
612  }
613 
615  void yInvert() { swap(m_p1.m_y, m_p2.m_y); }
616 
618  void xInvert() { swap(m_p1.m_x, m_p2.m_x); }
619 
621  bool contains(const DPoint &p) const {
622  return OGDF_GEOM_ET.geq(p.m_x, m_p1.m_x)
623  && OGDF_GEOM_ET.leq(p.m_x, m_p2.m_x)
624  && OGDF_GEOM_ET.geq(p.m_y, m_p1.m_y)
625  && OGDF_GEOM_ET.leq(p.m_y, m_p2.m_y);
626  }
627 
628 protected:
630  DLine bottom() const { return DLine(m_p1.m_x,m_p1.m_y,m_p2.m_x,m_p1.m_y); }
631 
633  DLine top() const { return DLine(m_p1.m_x, m_p2.m_y, m_p2.m_x,m_p2.m_y); }
634 
636  DLine left() const { return DLine(m_p1.m_x, m_p1.m_y, m_p1.m_x, m_p2.m_y); }
637 
639  DLine right() const { return DLine(m_p2.m_x, m_p1.m_y, m_p2.m_x, m_p2.m_y); }
640 
642  double parallelDist(const DLine &d1, const DLine &d2) const;
643 
645  double pointDist(const DPoint &p1, const DPoint &p2) const {
646  return sqrt((p1.m_y - p2.m_y) * (p1.m_y - p2.m_y) + (p1.m_x - p2.m_x) * (p1.m_x - p2.m_x));
647  }
648 };
649 
650 
658 
659  friend OGDF_EXPORT ostream &operator<<(ostream &os, const DIntersectableRect &dr);
660 
661  double m_area = 0.0;
663 
668  void initAreaAndCenter();
669 
670 public:
672  DIntersectableRect() = default;
673 
675  DIntersectableRect(const DPoint &p1, const DPoint &p2)
676  : DRect(p1, p2)
677  { initAreaAndCenter(); }
678 
680  DIntersectableRect(double x1, double y1, double x2, double y2)
681  : DIntersectableRect(DPoint(x1,y1), DPoint(x2,y2)) {}
682 
685  : DRect(static_cast<DRect>(dr))
686  , m_area(dr.m_area)
687  , m_center(dr.m_center) {}
688 
690  DIntersectableRect(const DPoint &center, double width, double height)
691  : DIntersectableRect(DPoint(center.m_x-width/2,center.m_y-height/2),
692  DPoint(center.m_x+width/2,center.m_y+height/2)) {};
693 
695  DIntersectableRect &operator= (const DIntersectableRect &dr) {
696  if (this != &dr) { // don't assign myself
697  m_p1 = dr.m_p1;
698  m_p2 = dr.m_p2;
699  m_center = dr.m_center;
700  m_area = dr.m_area;
701  }
702  return *this;
703  }
704 
706  DPoint center() const { return m_center; }
707 
709  double area() const { return m_area; }
710 
712  bool intersects(const DIntersectableRect &rectangle) const;
713 
717  DIntersectableRect intersection(const DIntersectableRect &other) const;
718 
720  double distance(const DIntersectableRect &other) const;
721 
723  void move(const DPoint &point);
724 };
725 
728 
729 private:
730 
731  const DRect *m_from;
732  const DRect *m_to;
733 
734  double m_factorX;
735  double m_factorY;
736  double m_offsetX;
737  double m_offsetY;
738 
739 public:
741  DScaler(const DRect &from, const DRect &to) :
742  m_from(&from),
743  m_to(&to),
744  m_factorX(to.width()/from.width()),
745  m_factorY(to.height()/from.height()),
746  m_offsetX(to.p1().m_x - from.p1().m_x * m_factorX),
747  m_offsetY(to.p1().m_y - from.p1().m_y * m_factorY) { }
748 
749  ~DScaler() {}
750 
752  const DRect &from() const { return *m_from; }
753 
755  const DRect &to() const { return *m_to; }
756 
758  double scaleToX(double x) { return x * m_factorX + m_offsetX; }
759 
761  double scaleToY(double y) { return y * m_factorY + m_offsetY; }
762 
764  double scaleWidth(double width) { return width * m_to->width() /m_from->width(); }
765 
767  double scaleHeight(double height) { return height * m_to->height()/m_from->height(); }
768 };
769 
770 
772 OGDF_EXPORT ostream &operator<<(ostream &os, const DScaler &ds);
773 
774 
778 class OGDF_EXPORT DSegment : public DLine {
779 
780 protected:
781 
782 public:
783 
785  DSegment() : DLine() {}
786 
788  DSegment(const DPoint &p1, const DPoint &p2) : DLine(p1, p2) {}
789 
791  explicit DSegment(const DLine &dl) : DLine(dl) {}
792 
794  DSegment(double x1, double y1, double x2, double y2) : DLine(x1, y1, x2, y2) {}
795 
797  DSegment(const DSegment &ds) : DLine(ds) {}
798 
799 
806  double det(const DSegment &segment) const {
807  return (dx() * segment.dy() - dy() * segment.dx());
808  }
809 };
810 
811 
816 
817 protected:
818 
820 
821 public:
828  DPolygon(bool cc = true) : m_counterclock(cc) { }
829 
831  explicit DPolygon(const DRect &rect, bool cc = true) : m_counterclock(cc) {
832  operator=(rect);
833  }
834 
836  DPolygon(const DPolygon &dop) : DPolyline(dop), m_counterclock(dop.m_counterclock) { }
837 
839  bool counterclock() { return m_counterclock; }
840 
842  DPolygon &operator=(const DPolygon &dop) {
844  m_counterclock = dop.m_counterclock;
845  return *this;
846  }
847 
849  DPolygon &operator=(const DRect &rect);
850 
852  DSegment segment(ListConstIterator<DPoint> it) const;
853 
854 
857  return insertPoint(p, begin(), begin());
858  }
859 
865  ListIterator<DPoint> insertPoint(const DPoint &p,
868 
870  void insertCrossPoint(const DPoint &p);
871 
873  int getCrossPoints(const DPolygon &p, List<DPoint> &crossPoints) const;
874 
876  void unify();
877 
879  void normalize();
880 
887  bool containsPoint(DPoint &p) const;
888 };
889 
891 OGDF_EXPORT ostream &operator<<(ostream &os, const DPolygon &dop);
892 
893 
894 int orientation(const DPoint &p, const DPoint &q, const DPoint &r);
895 
896 
897 inline int orientation(const DSegment &s, const DPoint &p)
898 {
899  return orientation(s.start(), s.end(), p);
900 }
901 
902 
903 
904 
905 } // end namespace ogdf
DIntersectableRect(double x1, double y1, double x2, double y2)
Creates a rectangle with lower left point (x1,y1) and upper right point (x1,y2).
Definition: geometry.h:680
static const double pi
The constant .
Definition: Math.h:46
DLine right() const
Right bounding line.
Definition: geometry.h:639
DPolygon(const DPolygon &dop)
Copy constructor.
Definition: geometry.h:836
static const int line
Definition: GmlParser.h:86
Default hash functions.
Definition: Hashing.h:218
void normalize()
Normalizes the rectangle.
Definition: geometry.h:583
DPoint & operator+=(const DPoint &p)
Definition: geometry.h:247
const DLine rightLine() const
Returns the right side of the rectangle.
Definition: geometry.h:600
double angle(GenericPoint q, GenericPoint r) const
Compute angle (in radians) between vectors.
Definition: geometry.h:119
NUMBER m_y
The y-coordinate.
Definition: geometry.h:78
int hash(const IPoint &ip) const
Definition: geometry.h:180
Lit operator^(Lit p, bool b)
Definition: SolverTypes.h:59
bool m_counterclock
If true points are given in conter-clockwise order.
Definition: geometry.h:819
DIntersectableRect(const DPoint &center, double width, double height)
Constructs a rectangle from the center point, width and height.
Definition: geometry.h:690
double height() const
Returns the height of the rectangle.
Definition: geometry.h:573
Polygons with real coordinates.
Definition: geometry.h:815
double pointDist(const DPoint &p1, const DPoint &p2) const
Computes distance between two points.
Definition: geometry.h:645
DPoint(double x, double y)
Creates a real point (x,y).
Definition: geometry.h:226
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double scaleToY(double y)
Transforms y-coordinates from source to target coordinate system.
Definition: geometry.h:761
IPoint(const IPoint &ip)
Copy constructor.
Definition: geometry.h:166
DIntersectableRect(const DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
Definition: geometry.h:675
IPolyline()
Creates an empty integer polyline.
Definition: geometry.h:197
double width() const
Returns the width of the rectangle.
Definition: geometry.h:568
double DRound(const double &d, int prec=0)
Definition: geometry.h:54
Polylines with integer coordinates.
Definition: geometry.h:194
double m_factorX
The scaling factor for the x-coordinates.
Definition: geometry.h:734
GenericPoint(const GenericPoint &p)
Copy constructor.
Definition: geometry.h:91
bool counterclock()
Returns true iff points are given in counter-clockwise order.
Definition: geometry.h:839
Rectangles with real coordinates.
Definition: geometry.h:515
DLine left() const
Left bounding line.
Definition: geometry.h:636
double m_factorY
The scaling factor for the y-coordinates.
Definition: geometry.h:735
Lines with real coordinates.
Definition: geometry.h:399
bool isHorizontal() const
Returns true iff this line runs horizontally.
Definition: geometry.h:462
DIntersectableRect(const DIntersectableRect &dr)
Copy constructor.
Definition: geometry.h:684
DSegment()
Creates an empty line segment.
Definition: geometry.h:785
Declaration of classes used for hashing.
DPoint center() const
Center of the rectangle.
Definition: geometry.h:706
Polylines with real coordinates.
Definition: geometry.h:350
NUMBER m_x
The x-coordinate.
Definition: geometry.h:77
Rectangles with real coordinates.
Definition: geometry.h:657
bool operator==(const DLine &dl) const
Equality operator.
Definition: geometry.h:422
double norm() const
Returns the norm of the point.
Definition: geometry.h:237
MDMFLengthAttribute operator-(MDMFLengthAttribute x, const MDMFLengthAttribute &y)
DLine top() const
Top bounding line.
Definition: geometry.h:633
Compare floating point numbers with epsilons and integral numbers with normal compare operators...
IPoint()
Creates an integer point (0,0).
Definition: geometry.h:160
Real points.
Definition: geometry.h:219
void yInvert()
Swaps the y-coordinates of the two points.
Definition: geometry.h:615
DPolyline()
Creates an empty integer polyline.
Definition: geometry.h:354
const DRect * m_from
Rectangluar area in source coordinate system.
Definition: geometry.h:731
DSegment(const DPoint &p1, const DPoint &p2)
Creates a line segment from p1 to p2.
Definition: geometry.h:788
ostream & operator<<(ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:764
IPoint(int x, int y)
Creates an integer point (x,p y).
Definition: geometry.h:163
DPoint(const DPoint &dp)
Copy constructor.
Definition: geometry.h:229
double scaleWidth(double width)
Scales a horizontal length from source to target coordinate system.
Definition: geometry.h:764
Orientation
Determines the orientation in hierarchical layouts.
Definition: geometry.h:46
const DRect * m_to
Rectangluar area in target coordinate system.
Definition: geometry.h:732
bool operator==(const DRect &dr) const
Equality operator: both rectangles have the same coordinates.
Definition: geometry.h:549
DVector(double x, double y)
Creates a vector (x,y).
Definition: geometry.h:293
DVector operator=(const DPoint &ip)
Assignment operator.
Definition: geometry.h:302
GenericPoint & operator=(const GenericPoint &p)
Assignment operator.
Definition: geometry.h:94
Integer points.
Definition: geometry.h:156
DLine(double x1, double y1, double x2, double y2)
Creates a line with start point (x1,y1) and end point (x2,y2).
Definition: geometry.h:417
const EpsilonTest OGDF_GEOM_ET
DPoint & operator*=(double c)
Definition: geometry.h:259
DVector(const DPoint &dv)
Copy constructor from DPoint.
Definition: geometry.h:299
DLine()
Creates an empty line.
Definition: geometry.h:408
const DPoint & p1() const
Returns the lower left point of the rectangle.
Definition: geometry.h:589
int numberType
The type for coordinates of the point.
Definition: geometry.h:75
DVector(const DVector &dv)
Copy constructor.
Definition: geometry.h:296
double scaleToX(double x)
Transforms x-coordinates from source to target coordinate system.
Definition: geometry.h:758
Mathematical Helpers.
DRect(const DLine &dl)
Creates a rectangle defined by the end points of line dl.
Definition: geometry.h:543
IPolyline(const IPolyline &ipl)
Copy constructor.
Definition: geometry.h:200
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
bool operator==(const DPoint &dp) const
Relaxed equality operator.
Definition: geometry.h:232
DRect(const DPoint &p1, const DPoint &p2)
Creates a rectangle with lower left point p1 and upper right point p2.
Definition: geometry.h:528
double m_offsetX
The offset for the x-coordinates.
Definition: geometry.h:736
DLine(const DLine &dl)
Copy constructor.
Definition: geometry.h:414
double yAbs() const
Returns the value y&#39; such that (0,y&#39;) lies on the unlimited straight-line define dby this line...
Definition: geometry.h:456
double scaleHeight(double height)
Scales a vertical length from source to target coordinate system.
Definition: geometry.h:767
Edges are oriented from left to right.
const DRect & from() const
Returns the rectangle in the source coordinate system.
Definition: geometry.h:752
Vectors with real coordinates.
Definition: geometry.h:286
bool operator>(const GenericPoint &p)
Definition: geometry.h:114
bool contains(const DPoint &p) const
Returns true iff p lies within this rectangle, modulo the comparison epsilon OGDF_GEOM_ET.
Definition: geometry.h:621
double angleDegrees(GenericPoint q, GenericPoint r) const
Compute angle (in degrees) between vectors.
Definition: geometry.h:144
double dy() const
Returns the y-coordinate of the difference (end point - start point).
Definition: geometry.h:450
bool operator<(const GenericPoint &p)
Definition: geometry.h:110
DPoint m_start
The start point of the line.
Definition: geometry.h:402
DPolygon(const DRect &rect, bool cc=true)
Creates a polgon from a rectangle.
Definition: geometry.h:831
Encapsulates a pointer to a list element.
Definition: List.h:41
bool operator!=(const DLine &dl) const
Inequality operator.
Definition: geometry.h:427
DLine(const DPoint &p1, const DPoint &p2)
Creates a line with start point p1 and end point p2.
Definition: geometry.h:411
double length() const
Returns the length (euclidean distance between start and edn point) of this line. ...
Definition: geometry.h:479
double area() const
Area of the rectangle.
Definition: geometry.h:709
const T & move(const T &v)
Definition: backward.hpp:243
DVector()
Creates a vector (0,0).
Definition: geometry.h:290
IPolyline & operator=(const IPolyline &ipl)
Assignment operator.
Definition: geometry.h:203
void xInvert()
Swaps the x-coordinates of the two points.
Definition: geometry.h:618
DPolygon & operator=(const DPolygon &dop)
Assignment operator.
Definition: geometry.h:842
DSegment(const DSegment &ds)
Copy constructor.
Definition: geometry.h:797
Edges are oriented from right to left.
bool operator<(const MDMFLengthAttribute &x, const MDMFLengthAttribute &y)
GenericPoint(NUMBER x, NUMBER y)
Creates a generic point (x,y).
Definition: geometry.h:88
const DLine bottomLine() const
Returns the bottom side of the rectangle.
Definition: geometry.h:610
Scaling between coordinate systems.
Definition: geometry.h:727
const DPoint & start() const
Returns the start point of the line.
Definition: geometry.h:441
DScaler(const DRect &from, const DRect &to)
Creates a scaler for scaling from area from to area to.
Definition: geometry.h:741
DPoint & operator/=(double c)
Definition: geometry.h:265
Parameterized base class for points.
Definition: geometry.h:71
DLine bottom() const
Bottom bounding line.
Definition: geometry.h:630
double distance(const DPoint &p) const
Returns the euclidean distance between p and this point.
Edges are oriented from top to bottom.
const DLine topLine() const
Returns the top side of the rectangle.
Definition: geometry.h:595
double m_offsetY
The offset for the y-coordinates.
Definition: geometry.h:737
static const double s_prec
The conversion-precision.
Definition: geometry.h:351
DRect(double x1, double y1, double x2, double y2)
Creates a rectangle with lower left point (x1,y1) and upper right point (x2,y2).
Definition: geometry.h:539
bool operator!=(const DRect &dr) const
Inequality operator.
Definition: geometry.h:554
bool isVertical() const
Returns true iff this line runs vertically.
Definition: geometry.h:459
const DPoint & end() const
Returns the end point of the line.
Definition: geometry.h:444
DRect(const DRect &dr)
Copy constructor.
Definition: geometry.h:534
The namespace for all OGDF objects.
GenericPoint()
Creates a generic point.
Definition: geometry.h:85
const DRect & to() const
Returns the rectangle in the target coordinate system.
Definition: geometry.h:755
List< E > & operator=(const List< E > &L)
Assignment operator.
Definition: List.h:1268
const DPoint & p2() const
Returns the upper right point of the rectangle.
Definition: geometry.h:592
double dx() const
Returns the x-coordinate of the difference (end point - start point).
Definition: geometry.h:447
DPolygon(bool cc=true)
Creates an empty polygon.
Definition: geometry.h:828
DSegment(const DLine &dl)
Creates a line segment defined by the start and end point of line dl.
Definition: geometry.h:791
bool operator==(const GenericPoint &p) const
Equality operator.
Definition: geometry.h:101
DSegment(double x1, double y1, double x2, double y2)
Creates a line segment from (x1,y1) to (x2,y2).
Definition: geometry.h:794
DPoint()
Creates a real point (0,0).
Definition: geometry.h:223
DPoint m_end
The end point of the line.
Definition: geometry.h:403
double slope() const
Returns the slope of the line.
Definition: geometry.h:453
friend DPoint operator*(double c, const DPoint &p)
Definition: geometry.h:271
DPoint m_p2
The upper right point of the rectangle.
Definition: geometry.h:521
double det(const DSegment &segment) const
Determines if segment is left or right of this segment.
Definition: geometry.h:806
DPolyline(const DPolyline &dpl)
Copy constructor.
Definition: geometry.h:357
ListIterator< DPoint > insertPoint(const DPoint &p)
Inserts point p, that must lie on a polygon segment.
Definition: geometry.h:856
Line segments with real coordinates.
Definition: geometry.h:778
DPoint & operator-=(const DPoint &p)
Definition: geometry.h:253
Declaration of doubly linked lists and iterators.
MDMFLengthAttribute operator+(MDMFLengthAttribute x, const MDMFLengthAttribute &y)
const DLine leftLine() const
Returns the left side of the rectangle.
Definition: geometry.h:605
Edges are oriented from bottom to top.
bool operator!=(const GenericPoint &p) const
Inequality operator.
Definition: geometry.h:106
DPoint m_p1
The lower left point of the rectangle.
Definition: geometry.h:520
DPolyline & operator=(const DPolyline &dpl)
Assignment operator.
Definition: geometry.h:360
int orientation(const DPoint &p, const DPoint &q, const DPoint &r)