private static Vector2d getPerpendicular(Tuple2d a, Tuple2d b, Vector2d ref) {
        final Vector2d pVec = new Vector2d(-(a.y-b.y), a.x-b.x);
        if (pVec.dot(ref) < 0)
            pVec.negate();
        return pVec;
    }
private static Vector2d getPerpendicular ( Tuple2d a , Tuple2d b , Vector2d ref ) { final Vector2d pVec = new Vector2d ( - ( a . y - b . y ) , a . x - b . x ) ; if ( pVec . dot ( ref ) < 0 ) pVec . negate ( ) ; return pVec ; }
Gat a vector perpendicular to the line, a-b, that is pointing
the same direction as 'ref'.

@param a first coordinate
@param b second coordinate
@param ref reference vector
@return perpendicular vector