[Overview][Types][Procedures and functions][Index] |
Gets the distance between two points, or the distance of a point from a specified line.
Source position: graphmath.pp line 69
function Distance( |
const PT1: TPoint; |
const Pt2: TPoint |
):Extended; overload; |
const PT1: TFloatPoint; |
const Pt2: TFloatPoint |
):Extended; overload; |
const Pt: TFloatPoint; |
const SP: TFloatPoint; |
const EP: TFloatPoint |
):Extended; overload; |
PT1 |
|
Starting point for the calculated distance. |
Pt2 |
|
Ending point for the calculated distance. |
Straight-line distance between the specified coordinates or objects.
PT1 |
|
Starting point for the calculated distance. |
Pt2 |
|
Ending point for the calculated distance. |
Pt |
|
Fixed point for the calculated distance. |
SP |
|
Starting point for the line used in the distance calculation. |
Distance is an overloaded function with variants that operate on either two point coordinates, or on a point and a line defined by two additional points values. The Distance() function is used primarily for internal purposes (such as in Bezier2PolyLine and EccentricAngle) but can be used for any purpose.
The return value is an Extended type with the calculated distance between the argument values. The return value is always a positive value.
The variants using two point arguments (TPoint or TFloatPoint) calculates the length of a straight line between the coordinates in PT1 and PT2 using the Pythagorean theorem. The distance between identical points is always zero (0).
The variant with three TFloatPoint arguments calculates the distance between the point Pt and the line represented by the points in SP and EP using Euclidean geometry. The distance is derived by finding the length of an imaginary line between Pt and the closest point that intersects the slope of the line in SP and EP. The distance for a point which lies on the defined line is always zero (0).
Version 4.0 | Generated 2025-05-03 | Home |