RotaTion

A 2D roration is applied to an object by repositioning it along a circular path in the xy plane.

We first determine the transformation equations for rotation of a point position P when the pivot point is at the coordinate origin.

Rotation of a point from position (x, y) to position (x'. y') through an angle a2 relative to the coordinate origin
The original angular displacement of the point from the x axis is a1
The constand distance of the point from the origin is r


Using standard trigonometric identities, we can express the transformed coordinates in terms of angles a1 and a2 as:

Rotated coordinates about the origin(0, 0):

x'=r*cos(a1+a2)= r*cos(a1)*cos(a2) - r*sin(a1)*sin(a2)
y =r*sin(a1+a2) = r*cos(a1)*sin(a2) + r*sin(a1)*cos(a2)

Original coordinates:

x=r*cos(a1)
y=r*sin(a1)

Therefore:

Rotated coordinates about the origin(0, 0):

x¡¦= x*cos(a2) - y*sin(a2)
y¡¦= x*sin(a2) + y*cos(a2)

Let's apply the rotation to a digital image:

For example:

The new position of point (4,2) with rotation angle=30 degree:

x'= 4*cos(30) - 2*sin(30) =2.45 --> 2
y'= 4*sin(30) + 2*cos(30) = 3.7 --> 3

Handling Empty Pixels - Copying

Similar to scaling, rotation will create some "holes" in the resulting image.

Again, using the same solution --- Copy pixel values from neighbours

Common approach - just copy any one!

Result:

pivot point = (0, 0 )

Let's do it by using pen and graph paper:

6X Zoom

6X Zoom

2X Zoom

1X Zoom