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

 missing image of cross4P(pa,pb,pc,pd)

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

Output Results

Algorithm Steps

  1. Set a threshold value thr = 1e-12 to account for numerical precision.
  2. Call the function cross2edges2 with parameters (pa, pb-pa, pc, pd-pc) to calculate potential intersection points and parameters ka and kb.
  3. Check if ka and kb are within the range [-thr, 1+thr] to determine if the lines intersect.
  4. 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