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
- TG1: HT-Matrix of line 1, where the z-axis is crossed.
- TG2: HT-Matrix of line 2, where the z-axis is crossed.
- varargin: Optional parameters, with a default threshold value of
1e-3
.
Output Results
- p: The crossing point or minimal distance point (1x3) of the two lines.
- d: The minimal distance between the two lines if they do not cross.
Algorithm Steps
- Retrieve the threshold value using
getfuncparams
, defaulting to 1e-3
.
- Calculate the transformation matrix
T
using crossL(TG1\TG2)
.
- Compute the absolute value of
T(2,1)
to determine the distance d
.
- Calculate the crossing point
p
by multiplying TG1
with the first three elements of T
and appending 1.
- Extract the first three elements of
p
to get the crossing point in 3D space.
- If
d
is greater than the threshold, print a message indicating the lines do not cross and set p
to an empty array.
- Transpose
p
for output.
- 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