static Point project(Line l, Point p) { Point p1 = l.getP1(); Point p2 = l.getP2(); Vector base = new Vector(p2, p1); double r = Vector.dot(new Vector(p, p1), base) / base.norm(); return base.scalarMul(r).plus(p1).toPoint(); }