cross4P
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2012-05-05, Last change: 2025-09-14
return whether two lines cross each other (2D fnct)
Description
This procedure is similar to cross2edges, but has a simplified result. It used in many analytical VLFL-Lib functions.
See Also: cross4P
, cross2edges
, cross2edges2
Example Illustration
Syntax
[kc,ka,kb]=cross4P(pa,pb,pc,pd)
Input Parameter
pa: | | start point of first line |
pb: | | end point of first line |
pc: | | start point of second line |
pd: | | end point of second line |
Output Parameter
kc: | | =0, i.e. there is no crossing. =1; i.e. there is a crossing |
ka: | | between 0 and 1 if there is a crossing of line 1 |
kb: | | between 0 and 1 if there is a crossing of line 2 |
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 whether two lines in a 2D plane intersect. It is a part of the SolidGeometry library and is used in various analytical functions.
Input Parameters
- pa: Start point of the first line.
- pb: End point of the first line.
- pc: Start point of the second line.
- pd: End point of the second line.
Output Results
- kc: Indicates if there is a crossing.
kc = 0 means no crossing, kc = 1 means there is a crossing.
- ka: A value between 0 and 1 if there is a crossing on the first line.
- kb: A value between 0 and 1 if there is a crossing on the second line.
Algorithm Steps
- Set a threshold value
thr = 1e-12 to account for numerical precision.
- Call the function
cross2edges2 with parameters (pa, pb-pa, pc, pd-pc) to calculate potential intersection points and parameters ka and kb.
- Check if
ka and kb are within the range [-thr, 1+thr] to determine if the lines intersect.
- If both
ka and kb are within the range, set kc = 1 indicating a crossing; otherwise, set kc = 0.
Algorithm explaination created using ChatGPT on 2025-08-19 00:26. (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