Class: QgsGeometryUtilsBase

class qgis.core.QgsGeometryUtilsBase

Bases: sip.wrapper

Convenience functions for geometry utils.

Added in version 3.34:

Methods

angleBetweenThreePoints

Calculates the angle between the lines AB and BC, where AB and BC described by points a, b and b, c.

angleBisector

Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX, bY) (dX, dY).

angleOnCircle

Returns True if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3.

averageAngle

Calculates the average angle (in radians) between the two linear segments from (x1, y1) to (x2, y2) and (x2, y2) to (x3, y3).

azimuth

Calculates Cartesian azimuth between points (x1, y1) and (x2, y2) (clockwise in degree, starting from north)

bisector

Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX, bY) (cX, cY).

ccwAngle

Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0

circleAngleBetween

Returns True if, in a circle, angle is between angle1 and angle2

circleCenterRadius

Returns radius and center of the circle through (x1 y1), (x2 y2), (x3 y3)

circleClockwise

Returns True if the circle defined by three angles is ordered clockwise.

circleLength

Length of a circular string segment defined by pt1, pt2, pt3

closestSideOfRectangle

Returns a number representing the closest side of a rectangle defined by /a right, bottom, left, top to the point at (x, y), where the point may be in the interior of the rectangle or outside it.

distance2D

Returns the 2D distance between (x1, y1) and (x2, y2).

distance3D

Returns the 3D distance between (x1, y1), (x2, y2) and (z2, z2).

interpolateArcValue

Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different angles (a1, a2, a3).

leftOfLine

Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).

lineAngle

Calculates the direction of line joining two points in radians, clockwise from the north direction.

lineIntersection

Computes the intersection between two lines.

linePerpendicularAngle

Calculates the perpendicular angle to a line joining two points.

linesIntersection3D

An algorithm to calculate an (approximate) intersection of two lines in 3D.

normalizedAngle

Ensures that an angle is in the range 0 <= angle < 2 pi.

perpendicularCenterSegment

Create a perpendicular line segment to a given segment [segmentPoint1,``segmentPoint2``] with its center at centerPoint.

perpendicularOffsetPointAlongSegment

Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2, y2), offset from the segment by the specified offset amount.

pointFractionAlongLine

Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at which the point lies.

pointsAreCollinear

Given the points (x1, y1), (x2, y2) and (x3, y3) returns True if these points can be considered collinear with a specified tolerance epsilon.

project

Returns coordinates of a point which corresponds to this point projected by a specified distance with specified angles (azimuth and inclination), using Cartesian mathematics.

segmentIntersection

Compute the intersection between two segments

skewLinesDistance

An algorithm to calculate the shortest distance between two skew lines.

skewLinesProjection

A method to project one skew line onto another.

sqrDistToLine

Returns the squared distance between a point and a line.

sqrDistance2D

Returns the squared 2D distance between (x1, y1) and (x2, y2).

sqrDistance3D

Returns the squared 3D distance between (x1, y1), (x2, y2) and (z2, z2).

sweepAngle

Calculates angle of a circular string part defined by pt1, pt2, pt3

triangleArea

Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

weightedPointInTriangle

Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

angleBetweenThreePoints(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) float

Calculates the angle between the lines AB and BC, where AB and BC described by points a, b and b, c.

Parameters:
  • x1 (float) – x-coordinate of point a

  • y1 (float) – y-coordinate of point a

  • x2 (float) – x-coordinate of point b

  • y2 (float) – y-coordinate of point b

  • x3 (float) – x-coordinate of point c

  • y3 (float) – y-coordinate of point c

Return type:

float

Returns:

angle between lines in radians. Returned value is undefined if two or more points are equal.

angleBisector(aX: float, aY: float, bX: float, bY: float, cX: float, cY: float, dX: float, dY: float) Tuple[bool, float, float, float]

Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX, bY) (dX, dY). The bisector segment of AB-CD is (point, projection of point by angle)

