Скачиваний:
14
Добавлен:
01.05.2014
Размер:
2.49 Кб
Скачать
#ifndef CPP001
#define CPP001

#include "cPoint.h"

cPoint::cPoint(double x1,double y1)
 {
  SetXY(x1,y1);
  inv();
 }

cPoint::cPoint()
 {
  SetXY(0.0,0.0);
 }


cPoint::~cPoint (){}


void cPoint::GetXY(double &x1, double &y1)
{
 x1 = GetX();
 y1 = GetY();
};

void cPoint::inv()
{
 if ( (x > MAXFLOAT) || (x < -MAXFLOAT) || (y > MAXFLOAT) || (y < -MAXFLOAT))

 {
 clrscr();
 cout<<"incorrect conditions";
 getch();
 exit(1);
 }
}



void cPoint::SetXY(double x1,double y1)
{
 if ((x1 > MAXFLOAT)||(x1 < -MAXFLOAT)||(y1 > MAXFLOAT)||(y1 < -MAXFLOAT))
 {
	clrscr();
	cout<<"incorrect conditions";
	getch();
	exit(1);
 };
 x=x1;
 y=y1;

// inv();
}//SetXY





void cPoint::Move(double dx,double dy)
{
 if ((dx > MAXFLOAT)||(dx < -MAXFLOAT)||(dy > MAXFLOAT)||(dy < -MAXFLOAT))
 {
	clrscr();
			cout<<"incorrect conditions";
			getch();
	exit(1);
 };
 inv();
 double x1,y1;
 x1=GetX();
 y1=GetY();
 x1+=dx;
 y1+=dy;
 SetXY(x1,y1);
 inv();
}//Move


void cPoint::Rotate(double x0, double y0, double alpha)
{
 if ((x0 > MAXFLOAT)||(x0 < -MAXFLOAT)||(y0 > MAXFLOAT)||(y0 < -MAXFLOAT))
 {
 clrscr();
			cout<<"incorrect conditions";
			getch();
 exit(1);
 };
 inv();
 double x1,y1,c,s,x11,x12,y11,y12;
 x1=GetX();
 y1=GetY();
 c=cos(alpha);
 s=sin(alpha);
 x11=(x1-x0)*c;
 x12=(y1-y0)*s;
 y11=(y1-y0)*c;
 y12=(x1-x0)*s;
 x1=x11-x12+x0;
 y1=y11+y12+y0;
 SetXY(x1,y1);
 inv();
}//Rotate



void cPoint::Mirror(double x0, double y0)
{
 inv();
 if ((x0 > MAXFLOAT)||(x0 < -MAXFLOAT)||(y0 > MAXFLOAT)||(y0 < -MAXFLOAT))
 {
 clrscr();
			cout<<"incorrect conditions";
			getch();
 exit(1);
 };
 double x1,y1;
 x1=GetX();
 y1=GetY();
 x1=2*x0-x1;
 y1=2*y0-y1;
 SetXY(x1,y1);
 inv();
}

double cPoint::GetX()
{
 return x;
}//GetX

double cPoint::GetY()
{
 return y;
}//GetY


double cPoint::Distance(double x0,double y0)
{
 if ((x0 > MAXFLOAT)||(x0 < -MAXFLOAT)||(y0 > MAXFLOAT)||(y0 < -MAXFLOAT))
 {
 clrscr();
			cout<<"incorrect conditions";
			getch();
 exit(1);
 };
 inv();
 double x1,y1,ans;
 x1=GetX();
 y1=GetY();
 ans=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
 if (ans>MAXFLOAT)
 {
	clrscr();
			cout<<"incorrect result";
			getch();
	exit(1);
 }
 inv();
 return ans;
};

cPoint cPoint::Get()
{
 cPoint P;
 P.SetXY(GetX(),GetY());
 return P;
}

void cPoint::out()
{
 cout<<"("<<GetX()<<";"<<GetY()<<")  ";
}

#endif

Соседние файлы в папке l3