cross2L

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2010-09-04, Last change: 2025-09-14

returns the crossing point of two straight lines

Description

[p,E] = cross2L (TG1, TG2) returns the crossing point p by solving the linear equation using the gauss-elemination problem (rref). If E(1,3) or (E(2,3) are zero, then both lines are identical
Point format changed in Rel 5.1 to [1 x 3]

See Also: crossL , crossT , cross2T , Tcross2T

Example Illustration

 missing image of cross2L(TG1,TG2)

Syntax

[p,d]=cross2L(TG1,TG2)

Input Parameter

TG1: HT-Matrix of line 1, the z axis is crossed
TG2: HT-Matrix of line 2, the z axis is crossed

Output Parameter

p: crossing point/minimal distance point (1x3) of the two lines
d: minimal distance between the two line if they dont cross

Examples

cross2L(T2P([0 0 0],[1 0 0]),T2P([2 0 0],[2 2 1])), shg



Copyright 2010-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, cross2L, calculates the crossing point of two straight lines represented by homogeneous transformation matrices (HT-Matrices) TG1 and TG2. It uses the Gauss elimination method to solve the linear equations.

Input Parameters

Output Results

Algorithm Steps

  1. Retrieve the threshold value using getfuncparams, defaulting to 1e-3.
  2. Calculate the transformation matrix T using crossL(TG1\TG2).
  3. Compute the absolute value of T(2,1) to determine the distance d.
  4. Calculate the crossing point p by multiplying TG1 with the first three elements of T and appending 1.
  5. Extract the first three elements of p to get the crossing point in 3D space.
  6. If d is greater than the threshold, print a message indicating the lines do not cross and set p to an empty array.
  7. Transpose p for output.
  8. If no output arguments are specified, plot the lines and the crossing point if they intersect.

Example

Example usage: cross2L(T2P([0 0 0],[1 0 0]),T2P([2 0 0],[2 2 1]))

Algorithm explaination created using ChatGPT on 2025-08-19 07:04. (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