Parameters:
  • aX (float) – x-coordinate of first vertex of the segment ab

  • aY (float) – y-coordinate of first vertex of the segment ab

  • bX (float) – x-coordinate of second vertex of the segment ab

  • bY (float) – y-coordinate of second vertex of the segment ab

  • cX (float) – x-coordinate of first vertex of the segment cd

  • cY (float) – y-coordinate of first vertex of the segment cd

  • dX (float) – x-coordinate of second vertex of the segment cd

  • dY (float) – y-coordinate of second vertex of the segment cd

Return type:

Tuple[bool, float, float, float]

Returns:

  • True if the bisector exists (A B and C D are not collinear)

  • pointX: x-coordinate of generated point

  • pointY: y-coordinate of generated point

  • angle: angle of the bisector from pointX, pointY origin on [ab-cd]

Added in version 3.18.

angleOnCircle(angle: float, angle1: float, angle2: float, angle3: float) bool

Returns True if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3.

Parameters:
  • angle (float)

  • angle1 (float)

  • angle2 (float)

  • angle3 (float)

Return type:

bool

averageAngle(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) float

Calculates the average angle (in radians) between the two linear segments from (x1, y1) to (x2, y2) and (x2, y2) to (x3, y3).

averageAngle(a1: float, a2: float) -> float Averages two angles, correctly handling negative angles and ensuring the result is between 0 and 2 pi.

Parameters:
  • a1 – first angle (in radians)

  • a2 – second angle (in radians)

  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • x3 (float)

  • y3 (float)

Return type:

float

Returns:

average angle (in radians)

azimuth(x1: float, y1: float, x2: float, y2: float) float

Calculates Cartesian azimuth between points (x1, y1) and (x2, y2) (clockwise in degree, starting from north)

Parameters:
  • x1 (float) – x-coordinate of the start point

  • y1 (float) – y-coordinate of the start point

  • x2 (float) – x-coordinate of the end point

  • y2 (float) – y-coordinate of the end point

Added in version 3.34.

Return type:

float

bisector(aX: float, aY: float, bX: float, bY: float, cX: float, cY: float) Tuple[bool, float, float]

Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX, bY) (cX, cY). The bisector segment of ABC is (A-point)

Parameters:
  • aX (float) – x-coordinate of first vertex in triangle

  • aY (float) – y-coordinate of first vertex in triangle

  • bX (float) – x-coordinate of second vertex in triangle

  • bY (float) – y-coordinate of second vertex in triangle

  • cX (float) – x-coordinate of third vertex in triangle

  • cY (float) – y-coordinate of third vertex in triangle

Return type:

Tuple[bool, float, float]

Returns:

  • True if the bisector exists (A B and C are not collinear)

  • pointX: x-coordinate of generated point

  • pointY: y-coordinate of generated point

Added in version 3.18.

ccwAngle(dy: float, dx: float) float

Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0

Parameters:
  • dy (float)

  • dx (float)

Return type:

float

circleAngleBetween(angle: float, angle1: float, angle2: float, clockwise: bool) bool

Returns True if, in a circle, angle is between angle1 and angle2

Parameters:
  • angle (float)

  • angle1 (float)

  • angle2 (float)

  • clockwise (bool)

Return type:

bool

circleCenterRadius(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) Tuple[float, float, float]

Returns radius and center of the circle through (x1 y1), (x2 y2), (x3 y3)

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • x3 (float)

  • y3 (float)

Return type:

Tuple[float, float, float]

circleClockwise(angle1: float, angle2: float, angle3: float) bool

Returns True if the circle defined by three angles is ordered clockwise.

The angles are defined counter-clockwise from the origin, i.e. using Euclidean angles as opposed to geographic “North up” angles.

Parameters:
  • angle1 (float)

  • angle2 (float)

  • angle3 (float)

Return type:

bool

circleLength(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) float

Length of a circular string segment defined by pt1, pt2, pt3

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • x3 (float)

  • y3 (float)

Return type:

float

closestSideOfRectangle(right: float, bottom: float, left: float, top: float, x: float, y: float) int

Returns a number representing the closest side of a rectangle defined by /a right, bottom, left, top to the point at (x, y), where the point may be in the interior of the rectangle or outside it.

