crossC2P

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analyzing function
Introduced first in SolidGeometry 1.0, Creation date: 2012-05-12, Last change: 2025-09-14

returns how often a line crosses a contour

Description

This procedures uses cross4P to test all segments of the vertex list for crossings. The vertex list will be always considered as closed

See Also: PLcross2Lines , PLcrossCPLline , iscrossingCPL , cross4P

Example Illustration

 missing image of crossC2P(VL,p1,p2)

Syntax

[k,CL,CCL]=crossC2P(VL,p1,p2)

Input Parameter

VL: vertex list of the contour
p1: start point
p2: end point

Output Parameter

k: number of crossings
CL: [i index of VL, k value distance p2 to p1, k value distance VL(i+1)-VL(i)
CCL: Cross point list

Examples


crossC2P(PLcircle(10,8),[-15 -15 ],[15 15])




Copyright 2012-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, crossC2P, calculates how often a line crosses a closed contour defined by a vertex list. It uses another function, cross4P, to determine crossings for each segment of the contour.

Input Parameters

Output Results

Algorithm Steps

  1. Determine the number of vertices n in the vertex list VL.
  2. Close the contour by appending the first vertex to the end of VL.
  3. Initialize CL as a zero matrix with n rows and 3 columns.
  4. Initialize counters k and m to zero.
  5. Loop through each segment of the contour:
    • Call cross4P to check if the line (p1, p2) crosses the segment (VL(i), VL(i+1)).
    • If a crossing is detected (kc > 0), increment k by kc and m by 1.
    • Store the crossing information in CL.
  6. Trim CL to only include detected crossings.
  7. Calculate the vector p21 as the difference between p2 and p1.
  8. Compute the crossing points CCL using the parameter ka and the vector p21.
  9. Remove duplicate crossing points from CCL and update CL accordingly.
  10. Set k to the number of unique crossing points.
  11. If no output arguments are specified, plot the contour, line, and crossing points using graphical functions.
Algorithm explaination created using ChatGPT on 2025-08-19 08:29. (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