@@ -55,55 +55,3 @@ function svdbasis(p::AbstractVector{<:Point})
5555 n = Vec (zero (ℒ), zero (ℒ), oneunit (ℒ))
5656 isnegative ((u × v) ⋅ n) ? (v, u) : (u, v)
5757end
58-
59- """
60- intersectparameters(a, b, c, d)
61-
62- Compute the parameters `λ₁` and `λ₂` of the lines
63- `a + λ₁ ⋅ v⃗₁`, with `v⃗₁ = b - a` and
64- `c + λ₂ ⋅ v⃗₂`, with `v⃗₂ = d - c` spanned by the input
65- points `a`, `b` resp. `c`, `d` such that to yield line
66- points with minimal distance or the intersection point
67- (if lines intersect).
68-
69- Furthermore, the ranks `r` of the matrix of the linear
70- system `A ⋅ λ⃗ = y⃗`, with `A = [v⃗₁ -v⃗₂], y⃗ = c - a`
71- and the rank `rₐ` of the augmented matrix `[A y⃗]` are
72- calculated in order to identify the intersection type:
73-
74- - Intersection: r == rₐ == 2
75- - Collinear: r == rₐ == 1
76- - No intersection: r != rₐ
77- - No intersection and parallel: r == 1, rₐ == 2
78- - No intersection, skew lines: r == 2, rₐ == 3
79- """
80- function intersectparameters (a:: Point , b:: Point , c:: Point , d:: Point )
81- # augmented linear system
82- A = ustrip .([(b - a) (c - d) (c - a)])
83-
84- # normalize by maximum absolute coordinate
85- A = A / maximum (abs, A)
86-
87- # numerical tolerance
88- T = eltype (A)
89- τ = atol (T)
90-
91- # check if a vector is non zero
92- isnonzero (v) = ! isapprox (v, zero (v), atol= τ)
93-
94- # calculate ranks by checking the zero rows of
95- # the factor R in the QR matrix factorization
96- _, R = qr (A)
97- r = sum (isnonzero, eachrow (R[:, SVector (1 , 2 )]))
98- rₐ = sum (isnonzero, eachrow (R))
99-
100- # calculate parameters of intersection
101- if r ≥ 2
102- λ = A[:, SVector (1 , 2 )] \ A[:, 3 ]
103- λ₁, λ₂ = λ[1 ], λ[2 ]
104- else # parallel or collinear
105- λ₁, λ₂ = zero (T), zero (T)
106- end
107-
108- λ₁, λ₂, r, rₐ
109- end
0 commit comments