29/9/2023

Consider this SQL statement:

SELECT ST_3DIntersects(Foo.a, Foo.b) As a_Intersects_b
, ST_3DIntersects(Foo.a1, Foo.b1) As a1_Intersects_b1
    FROM (
    SELECT ST_GeomFromText('LINESTRING(5 4 0, 5 0 0)', 0) As a
    ,ST_Affine(ST_GeomFromText('LINESTRING(5 4 0, 5 0 0)', 0), -0.9248934130614574, 0.2534855979991293, 0.2834029394388001, -0.2259466894528656, -0.9658860720787614, 0.12653927963108094, 0.3058108369577812, 0.05300139027692074, 0.9506158975253333, 0, 0, 0) As a1
    ,ST_GeomFromText('LINESTRING(6 4 0, 4 2 0)', 0) As b
    ,ST_Affine(ST_GeomFromText('LINESTRING(6 4 0, 4 2 0)', 0), -0.9248934130614574, 0.2534855979991293, 0.2834029394388001, -0.2259466894528656, -0.9658860720787614, 0.12653927963108094, 0.3058108369577812, 0.05300139027692074, 0.9506158975253333, 0, 0, 0) As b1
    ) As Foo;
-- Expected {True, True}
-- Actual {True, False}

Line a ('LINESTRING(5 4 0, 5 0 0)') intersects Line b ('LINESTRING(6 4 0, 4 2 0)') at Point c (’POINT(5 3 0)’).

3d_plot1.png

We affine Line a and Line b using the same orthogonal matrix $M$ and get Line a1 and Line b1 respectively. Line a1 and Line b1 intersect on the Point c1 because we only transform the coordinates.

$M =\begin{pmatrix} -0.9248934130614574 & 0.2534855979991293 & 0.2834029394388001 \\ -0.2259466894528656 & -0.9658860720787614 & 0.12653927963108094 \\ 0.3058108369577812 & 0.05300139027692074 & 0.9506158975253333 \end{pmatrix}$

$M*M^T = E$

3d_plot2.png