|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
Represents a 2D line segment between two Point endpoints. More...
#include <line.h>
Classes | |
| class | List |
| A list of Line objects with spatial query helpers. More... | |
Public Member Functions | |
| Line () | |
| Default constructor — creates a zero-length line at the origin. | |
| Line (const QPoint &p1, const QPoint &p2) | |
| Construct a line from two integer points. | |
| Line (const QPointF &p1, const QPointF &p2) | |
| Construct a line from two floating-point points. | |
| Line (const QPointF &origin, double bearing, double distance) | |
| Construct a line from an origin point, bearing, and distance. | |
| Line (const QPointF &origin, Geo::Direction direction, double distance) | |
| Construct a line from an origin point, cardinal direction, and distance. | |
| Line (const QLineF &other) | |
| Construct from a QLineF. | |
| Line (const QLine &other) | |
| Construct from a QLine. | |
| bool | operator== (const Line &other) const |
| Equality comparison — endpoints must match exactly. | |
| bool | operator!= (const Line &other) const |
| Inequality comparison. | |
| Point | p1 () const |
| Return the start point. | |
| void | setP1 (const Point &value) |
| Set the start point. | |
| Point | p2 () const |
| Return the end point. | |
| void | setP2 (const Point &value) |
| Set the end point. | |
| Point | midpoint () const |
| Return the midpoint of this line. | |
| double | length () const |
| Return the length (Euclidean distance between endpoints). | |
| double | slope () const |
| Return the slope (rise/run), or infinity for vertical lines. | |
| double | intercept () const |
| Return the Y-intercept of the line's equation. | |
| bool | isVertical () const |
| Test whether this line is exactly vertical. | |
| bool | isHorizontal () const |
| Test whether this line is exactly horizontal. | |
| double | bearing () const |
| Return the compass bearing from p1 to p2, in degrees. | |
| Angle | angle () const |
| Return the angle of this line as an Angle object. | |
| double | distanceTo (const QPointF &to) const |
| Return the perpendicular distance from this line to a point. | |
| Point | closestPointTo (const QPointF &point) const |
| Return the point on this line closest to the given point. | |
| Point | closestPointTo (const QPointF &point, double &distance) const |
| Return the closest point and output the distance. | |
| Point | furthestPointFrom (const QPointF &point) const |
| Return the endpoint furthest from the given point. | |
| Point | topMostPoint () const |
| Return the endpoint with the smallest Y coordinate. | |
| Point | bottomMostPoint () const |
| Return the endpoint with the largest Y coordinate. | |
| Point | leftMostPoint () const |
| Return the endpoint with the smallest X coordinate. | |
| Point | rightMostPoint () const |
| Return the endpoint with the largest X coordinate. | |
| bool | hasXBetween (double x1, double x2) const |
| Test whether the line spans an X range. | |
| bool | crossesX (double x) const |
| Test whether the line crosses a specific X coordinate. | |
| bool | hasYBetween (double y1, double y2) const |
| Test whether the line spans a Y range. | |
| bool | crossesY (double y) const |
| Test whether the line crosses a specific Y coordinate. | |
| bool | intersects (const Line &other) const |
| Test whether this line intersects another. | |
| bool | intersects (const Line &other, Point &intersection) const |
| Test whether this line intersects another and output the intersection point. | |
| bool | intersects (const Circle &other) const |
| Test whether this line intersects a circle. | |
| bool | intersects (const QRectF &other) const |
| Test whether this line intersects a rectangle. | |
| Point | intersection (const Line &other) const |
| Compute the intersection point with another line. | |
| bool | isLeftOf (const Line &other) const |
| Test whether this line is entirely to the left of other. | |
| bool | isRightOf (const Line &other) const |
| Test whether this line is entirely to the right of other. | |
| bool | isAbove (const Line &other) const |
| Test whether this line is entirely above other. | |
| bool | isBelow (const Line &other) const |
| Test whether this line is entirely below other. | |
| bool | isPerpendicular () const |
| Test whether this line is perpendicular (horizontal or vertical). | |
| bool | sharesAxisWith (const Line &other) const |
| Test whether this line shares an axis with other (both horizontal or both vertical). | |
| bool | sharesEndpointWith (const Line &other, double maxDistance=0) const |
| Test whether this line shares an endpoint with other within a tolerance. | |
| bool | sharesSameEndpoints (const Line &other) const |
| Test whether this line has exactly the same two endpoints as other. | |
| bool | isEndpoint (const QPointF &point, int precision=0) const |
| Test whether a point is an endpoint of this line. | |
| bool | containsPoint (const QPointF &point) const |
| Test whether a point lies on this line segment. | |
| Line & | shorten (double howMuch) |
| Shorten this line by removing length from the far end. | |
| Line & | extend (double howMuch) |
| Extend this line by adding length at the far end. | |
| Line & | grow (double howMuch) |
| Grow this line symmetrically by adding length at both ends. | |
| Geo::Direction | direction () const |
| Return the cardinal direction of this line. | |
| double | minX () const |
| Return the minimum X coordinate of the two endpoints. | |
| double | maxX () const |
| Return the maximum X coordinate of the two endpoints. | |
| double | minY () const |
| Return the minimum Y coordinate of the two endpoints. | |
| double | maxY () const |
| Return the maximum Y coordinate of the two endpoints. | |
| Point::List | points () const |
| Return a list containing both endpoints. | |
| Line & | round () |
| Round both endpoints to integer coordinates in place. | |
| Rectangle | makeRectangle (int expandedWidth) const |
| Create a rectangle of the given width centred on this line. | |
| Line & | move (double bearing, double distance) |
| Move this line by bearing and distance. | |
| Line & | move (Geo::Direction direction, double distance) |
| Move this line in a cardinal direction by a distance. | |
| Line & | moveDelta (double dx, double dy) |
| Translate this line by a (dx, dy) delta. | |
| Line & | rotate (const Point ¢roid, double angle) |
| Rotate this line around a centroid by an angle. | |
| QLine | toQLine () const |
| Convert to a QLine (integer endpoints). | |
| QLineF | toQLineF () const |
| Convert to a QLineF (floating-point endpoints). | |
| QString | toString () const |
| Format this line as a human-readable string. | |
| bool | isValid () const |
| Test whether this line has non-zero length. | |
Static Public Member Functions | |
| static Line | fromString (const QString &value) |
| Parse a Line from a string produced by toString(). | |
| static List | verticalLines (const QRectF &rect) |
| Return vertical lines along the left and right edges of a rectangle. | |
| static List | horizontalLines (const QRectF &rect) |
| Return horizontal lines along the top and bottom edges of a rectangle. | |
Represents a 2D line segment between two Point endpoints.
Provides length, slope, bearing, midpoint, intersection, containment, and spatial relationship queries as well as movement and rotation transforms.
|
inline |
|
inline |
|
inline |
| Line::Line | ( | const QPointF & | origin, |
| double | bearing, | ||
| double | distance | ||
| ) |
Construct a line from an origin point, bearing, and distance.
| origin | Start point |
| bearing | Compass bearing in degrees |
| distance | Length of the line |
| Line::Line | ( | const QPointF & | origin, |
| Geo::Direction | direction, | ||
| double | distance | ||
| ) |
Construct a line from an origin point, cardinal direction, and distance.
| origin | Start point |
| direction | Cardinal direction of travel |
| distance | Length of the line |
|
inline |
|
inline |
| Angle Line::angle | ( | ) | const |
| double Line::bearing | ( | ) | const |
Return the compass bearing from p1 to p2, in degrees.
| Point Line::bottomMostPoint | ( | ) | const |
Return the endpoint with the largest Y coordinate.
| Point Line::closestPointTo | ( | const QPointF & | point | ) | const |
Return the point on this line closest to the given point.
| point | Reference point |
| Point Line::closestPointTo | ( | const QPointF & | point, |
| double & | distance | ||
| ) | const |
Return the closest point and output the distance.
| point | Reference point |
| distance | Output set to the distance |
| bool Line::containsPoint | ( | const QPointF & | point | ) | const |
Test whether a point lies on this line segment.
| point | Point to test |
| bool Line::crossesX | ( | double | x | ) | const |
Test whether the line crosses a specific X coordinate.
| x | X coordinate to test |
| bool Line::crossesY | ( | double | y | ) | const |
Test whether the line crosses a specific Y coordinate.
| y | Y coordinate to test |
| Geo::Direction Line::direction | ( | ) | const |
Return the cardinal direction of this line.
| double Line::distanceTo | ( | const QPointF & | to | ) | const |
Return the perpendicular distance from this line to a point.
| to | Point to measure distance from |
| Line & Line::extend | ( | double | howMuch | ) |
Extend this line by adding length at the far end.
| howMuch | Amount to add |
|
static |
Parse a Line from a string produced by toString().
| value | String representation |
| Point Line::furthestPointFrom | ( | const QPointF & | point | ) | const |
Return the endpoint furthest from the given point.
| point | Reference point |
| Line & Line::grow | ( | double | howMuch | ) |
Grow this line symmetrically by adding length at both ends.
| howMuch | Amount to add at each end |
| bool Line::hasXBetween | ( | double | x1, |
| double | x2 | ||
| ) | const |
Test whether the line spans an X range.
| x1 | First X boundary |
| x2 | Second X boundary |
| bool Line::hasYBetween | ( | double | y1, |
| double | y2 | ||
| ) | const |
Test whether the line spans a Y range.
| y1 | First Y boundary |
| y2 | Second Y boundary |
|
static |
| double Line::intercept | ( | ) | const |
Return the Y-intercept of the line's equation.
Compute the intersection point with another line.
| other | Line to intersect with |
| bool Line::intersects | ( | const Circle & | other | ) | const |
Test whether this line intersects a circle.
| other | Circle to test against |
| bool Line::intersects | ( | const Line & | other | ) | const |
Test whether this line intersects another.
| other | Line to test against |
Test whether this line intersects another and output the intersection point.
| other | Line to test against |
| intersection | Output set to the intersection point |
| bool Line::intersects | ( | const QRectF & | other | ) | const |
Test whether this line intersects a rectangle.
| other | Rectangle to test against |
| bool Line::isAbove | ( | const Line & | other | ) | const |
Test whether this line is entirely above other.
| other | Line to compare against |
| bool Line::isBelow | ( | const Line & | other | ) | const |
Test whether this line is entirely below other.
| other | Line to compare against |
| bool Line::isEndpoint | ( | const QPointF & | point, |
| int | precision = 0 |
||
| ) | const |
Test whether a point is an endpoint of this line.
| point | Point to test |
| precision | Decimal places for comparison (0 = integer) |
| bool Line::isHorizontal | ( | ) | const |
Test whether this line is exactly horizontal.
| bool Line::isLeftOf | ( | const Line & | other | ) | const |
Test whether this line is entirely to the left of other.
| other | Line to compare against |
| bool Line::isPerpendicular | ( | ) | const |
Test whether this line is perpendicular (horizontal or vertical).
| bool Line::isRightOf | ( | const Line & | other | ) | const |
Test whether this line is entirely to the right of other.
| other | Line to compare against |
|
inline |
| bool Line::isVertical | ( | ) | const |
Test whether this line is exactly vertical.
| Point Line::leftMostPoint | ( | ) | const |
Return the endpoint with the smallest X coordinate.
| double Line::length | ( | ) | const |
Return the length (Euclidean distance between endpoints).
| Rectangle Line::makeRectangle | ( | int | expandedWidth | ) | const |
Create a rectangle of the given width centred on this line.
| expandedWidth | Width of the resulting rectangle |
| double Line::maxX | ( | ) | const |
Return the maximum X coordinate of the two endpoints.
| double Line::maxY | ( | ) | const |
Return the maximum Y coordinate of the two endpoints.
| Point Line::midpoint | ( | ) | const |
Return the midpoint of this line.
| double Line::minX | ( | ) | const |
Return the minimum X coordinate of the two endpoints.
| double Line::minY | ( | ) | const |
Return the minimum Y coordinate of the two endpoints.
| Line & Line::move | ( | double | bearing, |
| double | distance | ||
| ) |
Move this line by bearing and distance.
| bearing | Direction of movement in degrees |
| distance | Distance to move |
| Line & Line::move | ( | Geo::Direction | direction, |
| double | distance | ||
| ) |
Move this line in a cardinal direction by a distance.
| direction | Cardinal direction |
| distance | Distance to move |
| Line & Line::moveDelta | ( | double | dx, |
| double | dy | ||
| ) |
Translate this line by a (dx, dy) delta.
| dx | Horizontal displacement |
| dy | Vertical displacement |
|
inline |
|
inline |
|
inline |
|
inline |
| Point::List Line::points | ( | ) | const |
Return a list containing both endpoints.
| Point Line::rightMostPoint | ( | ) | const |
Return the endpoint with the largest X coordinate.
Rotate this line around a centroid by an angle.
| centroid | Centre of rotation |
| angle | Rotation angle in degrees |
| Line & Line::round | ( | ) |
Round both endpoints to integer coordinates in place.
|
inline |
|
inline |
| bool Line::sharesAxisWith | ( | const Line & | other | ) | const |
Test whether this line shares an axis with other (both horizontal or both vertical).
| other | Line to compare against |
| bool Line::sharesEndpointWith | ( | const Line & | other, |
| double | maxDistance = 0 |
||
| ) | const |
Test whether this line shares an endpoint with other within a tolerance.
| other | Line to compare |
| maxDistance | Maximum endpoint distance to consider shared (default 0 = exact) |
| bool Line::sharesSameEndpoints | ( | const Line & | other | ) | const |
Test whether this line has exactly the same two endpoints as other.
| other | Line to compare against |
| Line & Line::shorten | ( | double | howMuch | ) |
Shorten this line by removing length from the far end.
| howMuch | Amount to remove |
| double Line::slope | ( | ) | const |
Return the slope (rise/run), or infinity for vertical lines.
| Point Line::topMostPoint | ( | ) | const |
Return the endpoint with the smallest Y coordinate.
| QLine Line::toQLine | ( | ) | const |
Convert to a QLine (integer endpoints).
| QLineF Line::toQLineF | ( | ) | const |
Convert to a QLineF (floating-point endpoints).
| QString Line::toString | ( | ) | const |
Format this line as a human-readable string.
|
static |