Say a rectangle is rotated x degrees clockwise around it's center point.
Known: The width/height of the inner rectangle, the center point, and the angle.
Desired: The 4 coordinates of each corner of the bounding box.
How can this be calculated?
Say a rectangle is rotated x degrees clockwise around it's center point.
Known: The width/height of the inner rectangle, the center point, and the angle.
Desired: The 4 coordinates of each corner of the bounding box.
How can this be calculated?
If a rectangle with base $b>0$, height $h>0$ and centroid $O$ has vertices:
$$ V_1\left(-\frac{b}{2},-\frac{h}{2}\right), \quad \quad V_2\left(\frac{b}{2},-\frac{h}{2}\right), \quad \quad V_3\left(\frac{b}{2},\frac{h}{2}\right), \quad \quad V_4\left(-\frac{b}{2},\frac{h}{2}\right) $$
the vertices obtained by rotating $\theta\in[0,2\pi)$ clockwise and translating $O$ in $G(x_G,y_G)$ are:
$$ \begin{cases} x_i' = x_G + x_i\cos\theta + y_i\sin\theta \\ y_i' = y_G - x_i\sin\theta + y_i\cos\theta \\ \end{cases} \quad \quad \text{with} \; i=1,2,3,4\,. $$
Therefore, once calculated:
$$ \begin{aligned} & x_{\min} = \min(x_1',x_2',x_3',x_4'), \quad \quad x_{\max} = \max(x_1',x_2',x_3',x_4'); \\ & y_{\min} = \min(y_1',y_2',y_3',y_4'), \quad \quad \; \; y_{\max} = \max(y_1',y_2',y_3',y_4'); \\ \end{aligned} $$
the rectangle that contains it has vertices:
$$ A(x_{\min},y_{\min}), \quad \quad B(x_{\max},y_{\min}), \quad \quad C(x_{\max},y_{\max}), \quad \quad D(x_{\min},y_{\max}). $$