javascript - How can I calculate the size of an outer rectangle when it is rotated and must encompass an inner rectangle totally -
I have many answered questions, explaining how to calculate the bounding box of the curved rectangle But what i need to do is reverse
Red Rectangle A
is described as:
var box = {x: 0, y: 0, w: 100, h : 200};
And the dimension of blue rectangle b
is exactly , when it is rotated not .
Given that the rectangle B
has been rotated around its center point and given in the angle of radians, I use the minimum size Rectangle <<> B may occur when rectangular A
should always fit inside it while maintaining its original aspect ratio (as previously mentioned, rectangular A
similar)
If you label edges of rectangles and attract an extra line (green in the diagram), you can see what you need to calculate:
then c = a * Cos (θ) + b * sin (Θ)
and d = b * c / a
Comments
Post a Comment