
I have two rectangles inner rectangle(green) and the outer one (red).
OuterRectangle will be calculated by adding some offset to inner rectangle as shown below.
OuterLeft = innerLeft - 100; OuterTop = innerTop - 100; OuterRight = innerRight + 100; OuterBottom = innerBottom + 100;
But this will not work once the inner rectangle is rotated . Please let me know how can i calculate outer rectangle based on inner rectangle after rotation by some angle.
Thanks in advance
If you knew the rotation angle, you could simply apply the same rotation to the outer rectangle. So I assume that you only have to corner points of the (rotated) inner rectangle.
Let $p_0, p_1, p_2, p_3$ be the points of the inner rectangle, ordered counterclockwise (starting at the upper left corner, in this case). Then you can compute the vectors describing the edges
and the corresponding directions, by normalizing these vectors
$d_i = e_i / |e_i|$ for $i = 0...3$
The corners of the outer rectangle can then be computed based on the original points and these direction vectors. Let $s_t, s_l, s_b, s_r$ denote the offset of the outer rectangle at the top, left, bottom and right side, respectively (in your case, they are all 100).
(This is not really related to trigonometry, by the way)