The returned value may be:

  1. Point is closest to top side of rectangle

  2. Point is located on the top-right diagonal of rectangle, equally close to the top and right sides

  3. Point is closest to right side of rectangle

  4. Point is located on the bottom-right diagonal of rectangle, equally close to the bottom and right sides

  5. Point is closest to bottom side of rectangle

  6. Point is located on the bottom-left diagonal of rectangle, equally close to the bottom and left sides

  7. Point is closest to left side of rectangle

  8. Point is located on the top-left diagonal of rectangle, equally close to the top and left sides

Note

This method effectively partitions the space outside of the rectangle into Voronoi cells, so a point to the top left of the rectangle may be assigned to the left or top sides based on its position relative to the diagonal line extended from the rectangle’s top-left corner.

Added in version 3.20.

Parameters:
  • right (float)

  • bottom (float)

  • left (float)

  • top (float)

  • x (float)

  • y (float)

Return type:

int

distance2D(x1: float, y1: float, x2: float, y2: float) float

Returns the 2D distance between (x1, y1) and (x2, y2).

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

Return type:

float

distance3D(x1: float, y1: float, z1: float, x2: float, y2: float, z2: float) float

Returns the 3D distance between (x1, y1), (x2, y2) and (z2, z2).

Warning

No check is done if z contains NaN value. This is the caller’s responsibility.

Added in version 3.36.

Parameters:
  • x1 (float)

  • y1 (float)

  • z1 (float)

  • x2 (float)

  • y2 (float)

  • z2 (float)

Return type:

float

interpolateArcValue(angle: float, a1: float, a2: float, a3: float, zm1: float, zm2: float, zm3: float) float

Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different angles (a1, a2, a3).

Parameters:
  • angle (float)

  • a1 (float)

  • a2 (float)

  • a3 (float)

  • zm1 (float)

  • zm2 (float)

  • zm3 (float)

Return type:

float

leftOfLine(x: float, y: float, x1: float, y1: float, x2: float, y2: float) int

Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2). A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly on the line, or exactly in line with the segment) and the result is undefined.

Parameters:
  • x (float)

  • y (float)

  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

Return type:

int

lineAngle(x1: float, y1: float, x2: float, y2: float) float

Calculates the direction of line joining two points in radians, clockwise from the north direction.

Parameters:
  • x1 (float) – x-coordinate of line start

  • y1 (float) – y-coordinate of line start

  • x2 (float) – x-coordinate of line end

  • y2 (float) – y-coordinate of line end

Return type:

float

Returns:

angle in radians. Returned value is undefined if start and end point are the same.

lineIntersection(p1x: float, p1y: float, v1: QgsVector, p2x: float, p2y: float, v2: QgsVector) Tuple[bool, float, float]

Computes the intersection between two lines. Z dimension is supported and is retrieved from the first 3D point amongst p1 and p2.

Parameters:
  • p1x (float) – x-coordinate of point on the first line

  • p1y (float) – y-coordinate of point on the first line

  • v1 (QgsVector) – Direction vector of the first line

  • p2x (float) – x-coordinate of second point on the first line

  • p2y (float) – y-coordinate of second point on the first line

  • v2 (QgsVector) – Direction vector of the second line

Return type:

Tuple[bool, float, float]

Returns:

  • Whether the lines intersect

  • intersectionX: x-coordinate of the intersection point

  • intersectionY: y-coordinate of the intersection point

linePerpendicularAngle(x1: float, y1: float, x2: float, y2: float) float

Calculates the perpendicular angle to a line joining two points. Returned angle is in radians, clockwise from the north direction.

Parameters:
  • x1 (float) – x-coordinate of line start

  • y1 (float) – y-coordinate of line start

  • x2 (float) – x-coordinate of line end

  • y2 (float) – y-coordinate of line end

Return type:

float

Returns:

angle in radians. Returned value is undefined if start and end point are the same.

linesIntersection3D(La1: QgsVector3D, La2: QgsVector3D, Lb1: QgsVector3D, Lb2: QgsVector3D) Tuple[bool, QgsVector3D]

