rofCPLsmalldist

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Geometric Queries
Introduced first in SolidGeometry 5.4, Creation date: 2024-08-15, Last change: 2025-09-15

returns the smallest distance between two contours in CPL

Description

In contrast to CPLdistancewall, this function is a linear search function, that call several times CPLfindsmalldist. It is may be slow, but helpful for automatic design based on existing STLs

See Also: CPLdistancewall

Example Illustration

 missing image of rofCPLsmalldist(CPL,)

Syntax

rmin=rofCPLsmalldist(CPL,[])

Input Parameter

CPL: Contour

Output Parameter

rmin: smallest distance between contours in CPL

Examples


rofCPLsmalldist(PLcircle(4))




Copyright 2024-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

Algorithm (Workflow)

This function, rofCPLsmalldist, calculates the smallest distance between contours in a given contour list (CPL). It is a linear search function that repeatedly calls CPLfindsmalldist.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize res to 0.1, which is the resolution for the search.
  2. Calculate the bounding box of the CPL using BBofCPL and determine its size with sofBB.
  3. Set thr to 0.16 (0.4 squared) as a threshold for area comparison.
  4. Initialize ar with the size of the bounding box and d as a quarter of ar.
  5. Set AOLD to infinity to store the previous area for comparison.
  6. Enter a while loop that continues as long as ar is greater than or equal to res:
  7. Set rmin to the final value of ar.
  8. If no output is requested, plot the CPL and the final cut using SGfigure and CPLplot.
Algorithm explaination created using ChatGPT on 2025-08-19 06:47. (Please note: No guarantee for the correctness of this explanation)

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