Reputation: 13
I can get the bounding box of sheared or rotated rectangle using this formula
shearedW = Abs(Tan(shearX) * Height) + Width
shearedH = Abs(Tan(shearY) * Width) + Height
rotatedW = Abs(Cos(angle) * Width) + Abs(Sin(angle) * Height)
rotatedH = Abs(Sin(angle) * Width) + Abs(Cos(angle) * Height)
But how to combine those? I just need to know the width and height. The transformation is done by shearing then rotating the shape.
Upvotes: 1
Views: 704
Reputation: 80287
Just build affine matrix for combined transformation and apply it to vertices, then get differences for y- and x- coordinates.
Note that first pair of formulas is wrong - it gives additional width and heght. Full width:
shearedW = Width + Abs(Tan(shearX) * Height)
Upvotes: 1