// the perpendicular lies beyond the 1st endpoint. If pp > 1, then the\r
// perpendicular lies beyond the 2nd endpoint.\r
\r
- Vector lineSegment = v2 - v1;\r
+ Vector lineSegment = v1 - v2;\r
double magnitude = lineSegment.Magnitude();\r
- Vector pointSegment = p - v1;\r
+ Vector pointSegment = p - v2;\r
double t = lineSegment.Dot(pointSegment) / (magnitude * magnitude);\r
-\r
return t;\r
}\r
\r
+\r
+// Return the normal to the linesegment formed by the passed in points.\r
+// (Not sure which is head or tail, or which hand the normal lies)\r
+/*static*/ Vector Vector::Normal(Vector v1, Vector v2)\r
+{\r
+ Vector v = (v1 - v2).Unit();\r
+ return Vector(-v.y, v.x);\r
+}\r
+\r