An algorithm to calculate an (approximate) intersection of two lines in 3D.

Parameters:
  • La1 (QgsVector3D) – is the first point on the first line,

  • La2 (QgsVector3D) – is the second point on the first line,

  • Lb1 (QgsVector3D) – is the first point on the second line,

  • Lb2 (QgsVector3D) – is the second point on the second line,

Return type:

Tuple[bool, QgsVector3D]

Returns:

  • True if the intersection can be found, False - otherwise.

  • intersection: is the result intersection, of it can be found.

Example

QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(2,1,0), QgsVector3D(2,3,0))
# (True, PyQt5.QtGui.QgsVector3D(2.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(2,1,0), QgsVector3D(2,0,0))
# (True, PyQt5.QtGui.QgsVector3D(2.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(0,1,0), QgsVector3D(0,3,0))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(0,1,0), QgsVector3D(0,0,0))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(5,1,0), QgsVector3D(5,3,0))
# (False, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(0,0,0), QgsVector3D(5,0,0), QgsVector3D(5,1,0), QgsVector3D(5,0,0))
# (False, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(1,1,0), QgsVector3D(2,2,0), QgsVector3D(3,1,0), QgsVector3D(3,2,0))
# (True, PyQt5.QtGui.QgsVector3D(3.0, 3.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(1,1,0), QgsVector3D(2,2,0), QgsVector3D(3,2,0), QgsVector3D(3,1,0))
# (True, PyQt5.QtGui.QgsVector3D(3.0, 3.0, 0.0))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(5,5,5), QgsVector3D(0,0,0), QgsVector3D(0,5,5), QgsVector3D(5,0,0))
# (True, PyQt5.QtGui.QgsVector3D(2.5, 2.5, 2.5))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(2.5,2.5,2.5), QgsVector3D(0,5,0), QgsVector3D(2.5,2.5,2.5), QgsVector3D(5,0,0))
# (True, PyQt5.QtGui.QgsVector3D(2.5, 2.5, 2.5))
QgsGeometryUtils.linesIntersection3D(QgsVector3D(2.5,2.5,2.5), QgsVector3D(5,0,0), QgsVector3D(0,5,5), QgsVector3D(5,5,5))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 5.0, 5.0))
normalizedAngle(angle: float) float

Ensures that an angle is in the range 0 <= angle < 2 pi.

Parameters:

angle (float) – angle in radians

Return type:

float

Returns:

equivalent angle within the range [0, 2 pi)

perpendicularCenterSegment(centerPointX: float, centerPointY: float, segmentPoint1x: float, segmentPoint1y: float, segmentPoint2x: float, segmentPoint2y: float, segmentLength: float = 0) Tuple[float, float, float, float]

Create a perpendicular line segment to a given segment [segmentPoint1,``segmentPoint2``] with its center at centerPoint.

May be used to split geometries. Unless segmentLength is specified the new centered perpendicular line segment will have double the length of the input segment.

The result is a line (segment) centered in point p and perpendicular to segment [segmentPoint1, segmentPoint2].

Parameters:
  • centerPointX (float) – x-coordinate of the point where the center of the perpendicular should be located

  • centerPointY (float) – y-coordinate of the point where the center of the perpendicular should be located

  • segmentPoint1x (float) – : x-coordinate of segmentPoint1, the segment’s start point

  • segmentPoint1y (float) – : y-coordinate of segmentPoint1, the segment’s start point

  • segmentPoint2x (float) – : x-coordinate of segmentPoint2, the segment’s end point

  • segmentPoint2y (float) – : y-coordinate of segmentPoint2, the segment’s end point

  • perpendicularSegmentPoint1x – : x-coordinate of the perpendicularCenterSegment’s start point

  • perpendicularSegmentPoint1y – : y-coordinate of the perpendicularCenterSegment’s start point

  • perpendicularSegmentPoint2x – : x-coordinate of the perpendicularCenterSegment’s end point

  • perpendicularSegmentPoint2y – : y-coordinate of the perpendicularCenterSegment’s end point

  • segmentLength (float = 0) – (optional) Trims to given length. A segmentLength value of 0 refers to the default length which is double the length of the input segment. Set to 1 for a normalized length.

