struct DPoint
{
    float X;
	float Y;
	DPoint()
	{
		X = 0.0f;
		Y = 0.0f;
	}
	DPoint(float _X, float _Y)
	{
		X = _X;
		Y = _Y;
	}
	void swap(DPoint&a, DPoint&b)
	{
		std::swap(a.X ,b.X);
		std::swap(a.Y ,b.Y);
	}
	DPoint operator=(DPoint a)
	{
		DPoint::swap(*this,a);
		return *this;
	}
};

bool operator<(DPoint const& a, DPoint const& b)
{
	if(a.X >= b.X)return false;
	if(a.Y >= b.Y)return false;
	return true;
}

bool operator>(DPoint const& a, DPoint const& b)
{
	if(a.X <= b.X)return false;
	if(a.Y <= b.Y)return false;
	return true;
}

bool operator==(DPoint const& a, DPoint const& b)
{
	if(a.X != b.X)return false;
	if(a.Y != b.Y)return false;
	return true;
}

bool operator==(DPoint const& a, float b)
{
	if(a.X != b)return false;
	if(a.Y != b)return false;
	return true;
}

bool operator==(float b,DPoint const& a)
{
	if(a.X != b)return false;
	if(a.Y != b)return false;
	return true;
}

DPoint operator-(DPoint const& a, DPoint const& b)
{
	return DPoint(a.X-b.X,a.Y-b.Y);
}

DPoint operator-(DPoint const& a, float b)
{
	return DPoint(a.X-b,a.Y-b);
}

DPoint operator-(float a, DPoint const& b)
{
	return DPoint(a-b.X,a-b.Y);
}

DPoint operator+(DPoint const& a, DPoint const& b)
{
	return DPoint(a.X+b.X,a.Y+b.Y);
}

DPoint operator+(DPoint const& a, float b)
{
	return DPoint(a.X+b,a.Y+b);
}

DPoint operator+(float a, DPoint const& b)
{
	return DPoint(a+b.X,a+b.Y);
}

DPoint operator/(DPoint const& a, DPoint const& b)
{
	return DPoint(a.X/b.X,a.Y/b.Y);
}

DPoint operator/(DPoint const& a, float b)
{
	return DPoint(a.X/b,a.Y/b);
}

DPoint operator/(float a, DPoint const& b)
{
	return DPoint(a/b.X,a/b.Y);
}

DPoint operator*(DPoint const& a, DPoint const& b)
{
	return DPoint(a.X*b.X,a.Y*b.Y);
}

DPoint operator*(DPoint const& a, float b)
{
	return DPoint(a.X*b,a.Y*b);
}

DPoint operator*(float a, DPoint const& b)
{
	return DPoint(a*b.X,a*b.Y);
}

DPoint function_u(DPoint input)
{
	return input / (sqrt((input.X * input.X) + (input.Y * input.Y))); // (1)
}

DPoint function_r(DPoint input)
{
	return function_u(DPoint(input.Y, -input.X)); // (2)
}
vector <cell> PolygonTemp;


//somewhere here 
  
  DPoint temp[4];
					temp[0] = DPoint(Thread_xNode[tbcway.at(0)].xPOS,Thread_xNode[tbcway.at(0)].yPOS);
					temp[1] = DPoint(Thread_xNode[tbcway.at(1)].xPOS,Thread_xNode[tbcway.at(1)].yPOS);

					temp[2] = temp[0] - (function_r(temp[1] - temp[0]) * RecievedData.Width);
					temp[3] = temp[0] + (function_r(temp[1] - temp[0]) * RecievedData.Width);

					PolygonTemp.push_back(amx_ftoc(temp[2].X));
					PolygonTemp.push_back(amx_ftoc(temp[2].Y));
					PolygonTemp.push_back(amx_ftoc(temp[3].X));
					PolygonTemp.push_back(amx_ftoc(temp[3].Y));

					for(unsigned int k = 1; k < tbcway.size(); ++k)
					{
						temp[0] = DPoint(Thread_xNode[tbcway.at(k)].xPOS,Thread_xNode[tbcway.at(k)].yPOS);
						temp[1] = DPoint(Thread_xNode[tbcway.at(k+1)].xPOS,Thread_xNode[tbcway.at(k+1)].yPOS);
						temp[2] = DPoint(Thread_xNode[tbcway.at(k-1)].xPOS,Thread_xNode[tbcway.at(k-1)].yPOS);

						temp[3] = temp[0] + (function_r(function_u(temp[1] - temp[0]) - function_u(temp[2] - temp[0])) * RecievedData.Width);
					
						PolygonTemp.push_back(amx_ftoc(temp[3].X));
						PolygonTemp.push_back(amx_ftoc(temp[3].Y));
					}

					temp[0] = DPoint(Thread_xNode[tbcway.at(tbcway.size()-1)].xPOS,Thread_xNode[tbcway.at(tbcway.size()-1)].yPOS);
					temp[1] = DPoint(Thread_xNode[tbcway.at(tbcway.size()-2)].xPOS,Thread_xNode[tbcway.at(tbcway.size()-2)].yPOS);

					temp[2] = temp[0] - (function_r(temp[1] - temp[0]) * RecievedData.Width);
					temp[3] = temp[0] + (function_r(temp[1] - temp[0]) * RecievedData.Width);

					PolygonTemp.push_back(amx_ftoc(temp[2].X));
					PolygonTemp.push_back(amx_ftoc(temp[2].Y));
					PolygonTemp.push_back(amx_ftoc(temp[3].X));
					PolygonTemp.push_back(amx_ftoc(temp[3].Y));

					for(int k = tbcway.size()-1; k > 0; --k)
					{
						temp[0] = DPoint(Thread_xNode[tbcway.at(k)].xPOS,Thread_xNode[tbcway.at(k)].yPOS);
						temp[1] = DPoint(Thread_xNode[tbcway.at(k+1)].xPOS,Thread_xNode[tbcway.at(k+1)].yPOS);
						temp[2] = DPoint(Thread_xNode[tbcway.at(k-1)].xPOS,Thread_xNode[tbcway.at(k-1)].yPOS);

						temp[3] = temp[0] - (function_r(function_u(temp[1] - temp[0]) - function_u(temp[2] - temp[0])) * RecievedData.Width);
					