Sign in to follow this  

Image Rotation

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
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.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this