PDA

Click to See Complete Forum and Search --> : Calculate the size of rotating picture


MarkT
Sep 29th, 2003, 11:30 AM
I have a picture that is 100 pixels wide by 200 pixels high. This picture is going into a picture box and will then be rotated at various angles. What I need to be able to figure out is how big the picture box has to be as the picture rotates so I don’t chop any of it off.

JPicasso
Sep 29th, 2003, 01:23 PM
assuming you're rotating about the center, wouldn't this be a classic application of pythagreans' therum?

(100^2 + 200^2)^.5 =223.60679774997896964091736687313

so, each side would need to accomodate 224 pixels. right?

MarkT
Sep 29th, 2003, 04:04 PM
What I'm really looking for is to keep the container only large enough to house the image. While the image may be able to fit within a square that is in the range of 225 square, that is a much larger area than I need when the image is either vertical or rotated 90 degrees.

jemidiah
Sep 29th, 2003, 05:19 PM
Try this:
x = cos(rotation_angle)*height + sin(rotation_angle)*width
y = sin(rotation_angle)*height + cos(rotation_angle)*width

This should work. If it doesn't, let me know.