Javatpoint Logo
Javatpoint Logo

Rotation:

It is a process of changing the angle of the object. Rotation can be clockwise or anticlockwise. For rotation, we have to specify the angle of rotation and rotation point. Rotation point is also called a pivot point. It is print about which object is rotated.

Types of Rotation:

  1. Anticlockwise
  2. Counterclockwise

The positive value of the pivot point (rotation angle) rotates an object in a counter-clockwise (anti-clockwise) direction.

The negative value of the pivot point (rotation angle) rotates an object in a clockwise direction.

When the object is rotated, then every point of the object is rotated by the same angle.

Straight Line: Straight Line is rotated by the endpoints with the same angle and redrawing the line between new endpoints.

Polygon: Polygon is rotated by shifting every vertex using the same rotational angle.

Curved Lines: Curved Lines are rotated by repositioning of all points and drawing of the curve at new positions.

Circle: It can be obtained by center position by the specified angle.

Ellipse: Its rotation can be obtained by rotating major and minor axis of an ellipse by the desired angle.

Rotation
Rotation

Matrix for rotation is a clockwise direction.

Rotation

Matrix for rotation is an anticlockwise direction.

Rotation

Matrix for homogeneous co-ordinate rotation (clockwise)

Rotation

Matrix for homogeneous co-ordinate rotation (anticlockwise)

Rotation

Rotation about an arbitrary point: If we want to rotate an object or point about an arbitrary point, first of all, we translate the point about which we want to rotate to the origin. Then rotate point or object about the origin, and at the end, we again translate it to the original place. We get rotation about an arbitrary point.

Example: The point (x, y) is to be rotated

The (xc yc) is a point about which counterclockwise rotation is done

Step1: Translate point (xc yc) to origin

Rotation

Step2: Rotation of (x, y) about the origin

Rotation

Step3: Translation of center of rotation back to its original position

Rotation
Rotation

Example1: Prove that 2D rotations about the origin are commutative i.e. R1 R2=R2 R1.

Solution: R1 and R2are rotation matrices

Rotation

Example2: Rotate a line CD whose endpoints are (3, 4) and (12, 15) about origin through a 45° anticlockwise direction.

Solution: The point C (3, 4)

Rotation
Rotation
Rotation

Example3: Rotate line AB whose endpoints are A (2, 5) and B (6, 12) about origin through a 30° clockwise direction.

Solution: For rotation in the clockwise direction. The matrix is

Rotation

Step1: Rotation of point A (2, 5). Take angle 30°

Rotation

Step2: Rotation of point B (6, 12)

Rotation
Rotation

Program to rotate a line:

Output:

Before rotation

Rotation
Rotation
Rotation

After rotation

Rotation

Program to rotate a Triangle:

Output:

Before rotation

Rotation
Rotation
Rotation

After rotation

Rotation
Next TopicReflection




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA