# scale rotating boundingbox

I want to use basic rectangular collision detection. I have a rotating sprite and a method that calculates the bounding box every time in the Update() method. I simply check for intersection between all the lines of the box with all the lines of the other sprite's boxes.

Here is what I have for calculating the corners of the rotating bounding box:

``````double baseAngle = Math.Atan(this.Height / this.Width);
double len = Math.Sqrt(this.Height * this.Height / 4 + this.Width * this.Width / 4);

Vector2 tr = new Vector2(
(float)(Math.Sin(baseAngle + this.Rotation) * len) + this.Position.X,
(float)(Math.Cos(baseAngle + this.Rotation) * len) + this.Position.Y);
Vector2 tl = new Vector2(
(float)(Math.Sin(Math.PI - baseAngle + this.Rotation) * len) + this.Position.X,
(float)(Math.Cos(Math.PI - baseAngle + this.Rotation) * len) + this.Position.Y);
Vector2 bl = new Vector2(
(float)(Math.Sin(Math.PI + baseAngle + this.Rotation) * len) + this.Position.X,
(float)(Math.Cos(Math.PI + baseAngle + this.Rotation) * len) + this.Position.Y);
Vector2 br = new Vector2(
(float)(Math.Sin(2 * Math.PI - baseAngle + this.Rotation) * len) + this.Position.X,
(float)(Math.Cos(2 * Math.PI - baseAngle + this.Rotation) * len) + this.Position.Y);`
``````

My box is square shaped, and my texture of that rotating sprite is Rectangular. How can I scale the bounding box so it will be closer to the texture's size?

-
Might be easier if you scale it then rotate it. I'm not really clear on what the problem is, what about your current code isn't working? – Byte56 May 28 '13 at 18:03
I don't know how to scale it because I am not making an actual rectangle like the Rectangle class, I am just calculating the points where the boundingbox should be and when I draw lines between the corners a rectangle appears. If i want to scale it I somehow need to calculate those points to be moved but since the texture is rotating and thus the points I don't know how to do that – Kanga May 28 '13 at 20:50