KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
line.h
1/**
2 * @brief A 2D line segment defined by two endpoints, with extensive geometric query support.
3 */
4#ifndef LINE_H
5#define LINE_H
6
7#include <QLineF>
8#include <QList>
9#include <QPoint>
10#include <QRect>
11
12#include "Kanoop/kanoopcommon.h"
13#include "flatgeo.h"
14#include "point.h"
15
16class QLineF;
17class QLine;
18class Circle;
19class Rectangle;
20
21/**
22 * @brief Represents a 2D line segment between two Point endpoints.
23 *
24 * Provides length, slope, bearing, midpoint, intersection, containment, and
25 * spatial relationship queries as well as movement and rotation transforms.
26 */
27class KANOOP_EXPORT Line
28{
29public:
30 /** @brief Default constructor — creates a zero-length line at the origin. */
31 Line() {}
32
33 /**
34 * @brief Construct a line from two integer points.
35 * @param p1 Start point
36 * @param p2 End point
37 */
38 Line(const QPoint& p1, const QPoint& p2) :
39 _p1(p1), _p2(p2) {}
40
41 /**
42 * @brief Construct a line from two floating-point points.
43 * @param p1 Start point
44 * @param p2 End point
45 */
46 Line(const QPointF& p1, const QPointF& p2) :
47 _p1(p1), _p2(p2) {}
48
49 /**
50 * @brief Construct a line from an origin point, bearing, and distance.
51 * @param origin Start point
52 * @param bearing Compass bearing in degrees
53 * @param distance Length of the line
54 */
55 Line(const QPointF& origin, double bearing, double distance);
56
57 /**
58 * @brief Construct a line from an origin point, cardinal direction, and distance.
59 * @param origin Start point
60 * @param direction Cardinal direction of travel
61 * @param distance Length of the line
62 */
63 Line(const QPointF& origin, Geo::Direction direction, double distance);
64
65 /**
66 * @brief Construct from a QLineF.
67 * @param other Source QLineF to copy endpoints from
68 */
69 Line(const QLineF& other) :
70 Line(other.p1(), other.p2()) {}
71
72 /**
73 * @brief Construct from a QLine.
74 * @param other Source QLine to copy endpoints from
75 */
76 Line(const QLine& other) :
77 Line(other.p1(), other.p2()) {}
78
79 /**
80 * @brief Equality comparison — endpoints must match exactly.
81 * @param other Line to compare against
82 * @return true if both endpoints match
83 */
84 bool operator ==(const Line& other) const { return _p1 == other._p1 && _p2 == other._p2; }
85 /**
86 * @brief Inequality comparison.
87 * @param other Line to compare against
88 * @return true if the lines differ
89 */
90 bool operator !=(const Line& other) const { return (*this == other) == false; }
91
92 /**
93 * @brief Parse a Line from a string produced by toString().
94 * @param value String representation
95 * @return Parsed Line
96 */
97 static Line fromString(const QString& value);
98
99 /**
100 * @brief Return the start point.
101 * @return Start Point
102 */
103 Point p1() const { return _p1; }
104
105 /**
106 * @brief Set the start point.
107 * @param value New start point
108 */
109 void setP1(const Point& value) { _p1 = value; }
110
111 /**
112 * @brief Return the end point.
113 * @return End Point
114 */
115 Point p2() const { return _p2; }
116
117 /**
118 * @brief Set the end point.
119 * @param value New end point
120 */
121 void setP2(const Point& value) { _p2 = value; }
122
123 /**
124 * @brief A list of Line objects with spatial query helpers.
125 */
126 class KANOOP_EXPORT List : public QList<Line>
127 {
128 public:
129 /** @brief Default constructor. */
130 List() : QList<Line>() {}
131
132 /**
133 * @brief Construct from a QList<Line>.
134 * @param other Source list to copy lines from
135 */
136 List(const QList<Line>& other) {
137 for(const Line& line : other) {
138 append(line);
139 }
140 }
141
142 /**
143 * @brief Build a list of lines connecting adjacent points in a QList<QPoint>.
144 * @param points List of integer points
145 * @return List of lines connecting consecutive points
146 */
147 static List fromPoints(const QList<QPoint>& points);
148
149 /**
150 * @brief Build a list of lines connecting adjacent points in a QList<QPointF>.
151 * @param points List of floating-point points
152 * @return List of lines connecting consecutive points
153 */
154 static List fromPoints(const QList<QPointF>& points);
155
156 /**
157 * @brief Parse a List from a string produced by toString().
158 * @param value String representation
159 * @return Parsed List
160 */
161 static List fromString(const QString& value);
162
163 /** @brief Return the longest horizontal line in the list.
164 * @return Longest horizontal Line */
166 /** @brief Return the longest vertical line in the list.
167 * @return Longest vertical Line */
169
170 /**
171 * @brief Test whether the list contains a line with the same two endpoints.
172 * @param line Line to search for
173 * @return true if a matching line is found
174 */
175 bool containsLineWithSameEndpoints(const Line& line) const;
176
177 /** @brief Return the line with the smallest Y start or end coordinate.
178 * @return Highest Line */
179 Line highest() const;
180 /** @brief Return the line with the largest Y start or end coordinate.
181 * @return Lowest Line */
182 Line lowest() const;
183 /** @brief Return the shortest line in the list.
184 * @return Shortest Line */
185 Line shortest() const;
186 /** @brief Return the longest line in the list.
187 * @return Longest Line */
188 Line longest() const;
189
190 /**
191 * @brief Return the point on any line closest to the given point.
192 * @param other Reference point
193 * @return Closest point on any line
194 */
195 QPointF closestPointTo(const QPointF& other);
196
197 /**
198 * @brief Return the closest point, and output which line and distance produced it.
199 * @param other Reference point
200 * @param closestLine Output set to the line containing the closest point
201 * @param closestDistance Output set to the distance to the closest point
202 * @return Closest point on any line
203 */
204 QPointF closestPointTo(const QPointF& other, Line& closestLine, double &closestDistance);
205
206 /** @brief Return the minimum X coordinate across all line endpoints.
207 * @return Minimum X value */
208 double minX() const;
209 /** @brief Return the maximum X coordinate across all line endpoints.
210 * @return Maximum X value */
211 double maxX() const;
212 /** @brief Return the minimum Y coordinate across all line endpoints.
213 * @return Minimum Y value */
214 double minY() const;
215 /** @brief Return the maximum Y coordinate across all line endpoints.
216 * @return Maximum Y value */
217 double maxY() const;
218
219 /** @brief Return the bounding rectangle of all lines in the list.
220 * @return Bounding Rectangle */
222
223 /**
224 * @brief Return the first line that contains the given point.
225 * @param point Point to search for
226 * @return Matching line, or an invalid line if not found
227 */
228 Line lineContainingPoint(const Point& point) const;
229
230 /**
231 * @brief Return the first line near the given point within a margin.
232 * @param point Reference point
233 * @param margin Maximum allowed distance
234 * @return Nearby line, or an invalid line if not found
235 */
236 Line lineNearPoint(const Point& point, int margin) const;
237
238 /** @brief Return the total combined length of all lines.
239 * @return Sum of all line lengths */
240 double totalLength() const;
241
242 /**
243 * @brief Move all lines by the given delta.
244 * @param dx Horizontal displacement
245 * @param dy Vertical displacement
246 * @return Reference to this list
247 */
248 List &moveDelta(double dx, double dy);
249
250 /** @brief Convert all lines to a list of QLineF objects.
251 * @return QList of QLineF */
252 QList<QLineF> toQLineFList() const;
253 /** @brief Convert all lines to a list of QLine objects.
254 * @return QList of QLine */
255 QList<QLine> toQLineList() const;
256
257 /** @brief Format the list as a human-readable string.
258 * @return String representation */
259 QString toString() const;
260 };
261
262 /** @brief Return the midpoint of this line.
263 * @return Midpoint */
265 /** @brief Return the length (Euclidean distance between endpoints).
266 * @return Length of the line */
267 double length() const;
268 /** @brief Return the slope (rise/run), or infinity for vertical lines.
269 * @return Slope value */
270 double slope() const;
271 /** @brief Return the Y-intercept of the line's equation.
272 * @return Y-intercept */
273 double intercept() const;
274 /** @brief Test whether this line is exactly vertical.
275 * @return true if vertical */
276 bool isVertical() const;
277 /** @brief Test whether this line is exactly horizontal.
278 * @return true if horizontal */
279 bool isHorizontal() const;
280 /** @brief Return the compass bearing from p1 to p2, in degrees.
281 * @return Bearing in degrees */
282 double bearing() const;
283 /** @brief Return the angle of this line as an Angle object.
284 * @return Angle of the line */
285 Angle angle() const;
286
287 /**
288 * @brief Return the perpendicular distance from this line to a point.
289 * @param to Point to measure distance from
290 * @return Perpendicular distance
291 */
292 double distanceTo(const QPointF& to) const;
293
294 /**
295 * @brief Return the point on this line closest to the given point.
296 * @param point Reference point
297 * @return Closest Point on this line segment
298 */
299 Point closestPointTo(const QPointF& point) const;
300
301 /**
302 * @brief Return the closest point and output the distance.
303 * @param point Reference point
304 * @param distance Output set to the distance
305 * @return Closest Point on this line segment
306 */
307 Point closestPointTo(const QPointF& point, double& distance) const;
308
309 /**
310 * @brief Return the endpoint furthest from the given point.
311 * @param point Reference point
312 * @return The furthest of p1 and p2
313 */
314 Point furthestPointFrom(const QPointF& point) const;
315
316 /** @brief Return the endpoint with the smallest Y coordinate.
317 * @return Top-most Point */
319 /** @brief Return the endpoint with the largest Y coordinate.
320 * @return Bottom-most Point */
322 /** @brief Return the endpoint with the smallest X coordinate.
323 * @return Left-most Point */
325 /** @brief Return the endpoint with the largest X coordinate.
326 * @return Right-most Point */
328
329 /**
330 * @brief Test whether the line spans an X range.
331 * @param x1 First X boundary
332 * @param x2 Second X boundary
333 * @return true if any part of the line falls between x1 and x2
334 */
335 bool hasXBetween(double x1, double x2) const;
336
337 /**
338 * @brief Test whether the line crosses a specific X coordinate.
339 * @param x X coordinate to test
340 * @return true if the line crosses x
341 */
342 bool crossesX(double x) const;
343
344 /**
345 * @brief Test whether the line spans a Y range.
346 * @param y1 First Y boundary
347 * @param y2 Second Y boundary
348 * @return true if any part of the line falls between y1 and y2
349 */
350 bool hasYBetween(double y1, double y2) const;
351
352 /**
353 * @brief Test whether the line crosses a specific Y coordinate.
354 * @param y Y coordinate to test
355 * @return true if the line crosses y
356 */
357 bool crossesY(double y) const;
358
359 /**
360 * @brief Test whether this line intersects another.
361 * @param other Line to test against
362 * @return true if the segments intersect
363 */
364 bool intersects(const Line& other) const;
365
366 /**
367 * @brief Test whether this line intersects another and output the intersection point.
368 * @param other Line to test against
369 * @param intersection Output set to the intersection point
370 * @return true if the segments intersect
371 */
372 bool intersects(const Line& other, Point &intersection) const;
373
374 /**
375 * @brief Test whether this line intersects a circle.
376 * @param other Circle to test against
377 * @return true if the line intersects or is tangent to the circle
378 */
379 bool intersects(const Circle& other) const;
380
381 /**
382 * @brief Test whether this line intersects a rectangle.
383 * @param other Rectangle to test against
384 * @return true if the line intersects the rectangle boundary
385 */
386 bool intersects(const QRectF &other) const;
387
388 /**
389 * @brief Compute the intersection point with another line.
390 * @param other Line to intersect with
391 * @return Intersection point (may be invalid if lines are parallel)
392 */
393 Point intersection(const Line& other) const;
394
395 /**
396 * @brief Test whether this line is entirely to the left of other.
397 * @param other Line to compare against
398 * @return true if this line is entirely to the left
399 */
400 bool isLeftOf(const Line& other) const;
401 /**
402 * @brief Test whether this line is entirely to the right of other.
403 * @param other Line to compare against
404 * @return true if this line is entirely to the right
405 */
406 bool isRightOf(const Line& other) const;
407 /**
408 * @brief Test whether this line is entirely above other.
409 * @param other Line to compare against
410 * @return true if this line is entirely above
411 */
412 bool isAbove(const Line& other) const;
413 /**
414 * @brief Test whether this line is entirely below other.
415 * @param other Line to compare against
416 * @return true if this line is entirely below
417 */
418 bool isBelow(const Line& other) const;
419 /** @brief Test whether this line is perpendicular (horizontal or vertical).
420 * @return true if the line is horizontal or vertical */
421 bool isPerpendicular() const;
422 /**
423 * @brief Test whether this line shares an axis with other (both horizontal or both vertical).
424 * @param other Line to compare against
425 * @return true if both lines share the same axis
426 */
427 bool sharesAxisWith(const Line& other) const;
428
429 /**
430 * @brief Test whether this line shares an endpoint with other within a tolerance.
431 * @param other Line to compare
432 * @param maxDistance Maximum endpoint distance to consider shared (default 0 = exact)
433 * @return true if any endpoint pair is within maxDistance of each other
434 */
435 bool sharesEndpointWith(const Line& other, double maxDistance = 0) const;
436
437 /**
438 * @brief Test whether this line has exactly the same two endpoints as other.
439 * @param other Line to compare against
440 * @return true if both endpoints match in either order
441 */
442 bool sharesSameEndpoints(const Line& other) const;
443
444 /**
445 * @brief Test whether a point is an endpoint of this line.
446 * @param point Point to test
447 * @param precision Decimal places for comparison (0 = integer)
448 * @return true if point matches p1 or p2 within precision
449 */
450 bool isEndpoint(const QPointF& point, int precision = 0) const;
451
452 /**
453 * @brief Test whether a point lies on this line segment.
454 * @param point Point to test
455 * @return true if point lies on the segment
456 */
457 bool containsPoint(const QPointF& point) const;
458
459 /**
460 * @brief Shorten this line by removing length from the far end.
461 * @param howMuch Amount to remove
462 * @return Reference to this line
463 */
464 Line& shorten(double howMuch);
465
466 /**
467 * @brief Extend this line by adding length at the far end.
468 * @param howMuch Amount to add
469 * @return Reference to this line
470 */
471 Line& extend(double howMuch);
472
473 /**
474 * @brief Grow this line symmetrically by adding length at both ends.
475 * @param howMuch Amount to add at each end
476 * @return Reference to this line
477 */
478 Line& grow(double howMuch);
479
480 /** @brief Return the cardinal direction of this line.
481 * @return Cardinal direction */
483
484 /** @brief Return the minimum X coordinate of the two endpoints.
485 * @return Minimum X value */
486 double minX() const;
487 /** @brief Return the maximum X coordinate of the two endpoints.
488 * @return Maximum X value */
489 double maxX() const;
490 /** @brief Return the minimum Y coordinate of the two endpoints.
491 * @return Minimum Y value */
492 double minY() const;
493 /** @brief Return the maximum Y coordinate of the two endpoints.
494 * @return Maximum Y value */
495 double maxY() const;
496
497 /** @brief Return a list containing both endpoints.
498 * @return Point::List with p1 and p2 */
500
501 /** @brief Round both endpoints to integer coordinates in place.
502 * @return Reference to this line */
504
505 /**
506 * @brief Create a rectangle of the given width centred on this line.
507 * @param expandedWidth Width of the resulting rectangle
508 * @return Rectangle enclosing the line
509 */
510 Rectangle makeRectangle(int expandedWidth) const;
511
512 /**
513 * @brief Return vertical lines along the left and right edges of a rectangle.
514 * @param rect Rectangle to extract edges from
515 * @return List of vertical edge lines
516 */
517 static List verticalLines(const QRectF& rect);
518
519 /**
520 * @brief Return horizontal lines along the top and bottom edges of a rectangle.
521 * @param rect Rectangle to extract edges from
522 * @return List of horizontal edge lines
523 */
524 static List horizontalLines(const QRectF& rect);
525
526 /**
527 * @brief Move this line by bearing and distance.
528 * @param bearing Direction of movement in degrees
529 * @param distance Distance to move
530 * @return Reference to this line
531 */
532 Line& move(double bearing, double distance);
533
534 /**
535 * @brief Move this line in a cardinal direction by a distance.
536 * @param direction Cardinal direction
537 * @param distance Distance to move
538 * @return Reference to this line
539 */
540 Line& move(Geo::Direction direction, double distance);
541
542 /**
543 * @brief Translate this line by a (dx, dy) delta.
544 * @param dx Horizontal displacement
545 * @param dy Vertical displacement
546 * @return Reference to this line
547 */
548 Line& moveDelta(double dx, double dy);
549
550 /**
551 * @brief Rotate this line around a centroid by an angle.
552 * @param centroid Centre of rotation
553 * @param angle Rotation angle in degrees
554 * @return Reference to this line
555 */
556 Line &rotate(const Point& centroid, double angle);
557
558 /** @brief Convert to a QLine (integer endpoints).
559 * @return QLine equivalent */
560 QLine toQLine() const;
561 /** @brief Convert to a QLineF (floating-point endpoints).
562 * @return QLineF equivalent */
563 QLineF toQLineF() const;
564
565 /** @brief Format this line as a human-readable string.
566 * @return String representation */
567 QString toString() const;
568
569 /**
570 * @brief Test whether this line has non-zero length.
571 * @return true if length() != 0
572 */
573 bool isValid() const { return length() != 0; }
574
575private:
576 Point _p1;
577 Point _p2;
578
579 /** @brief Test whether a value lies between v1 and v2 (inclusive). */
580 static inline bool isBetween(double value, double v1, double v2)
581 {
582 return value >= v1 && value <= v2;
583 }
584};
585
586#endif // LINE_H
A compass bearing angle measured in degrees, with wraparound arithmetic.
Definition angle.h:17
Represents a 2D circle with centre and radius, supporting geometric queries.
Definition circle.h:17
A list of Line objects with spatial query helpers.
Definition line.h:127
QPointF closestPointTo(const QPointF &other)
Return the point on any line closest to the given point.
List()
Default constructor.
Definition line.h:130
bool containsLineWithSameEndpoints(const Line &line) const
Test whether the list contains a line with the same two endpoints.
Line highest() const
Return the line with the smallest Y start or end coordinate.
QString toString() const
Format the list as a human-readable string.
double maxX() const
Return the maximum X coordinate across all line endpoints.
double totalLength() const
Return the total combined length of all lines.
Line lineNearPoint(const Point &point, int margin) const
Return the first line near the given point within a margin.
Rectangle boundingRectangle() const
Return the bounding rectangle of all lines in the list.
List(const QList< Line > &other)
Construct from a QList<Line>.
Definition line.h:136
double maxY() const
Return the maximum Y coordinate across all line endpoints.
QList< QLineF > toQLineFList() const
Convert all lines to a list of QLineF objects.
Line longestVerticalLine()
Return the longest vertical line in the list.
Line lowest() const
Return the line with the largest Y start or end coordinate.
static List fromString(const QString &value)
Parse a List from a string produced by toString().
double minY() const
Return the minimum Y coordinate across all line endpoints.
List & moveDelta(double dx, double dy)
Move all lines by the given delta.
Line longestHorizontalLine()
Return the longest horizontal line in the list.
Line lineContainingPoint(const Point &point) const
Return the first line that contains the given point.
QList< QLine > toQLineList() const
Convert all lines to a list of QLine objects.
static List fromPoints(const QList< QPointF > &points)
Build a list of lines connecting adjacent points in a QList<QPointF>.
double minX() const
Return the minimum X coordinate across all line endpoints.
Line longest() const
Return the longest line in the list.
static List fromPoints(const QList< QPoint > &points)
Build a list of lines connecting adjacent points in a QList<QPoint>.
QPointF closestPointTo(const QPointF &other, Line &closestLine, double &closestDistance)
Return the closest point, and output which line and distance produced it.
Line shortest() const
Return the shortest line in the list.
Represents a 2D line segment between two Point endpoints.
Definition line.h:28
Point bottomMostPoint() const
Return the endpoint with the largest Y coordinate.
double maxY() const
Return the maximum Y coordinate of the two endpoints.
Angle angle() const
Return the angle of this line as an Angle object.
Point midpoint() const
Return the midpoint of this line.
bool isRightOf(const Line &other) const
Test whether this line is entirely to the right of other.
Line & round()
Round both endpoints to integer coordinates in place.
Line(const QPointF &origin, double bearing, double distance)
Construct a line from an origin point, bearing, and distance.
double minX() const
Return the minimum X coordinate of the two endpoints.
Line & extend(double howMuch)
Extend this line by adding length at the far end.
bool intersects(const Line &other) const
Test whether this line intersects another.
Line & move(double bearing, double distance)
Move this line by bearing and distance.
Line(const QLine &other)
Construct from a QLine.
Definition line.h:76
Point::List points() const
Return a list containing both endpoints.
QString toString() const
Format this line as a human-readable string.
Point p2() const
Return the end point.
Definition line.h:115
double bearing() const
Return the compass bearing from p1 to p2, in degrees.
bool isAbove(const Line &other) const
Test whether this line is entirely above other.
Point p1() const
Return the start point.
Definition line.h:103
QLineF toQLineF() const
Convert to a QLineF (floating-point endpoints).
Point leftMostPoint() const
Return the endpoint with the smallest X coordinate.
Point furthestPointFrom(const QPointF &point) const
Return the endpoint furthest from the given point.
bool hasYBetween(double y1, double y2) const
Test whether the line spans a Y range.
bool isEndpoint(const QPointF &point, int precision=0) const
Test whether a point is an endpoint of this line.
static Line fromString(const QString &value)
Parse a Line from a string produced by toString().
bool isVertical() const
Test whether this line is exactly vertical.
Line(const QLineF &other)
Construct from a QLineF.
Definition line.h:69
bool crossesY(double y) const
Test whether the line crosses a specific Y coordinate.
double intercept() const
Return the Y-intercept of the line's equation.
bool intersects(const Line &other, Point &intersection) const
Test whether this line intersects another and output the intersection point.
bool isHorizontal() const
Test whether this line is exactly horizontal.
bool isValid() const
Test whether this line has non-zero length.
Definition line.h:573
bool hasXBetween(double x1, double x2) const
Test whether the line spans an X range.
bool sharesAxisWith(const Line &other) const
Test whether this line shares an axis with other (both horizontal or both vertical).
static List verticalLines(const QRectF &rect)
Return vertical lines along the left and right edges of a rectangle.
bool sharesEndpointWith(const Line &other, double maxDistance=0) const
Test whether this line shares an endpoint with other within a tolerance.
Line(const QPointF &p1, const QPointF &p2)
Construct a line from two floating-point points.
Definition line.h:46
bool intersects(const Circle &other) const
Test whether this line intersects a circle.
double minY() const
Return the minimum Y coordinate of the two endpoints.
QLine toQLine() const
Convert to a QLine (integer endpoints).
double length() const
Return the length (Euclidean distance between endpoints).
static List horizontalLines(const QRectF &rect)
Return horizontal lines along the top and bottom edges of a rectangle.
double maxX() const
Return the maximum X coordinate of the two endpoints.
Point topMostPoint() const
Return the endpoint with the smallest Y coordinate.
Point closestPointTo(const QPointF &point, double &distance) const
Return the closest point and output the distance.
Point rightMostPoint() const
Return the endpoint with the largest X coordinate.
bool sharesSameEndpoints(const Line &other) const
Test whether this line has exactly the same two endpoints as other.
Line & moveDelta(double dx, double dy)
Translate this line by a (dx, dy) delta.
bool intersects(const QRectF &other) const
Test whether this line intersects a rectangle.
bool isPerpendicular() const
Test whether this line is perpendicular (horizontal or vertical).
Line & move(Geo::Direction direction, double distance)
Move this line in a cardinal direction by a distance.
Line & shorten(double howMuch)
Shorten this line by removing length from the far end.
Geo::Direction direction() const
Return the cardinal direction of this line.
Line(const QPoint &p1, const QPoint &p2)
Construct a line from two integer points.
Definition line.h:38
Rectangle makeRectangle(int expandedWidth) const
Create a rectangle of the given width centred on this line.
Line()
Default constructor — creates a zero-length line at the origin.
Definition line.h:31
Line & grow(double howMuch)
Grow this line symmetrically by adding length at both ends.
Line(const QPointF &origin, Geo::Direction direction, double distance)
Construct a line from an origin point, cardinal direction, and distance.
Point intersection(const Line &other) const
Compute the intersection point with another line.
bool isBelow(const Line &other) const
Test whether this line is entirely below other.
void setP1(const Point &value)
Set the start point.
Definition line.h:109
double distanceTo(const QPointF &to) const
Return the perpendicular distance from this line to a point.
bool containsPoint(const QPointF &point) const
Test whether a point lies on this line segment.
double slope() const
Return the slope (rise/run), or infinity for vertical lines.
Line & rotate(const Point &centroid, double angle)
Rotate this line around a centroid by an angle.
bool crossesX(double x) const
Test whether the line crosses a specific X coordinate.
void setP2(const Point &value)
Set the end point.
Definition line.h:121
bool isLeftOf(const Line &other) const
Test whether this line is entirely to the left of other.
Point closestPointTo(const QPointF &point) const
Return the point on this line closest to the given point.
A list of Point objects with corner-finding helpers.
Definition point.h:110
A 2D floating-point point extending QPointF with movement and spatial query methods.
Definition point.h:16
A 2D rectangle extending QRectF with edge, corner, and geometric query helpers.
Definition rectangle.h:16
Direction
Cardinal directions, aliased to the corresponding Side values.
Definition geo.h:37