Look at the scene in the direction of movement (in other words, apply a change of coordinates so that this direction becomes vertical and reduces height). You get a two-dimensional digit.
Given the edges of two boxes that are facing each other, you will see two hexagons, each of which is divided into three parallelograms.

Then
Edge intersection detection in 2D. From the relationship of the section at the edges, you can determine the actual distances z.
For all vertices, define the face on which they fall in another field; and from three-dimensional equations - the breakdown point of the viewing line into the plane of the face, hence the distance. (Repeat this for vertices A and B.)
, ( , ).
"--" , .