public Rectangle getBBRelativeToWorld()
{
List<Vector2> newPts = new List<Vector2>();
Vector2 halfDim = new Vector2(Width / 2, Height / 2); // this is a hack to place the objects at their center correctly
newPts.Add(mapPointOnImage(boundingBox.X, boundingBox.Y) - halfDim);
newPts.Add(mapPointOnImage(boundingBox.X, Height + boundingBox.Y) - halfDim);
newPts.Add(mapPointOnImage(Width + boundingBox.X, boundingBox.Y) - halfDim);
newPts.Add(mapPointOnImage(Width + boundingBox.X, Height + boundingBox.Y) - halfDim);
float max_y = newPts[0].Y;
float min_y = newPts[0].Y;
float max_x = newPts[0].X;
float min_x = newPts[0].X;
foreach (Vector2 pt in newPts)
{
if (pt.X > max_x)
{
max_x = pt.X;
}
else if (pt.X < min_x)
{
min_x = pt.X;
}
if (pt.Y > max_y)
{
max_y = pt.Y;
}
else if (pt.Y < min_y)
{
min_y = pt.Y;
}
}
min_x -= boundingBox.X; // *horizontalScale;
min_y -= boundingBox.Y; // *verticalScale;
max_x -= boundingBox.X; // *horizontalScale;
max_y -= boundingBox.Y; // *verticalScale;
return (new Rectangle(
(int)min_x,
(int)min_y,
(int)(max_x - min_x),
(int)(max_y - min_y)));
}