Can you solve it with pen & pencil? I guess the key insight for adjacent sides is that if you flatten out the sides it is just a normal shortest path problem. So if you have points (0,a,b) and (c,1,d) for a 1x1x1 cube you will have to travel over the (0,1,z) edge. So you get the distance from both points to the edge and add them and that is one side of the triangle. Then for the lines you drew to the edge, the distance between these two lines along the edge is another side of the triangle. Then you have enough info to use trig to get the angle from one point to another relative to the shared edge.
Coding this sounds like a pain in the ass. Sorry
edit: Just noticed you only wanted to calculate the distance not produce some equation to describe the path. In this case its just pythagorean with the two found sides.
Last edited by e i pi; 10-21-2014 at 04:51 PM.
Reason: bla