#include "StdAfx.h" #include "Location.h" #using using namespace System; const double Pi = Math::PI; void Location::MoveBy(int angle, double d) { double radians = angle*Pi/180; x += d * Math::Cos(radians); y += d * Math::Sin(radians); } void Location::MoveBy(Direction angle, double d) { switch( angle ){ case East: x += d; return; case West: x -= d; return; case North: y += d; return; case South: y -= d; return; default: MoveBy(angle, d); } } inline double sqr(double x) { return x*x; } double Location::Distance(Location &a, Location &b) { return Math::Sqrt( sqr(a.X-b.X) + sqr(a.Y-b.Y) ); }