Added in version 3.24.

Return type:

Tuple[float, float, float, float]

perpendicularOffsetPointAlongSegment(x1: float, y1: float, x2: float, y2: float, proportion: float, offset: float) Tuple[float, float]

Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2, y2), offset from the segment by the specified offset amount.

Parameters:
  • x1 (float) – x-coordinate of start of segment

  • y1 (float) – y-coordinate of start of segment

  • x2 (float) – x-coordinate of end of segment

  • y2 (float) – y-coordinate of end of segment

  • proportion (float) – proportion of the segment’s length at which to place the point (between 0.0 and 1.0)

  • offset (float) – perpendicular offset from segment to apply to point. A negative offset shifts the point to the left of the segment, while a positive offset will shift it to the right of the segment.

Example

# Offset point at center of segment by 2 units to the right
x, y = QgsGeometryUtils.perpendicularOffsetPointAlongSegment( 1, 5, 11, 5, 0.5, 2 )
# (6.0, 3.0)

# Offset point at center of segment by 2 units to the left
x, y = QgsGeometryUtils.perpendicularOffsetPointAlongSegment( 1, 5, 11, 5, 0.5, -2 )
# (6.0, 7.0)
rtype:

Tuple[float, float]

return:
  • x: calculated point x-coordinate

  • y: calculated point y-coordinate

Added in version 3.20.

pointFractionAlongLine(x1: float, y1: float, x2: float, y2: float, px: float, py: float) float

Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at which the point lies.

Warning

this method requires that the point definitely lies on the line!

Added in version 3.32.

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • px (float)

  • py (float)

Return type:

float

pointsAreCollinear(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, epsilon: float) bool

Given the points (x1, y1), (x2, y2) and (x3, y3) returns True if these points can be considered collinear with a specified tolerance epsilon.

Added in version 3.32.

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • x3 (float)

  • y3 (float)

  • epsilon (float)

Return type:

bool

project(aX: float, aY: float, aZ: float, distance: float, azimuth: float, inclination: float) Tuple[float, float, float]

Returns coordinates of a point which corresponds to this point projected by a specified distance with specified angles (azimuth and inclination), using Cartesian mathematics. M value is preserved. resultX, resultY, resultZ are coordinates of the point projected. If a 2D point is projected a 3D point will be returned except if inclination is 90. A 3D point is always returned if a 3D point is projected.

Parameters:
  • aX (float) – x-coordinate of the point to project

  • aY (float) – y-coordinate of the point to project

  • aZ (float) – z-coordinate of the point to project

  • distance (float) – distance to project

  • azimuth (float) – angle to project in X Y, clockwise in degrees starting from north

  • inclination (float) – angle to project in Z (3D). If the point is 2D, the Z value is assumed to be 0.

Return type:

Tuple[float, float, float]

Returns:

  • resultX: Output parameter, x-coordinates of the point projected.

  • resultY: Output parameter, y-coordinates of the point projected.

  • resultZ: Output parameter, z-coordinates of the point projected.

Added in version 3.34.

segmentIntersection(p1x: float, p1y: float, p2x: float, p2y: float, q1x: float, q1y: float, q2x: float, q2y: float, tolerance: float = 1e-08, acceptImproperIntersection: bool = False) Tuple[bool, float, float, bool]

Compute the intersection between two segments

Parameters:
  • p1x (float) – x-coordinate of the first segment start point

  • p1y (float) – y-coordinate of the first segment start point

  • p2x (float) – x-coordinate of the first segment end point

  • p2y (float) – y-coordinate of the first segment end point

  • q1x (float) – x-coordinate of the second segment start point

  • q1y (float) – y-coordinate of the second segment start point

  • q2x (float) – x-coordinate of the second segment end point

  • q2y (float) – y-coordinate of the second segment end point

  • tolerance (float = 1e-08) – The tolerance to use

  • acceptImproperIntersection (bool = False) – By default, this method returns True only if segments have proper intersection. If set true, returns also True if segments have improper intersection (end of one segment on other segment ; continuous segments).

