X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvector.cpp;h=23bd783cf2fcce61dd3c6ab6627972ca7678813a;hb=70297ac8ec7453e4196f4b58056bcfe4b04f2aca;hp=ab1433f9c6a5123e6ca6a8475cbe852210ecb933;hpb=11802354d1ddc5bc571d83d8fc9b600618cb4372;p=architektonas diff --git a/src/vector.cpp b/src/vector.cpp index ab1433f..23bd783 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -248,7 +248,15 @@ double Vector::Parameter(Vector v1, Vector v2, Vector p) double magnitude = lineSegment.Magnitude(); Vector pointSegment = p - v1; double t = lineSegment.Dot(pointSegment) / (magnitude * magnitude); - return t; } + +// Return the normal to the linesegment formed by the passed in points. +// (Not sure which is head or tail, or which hand the normal lies) +/*static*/ Vector Vector::Normal(Vector v1, Vector v2) +{ + Vector v = (v2 - v1).Unit(); + return Vector(-v.y, v.x); +} +