#include "2dvector.h" #include #include #define PI 3.141592654 float costable[360]; float sintable[360]; void InitTables() { float temp; for( int i = 0; i<360; i++ ) { temp = ((float)(360-i))/180; temp *= PI; costable[i] = (float)cos( temp ); sintable[i] = (float)sin( temp ); } } C2DVector::C2DVector() { x = 0; y = 0; angle = 0; length = 0; } C2DVector::C2DVector( long Xin, long Yin ) { x = Xin; y = Yin; angle = -1; length = sqrt( Xin*Xin + Yin*Yin ); } C2DVector::~C2DVector() { } void C2DVector::SetX( long Xin ) { x = Xin; } void C2DVector::SetY( long Yin ) { y = Yin; } void C2DVector::SetLength( long Lin ) { length = Lin; x = costable[angle]*length; y = sintable[angle]*length; } void C2DVector::SetAngle( int Ain ) { angle = Ain; x = costable[angle]*length; y = sintable[angle]*length; } long C2DVector::GetX() { return x; } long C2DVector::GetY() { return y; } long C2DVector::GetLength() { return length; } int C2DVector::GetAngle() { return angle; } void C2DVector::operator =(C2DVector aVector) { x = aVector.x; y = aVector.y; length = aVector.length; angle = aVector.angle; }