isInteriorofCPL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analyzing function
Introduced first in SolidGeometry 4.9, Creation date: 2020-01-22, Last change: 2025-09-14

tests whether a point is inside of a closed contour in 2D!

Description

for simple CPL; this function is faster than insideCPL
+1 means point is inside or on contour
0 means point is outside

See Also: crosstest , insideCPL , insideCPS , CPLselectbyP

Example Illustration

 missing image of isInteriorofCPL(CPL,PL);

Syntax

ii=isInteriorofCPL(CPL,PL);

Input Parameter

CPL: Vertex list of the contour
PL: Point to check

Output Parameter

ii: +1==inside or on, 0==outside

Examples


isInteriorofCPL(CPLsample(8)/10,rand(1000000,2));
isInteriorofCPL(PLcircle(1),rand(1000000,2));




Copyright 2020-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, isInteriorofCPL, determines whether a given point is inside or on the boundary of a closed contour in 2D. It is designed for simple closed polygonal lines (CPL) and is optimized for speed compared to other similar functions.

Input Parameters

Output Results

Algorithm Steps

  1. Determine the number of vertices in the contour (n1) and the number of points to check (n2).
  2. If there are no points to check (n2 == 0), return an empty result.
  3. Check if the contour has more than 6 vertices, more than 100,000 points to check, or if any vertex coordinate is NaN. If any of these conditions are true:
    • Create a polygon shape using the polyshape function with the contour vertices.
    • Use the isinterior function to determine if each point is inside the polygon.
  4. If the above conditions are not met, use the insideCPL function to determine if each point is inside the contour. The result is adjusted to be binary (+1 or 0).
  5. If no output argument is specified, plot the results:
    • Display the contour using CPLplot with a black line.
    • Plot points inside the contour in green and points outside in red using PLplot.
    • Adjust the axis to grow by 10% using BBgrow.
Algorithm explaination created using ChatGPT on 2025-08-19 01:19. (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