Well, this is related to the discussion we were having with Uri about coordinate systems earlier. It's also possible the code is wrong too.  

As a thought exercise, what would you expect r.distance(pStart-1) and r.distance(pEnd-1) to be?