# Image Rotation

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

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

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

Regards

##### Share on other sites
great thanks just what i was looking for

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
12

• 14
• 9
• 22
• 9
• 31
• ### Forum Statistics

• Total Topics
632618
• Total Posts
3007485
• ### Who's Online (See full list)

There are no registered users currently online

×