I am only interested in the sign of the dot product. Does that make things more clear?
I'm still curious if it is correct to always move in the direction of the normal of the line segment. For example, if p1 == p2, there's still a best direction. But I was missing something with the sign, so I could also be missing something else.
Edit: oh, maybe I'm missing that it is just a "line" instead of a segment. From the description, I'm not sure. It uses the word line but describes it as a line that goes from one point to another, which I pictured as a segment.