Пример #1
0
bool quadTree::pointToRectCollision(point2d* point, rectangle rect) {
	if((point->getX() >= rect.getStartPoint()->getX() || FLOAT_EQ(point->getX(),rect.getStartPoint()->getX())) && 
		(point->getX() <= rect.getEndPoint()->getX()|| FLOAT_EQ(point->getX(),rect.getEndPoint()->getX())) && 
		(point->getY() >= rect.getStartPoint()->getY() || FLOAT_EQ(point->getY(),rect.getStartPoint()->getY())) && 
		(point->getY() <= rect.getEndPoint()->getY() || FLOAT_EQ(point->getY(),rect.getEndPoint()->getY())))
	{
		return true;
	}
	return false;
}
Пример #2
0
bool rectangle::isUnder(rectangle rect)
{
	if(start->getX() <= rect.getStartPoint()->getX() && end->getX() >= rect.getEndPoint()->getX() &&
		start->getY() >= rect.getStartPoint()->getY() && end->getY() <= rect.getEndPoint()->getY()) {
		return true;
	}
	return false;
	//if ((start->getX() <= rect.getStartPoint()->getX() && rect.getEndPoint()->getX() >= end->getX()) 
	//	&&(start->getY() >= rect.getStartPoint()->getY() && rect.getEndPoint()->getY() >= end->getY()))
	//{
	//	return true;
	//} else
	//if (( rect.getStartPoint()->getX()<= start->getX() && end->getX() <= rect.getEndPoint()->getX()) 
	//	&&( rect.getStartPoint()->getY() >= start->getY() && rect.getEndPoint()->getY() >=  rect.getEndPoint()->getY()))
	//{
	//	return true;
	//}
	//else
	//{
	//	return false;
	//}
}