• Advertisement
Sign in to follow this  

Image Rotation

This topic is 4165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i trying to write image rotation code and wouldliketo be able to work out the width and height of the rotated image as the angle of rotation increase, but i can get hte right formula. here and image of what i mean thanks

Share this post


Link to post
Share on other sites
Advertisement
When you rotate by a small amount, the left-vertical side gets 'smaller' while the top-horizontal gets bigger (as projected to a vertical line). The height of the resulting canvas is the sum of these two.

The projected height of the verticals of any rectangle are
h' = h.cos(theta)
and similarly, the projected height of the horizontals are:
w' = w.sin(theta)

So the overall height of the image becomes
H = h.cos(theta) + w.sin(theta)
A similar calculation finds the canvas width to be
W = h.sin(theta) + w.cos(theta)

Since you are working with a square, these values become one and the same:
L = l(sin(theta) + cos(theta))
L = l.sqrt(2).sin(theta + pi/4)
where l = 8, in the diagram.

Regards
Admiral

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement