}
+double Geometry::DistanceToLineFromPoint(Point tail, Point head, Point point)
+{
+ // Interpretation: given a line in the form x = a + tu, where u is the
+ // unit vector of the line, a is the tail and t is a parameter which
+ // describes the line, the distance of a point p to the line is given by:
+ // || (a - p) - ((a - p) . u) u ||
+ // We go an extra step: we set the sign to reflect which side of the line
+ // it's on (+ == to the left if head points away from you, - == to the
+ // right)
+ Vector line(tail, head);
+ Vector u = line.Unit();
+ Vector a_p = tail - point;
+ Vector dist = a_p - (u * (a_p).Dot(u));
+
+ double angle = Vector::Angle(tail, point) - line.Angle();
+
+ if (angle < 0)
+ angle += TAU;
+
+ return dist.Magnitude() * (angle < HALF_TAU ? +1.0 : -1.0);
+}
+
+
Point Geometry::MirrorPointAroundLine(Point point, Point tail, Point head)
{
// Get the vector of the intersection of the line and the normal on the