CPLdisttopoint

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.0, Creation date: 2017-07-30, Last change: 2025-09-14

returns the minmal distance between a contour and a given point

Description

for each edge/ conenction between two points, the distance to the origin or the optional point p is calculated. Because of a bug for outside points, the function has been modified completely for SG-Lib 5.4 and outside distances are now negative. Inside distances are positive.

See Also: centerCPL , CPLdistance

Example Illustration

 missing image of CPLdisttopoint(CPL,p)

Syntax

[dmin,ei]=CPLdisttopoint(CPL,[p])

Input Parameter

CPL: Closed polygon line
p: point of interest; default is [0 0]

Output Parameter

dmin: minmal circle radius that touches the contour. negative if outside
ei:

Examples


CPLdisttopoint(CPLofPL(PLcircle(10,3)),[-6 0]) % Inside and nearest edge => positive d
CPLdisttopoint(CPLofPL(PLcircle(10,3)),[-12 0]) % Outside and nearest Point => negative d
CPLdisttopoint(CPLofPL(PLcircle(10,4)),[-12 0]) % Outside and nearest edge => negative d

References

https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line



Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Last html export of this page out of FM database by TL: 2025-09-21