X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvector.cpp;h=6147c6d71d4021c0e10744b482e2b7796bb93c72;hb=7f3a6b11585376eecd80979ec3da2346c5314d88;hp=11ddb6494962b724e8166b05502baa27612c0295;hpb=c85958d34fac175452fe420ff24ea82f26d6f1f3;p=architektonas diff --git a/src/vector.cpp b/src/vector.cpp index 11ddb64..6147c6d 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -31,6 +31,15 @@ Vector::Vector(Vector tail, Vector head): x(head.x - tail.x), y(head.y - tail.y) } +// Create vector from angle + length (2D; z is set to zero) +void Vector::SetAngleAndLength(double angle, double length) +{ + x = cos(angle) * length; + y = sin(angle) * length; + z = 0; +} + + Vector Vector::operator=(Vector const v) { x = v.x, y = v.y, z = v.z; @@ -257,10 +266,8 @@ double Vector::Parameter(Vector tail, Vector head, Vector p) // (Not sure which is head or tail, or which hand the normal lies) // [v1 should be the tail, v2 should be the head, in which case the normal should // rotate anti-clockwise.] -///*static*/ Vector Vector::Normal(Vector v1, Vector v2) /*static*/ Vector Vector::Normal(Vector tail, Vector head) { -// Vector v = (v1 - v2).Unit(); Vector v = (head - tail).Unit(); return Vector(-v.y, v.x); }