Syntax
[i,j]=crossedgeVL(VL,k0,k1,k2)
Input Parameter
VL : | | Vertex list |
k0 : | | Index 0 |
k1 : | | Index 1 |
k2 : | | Index 2 |
Output Parameter
i : | | index of the beginning of the crossed line |
j : | | index of the end of the crossed line, ie. i+1 |
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 algorithm determines if a line segment defined by three indices crosses any other line segment in a 2D contour. The contour is represented by a sorted vertex list, and the function checks for intersections using the helper function cross4P
.
Input Parameters
- VL: A list of vertices representing the 2D contour.
- k0: Index of the first vertex of the line segment.
- k1: Index of the second vertex of the line segment.
- k2: Index of the third vertex of the line segment.
Output Results
- i: Index of the beginning of the crossed line.
- j: Index of the end of the crossed line, i.e.,
i+1
.
Algorithm Steps
- Initialize
i
to 0.
- Check if any of the line segments formed by the indices
k0, k1, k2
cross the contour using crossC2P
. If a crossing is detected, set i
to the corresponding index.
- Return if a crossing is found at this stage.
- Determine the number of vertices
n
. If n
is less than 4, set CI
to 0 and return.
- Reorder the indices
K
to ensure they are not successive.
- Extract the points
p0, p1, p2
from the vertex list using the indices k0, k1, k2
.
- Check if the indices form a real sequence. If they do, set
i
and j
to 0 and return.
- Iterate over each vertex in the contour:
- For each pair of vertices
(i, j)
, check if they are not part of the line segment defined by k0, k1, k2
.
- Use
cross4P
to check if the line segment (p2, p0)
crosses the line segment (VL(j,:), VL(i,:))
.
- If a crossing is detected, return the indices
i
and j
.
- If no crossing is found, set
i
and j
to 0.
Algorithm explaination created using ChatGPT on 2025-08-19 07:55. (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