2D Rotation in Computer Graphics
The Rotation of any object depends upon the two points.
Rotation Point: It is also called the Pivot point.
Rotation Angle: It is denoted by Theta (?).
We can rotate an object in two ways-
Clockwise: An object rotates clockwise if the value of the Rotation angle is negative (-).
Anti-Clockwise: An object rotates anti-clockwise if the value of the Rotation angle is positive (+).
We can apply Rotation on following objects-
- Straight Lines
- Curved Lines
- Polygon
- Circle
For Example–
Rotation of a Point: If we want to Rotate a point A (P0, Q0) that has a Rotation angle with ? distance r from origin to A (P1, Q1) that has a Rotation angle ?. Then, we can rotate by following Rotation equation-
P1 = P0 x cos? – Q0 x sin?
Q1 = P0 x sin? + Q0 x cos?
We can represent the coordinates of point A (P0, Q0) by using standard trigonometry-
P0 = r cos?………… (1)
Q0 = r sin?………… (2)
We can also define point A
(P1, Q1) in the same way-
P1 = r cos (?+?) = r cos?cos? — r sin?sin? …………. (3)
Q1 = r sin (?+?) = r cos?sin? + r sin?cos? …………. (4)
By using equation (1) (2) (3) (4), we will get-
P1= P0 cos? — P0 sin?
Q1= P0 sin? + P0 cos?
We can also represent the Rotation in the form of matrix–