class Vector2D { float x; float y; Vector2D() { x = y = 0.0; } Vector2D( float newX, float newY ) { x = newX; y = newY; } void Add( Vector2D add ) { x += add.x; y += add.y; } void Multiply( float val ) { x *= val; y *= val; } float DotProduct( Vector2D dot ) { return( dot.x*x + dot.y*y ); } void RotateByAngle( float angle ) { if( angle == 0.0 ) { return; } float tempX = x; float tempY = y; x = tempX*cos(angle) - tempY*sin(angle); y = tempX*sin(angle) + tempY*cos(angle); } float GetRadiansFromVector() { return( atan2(y, x) ); } float Magnitude() { return( sqrt( x*x + y*y ) ); } float MagnitudeSquared() { return( x*x + y*y ); } void Normalize() { float magnitude = Magnitude(); if( magnitude != 0.0 ) { x /= magnitude; y /= magnitude; } } void Negative() { x = -x; y = -y; } void Zero() { x = y = 0.f; } void Set( float X, float Y ) { x = X; y = Y; } }