Return type:

Tuple[bool, float, float, bool]

Returns:

  • Whether the segments intersect

  • intersectionPointX: Output parameter, x-coordinate of the intersection point

  • intersectionPointY: Output parameter, y-coordinate of the intersection point

  • isIntersection: Output parameter, return True if an intersection is found

skewLinesDistance(P1: QgsVector3D, P12: QgsVector3D, P2: QgsVector3D, P22: QgsVector3D) float

An algorithm to calculate the shortest distance between two skew lines.

Parameters:
  • P1 (QgsVector3D) – is the first point of the first line,

  • P12 (QgsVector3D) – is the second point on the first line,

  • P2 (QgsVector3D) – is the first point on the second line,

  • P22 (QgsVector3D) – is the second point on the second line.

Return type:

float

Returns:

the shortest distance

skewLinesProjection(P1: QgsVector3D, P12: QgsVector3D, P2: QgsVector3D, P22: QgsVector3D, epsilon: float = 0.0001) Tuple[bool, QgsVector3D]

A method to project one skew line onto another.

Parameters:
  • P1 (QgsVector3D) – is a first point that belonds to first skew line,

  • P12 (QgsVector3D) – is the second point that belongs to first skew line,

  • P2 (QgsVector3D) – is the first point that belongs to second skew line,

  • P22 (QgsVector3D) – is the second point that belongs to second skew line,

  • X1 – is the result projection point of line P2P22 onto line P1P12,

  • epsilon (float = 0.0001) – the tolerance to use.

Return type:

Tuple[bool, QgsVector3D]

Returns:

True if such point exists, False - otherwise.

sqrDistToLine(ptX: float, ptY: float, x1: float, y1: float, x2: float, y2: float, epsilon: float) Tuple[float, float, float]

Returns the squared distance between a point and a line.

Parameters:
  • ptX (float)

  • ptY (float)

  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • epsilon (float)

Return type:

Tuple[float, float, float]

sqrDistance2D(x1: float, y1: float, x2: float, y2: float) float

Returns the squared 2D distance between (x1, y1) and (x2, y2).

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

Return type:

float

sqrDistance3D(x1: float, y1: float, z1: float, x2: float, y2: float, z2: float) float

Returns the squared 3D distance between (x1, y1), (x2, y2) and (z2, z2).

Warning

No check is done if z contains NaN value. This is the caller’s responsibility.

Added in version 3.36.

Parameters:
  • x1 (float)

  • y1 (float)

  • z1 (float)

  • x2 (float)

  • y2 (float)

  • z2 (float)

Return type:

float

sweepAngle(centerX: float, centerY: float, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) float

Calculates angle of a circular string part defined by pt1, pt2, pt3

Parameters:
  • centerX (float)

  • centerY (float)

  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • x3 (float)

  • y3 (float)

Return type:

float

triangleArea(aX: float, aY: float, bX: float, bY: float, cX: float, cY: float) float

Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

Added in version 3.10.

Parameters:
  • aX (float)

  • aY (float)

  • bX (float)

  • bY (float)

  • cX (float)

  • cY (float)

Return type:

float

weightedPointInTriangle(aX: float, aY: float, bX: float, bY: float, cX: float, cY: float, weightB: float, weightC: float) Tuple[float, float]

Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

Parameters:
  • aX (float) – x-coordinate of first vertex in triangle

  • aY (float) – y-coordinate of first vertex in triangle

  • bX (float) – x-coordinate of second vertex in triangle

  • bY (float) – y-coordinate of second vertex in triangle

  • cX (float) – x-coordinate of third vertex in triangle

  • cY (float) – y-coordinate of third vertex in triangle

  • weightB (float) – weighting factor along axis A-B (between 0 and 1)

  • weightC (float) – weighting factor along axis A-C (between 0 and 1)

Return type:

Tuple[float, float]

Returns:

  • pointX: x-coordinate of generated point

  • pointY: y-coordinate of generated point

Added in version 3.10.