Thinking about it, this is the way I might do it:
- Create a center point coordinate of the pursued cube. (p1)
- Create a center point coordinate of the chaser cube. (p2)
- Find the vertical and horizontal angles of that line (p1,p2)
- Find the center point of the side of the cube that represents the face. (p3)
- Find the vertical and horizontal angles of that line (p1,p3)
- Rotate the cube until angles of line (p1,p3) matches those of (p1,p2)
- The line to move along would be (p1,p2), but taking into the (p1,p3) of each cube as to identify collision, assuming head on collision.
To take into account all approach points, then the distance between the two cubes would be:
(p1,p2) - (p1, point of intersection of line on p1’s surface) - (p2, point of intersection of line on p2’s surface)
Note this is purely theoretical and haven’t actually put it to the test.
Examples of rotation can be found here:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05
Let me know if this works for you.