bool CollisionManager::CircleToRect(double cx, double cy, double cr, double rx, double ry, double rw, double rh) const
{
	double outx = 0;
	double outy = 0;

	ClosestPointToRect(cx, cy, rx, ry, rw, rh, &outx, &outy);

	return SquaredDistance(cx, cy, outx, outy) <= Pow(cr, 2);
}
Beispiel #2
0
bool CollisionManager::CircleToRect(double cx, double cy, double cr, double rx, double ry, double rw, double rh) const
{
	double closestX,closestY;
	
	//buscamos el punto mas cercano desde el centro hasta el rectangulo
	ClosestPointToRect(cx,cy,rx,ry,rw,rh,&closestX,&closestY);
	
	//si la distancia desde el centro al punto mas cercano es menor que el radio colisiona
	return SquareDistance(cx,cy,closestX, closestY) < (cr * cr);
}
Beispiel #3
0
bool CollisionManager::CircleToRect(double cx, double cy, double cr, double rx, double ry, double rw, double rh) const
{
	double closestX, closestY;
	ClosestPointToRect(cx, cy, rx, ry, rw, rh, &closestX, &closestY);
	if (Distance(cx, cy, closestX, closestY) <= cr) {
		return true;
	}
	else {
		return false;
	}
}
bool CollisionManager::CircleToRect(double cx, double cy, double cr, double rx, double ry, double rw, double rh) const {
	if (PointInRect(cx, cy, rx, ry, rw, rh))
		return true;
	else {
		double nearestX;
		double nearestY;
		ClosestPointToRect(cx, cy, rx, ry, rw, rh, &nearestX, &nearestY);

		if (Distance(cx, cy, nearestX, nearestY) <= cr)
			return true;
		else
			return false;
	}
}
bool CollisionManager::CircleToRect(double cx, double cy, double cr,
	double rx, double ry, double rw, double rh) const{
	double outx, outy;
	ClosestPointToRect(cx + cr, cy + cr, rx, ry, rw, rh, &outx, &outy);
	return Distance(cx + cr, cy + cr, outx, outy) < cr;
}