Computer Graphics Rotation
Last Updated :
04 Jan, 2023
Rotation is one of the part of computer graphic's transformation, Transformation means to change some graphics into something else with the help of rules. There are various types of transformations like translation, scaling, rotation, shearing, reflection etc. it helps to change the object's position, size, orientation, shape, etc. When a transformation takes place on a 2D plane, it is called 2D transformation.
2D Rotation in Computer Graphics:
Rotation is another useful transformation technique in computer graphics in this, the rotation of an object is about specified pivot point. In rotation, the object is rotated θ about the origin. In rotation the given point or figure is just rotated along with some angle theta by keeping the r same it means it is rotating in a circular manner.
Now here, from the following figure, let point P X,Y is located at angle φ from the horizontal X coordinate with distance r from the origin. and we want to rotate it at the angle θ. so After rotating it to a coordinates, the new points will be P’ X′,Y′.
Now to get the new rotated coordinates we will use some trigonometric identities, coordinate of point P X,Y can be represented as :
X=rcosϕ ------eq(1)
Y=rsinϕ ------eq(2)
in similar fashion we can represent P' X',Y'
x′=rcos(ϕ+θ)=rcosϕcosθ−rsinϕsinθ ----eq(3)
y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ ----eq(4)
now put the equations 1,2 in 3, 4 we will get our coordinates x' and y'
x′=xcosθ−ysinθ
y′=xsinθ+ycosθ
We can represent the above equations in matrix form also, like
[X′Y′]=[XY][cosθ−sinθsinθcosθ]
OR
P’ = P . R
Here R is the rotation matrix
R=[cosθ−sinθsinθcosθ]
There are various figures we can rotate like point rotation, line rotation, polygon rotation etc.
Now, let's consider an example of point rotation:
we have a line segment with point as (0, 0) and ending point as (5, 5). and we want to rotate it 30 degree anticlockwise direction on the line segment and find out the new coordinates of the line.
Let new ending coordinates of the line after rotation = (X', Y'). and X=5, Y=5
By using the rotation equations, we have-
X':
= X * cosθ – Y * sinθ
= 5 * cos30º – 5 * sin30º
= 5 * (√3 / 2) – 5 * (1 / 2)
= 5(√3/2 – 1/2)
= 5(0.866 – 0.5)
= 1.83
Y':
= X * sinθ + Y * cosθ
= 5 * sin30º + 5 * cos30º
= 5 * (1 / 2) + 5 * (√3 / 2)
= 5(1/2 + √3/2)
= 5(0.5 + 0.866)
= 6.83
Thus, New ending coordinates of the line after rotation = (1.83, 6.83).
Similar Reads
Computer Graphics - 3D Rotation Transformations
Rotation in 3D is more nuanced as compared to the rotation transformation in 2D, as in 3D rotation we have to deal with 3-axes (x, y, z). Rotation about an arbitrary axis There are three kinds of arbitrary rotation, here we can rotate an object just parallel(or along) a specific axis so that the coo
4 min read
Rotation Matrix
A Rotation Matrix is a type of transformation matrix used to rotate vectors in a Euclidean space. It applies matrix multiplication to transform the coordinates of a vector, rotating it around the origin without altering its shape or magnitude.Rotation matrices are square matrices with real entries a
11 min read
Concepts of Rotational Motion
Rotational motion refers to the movement of an object around a fixed axis. It is a complex concept that requires an understanding of several related concepts. Some of the important concepts related to rotational motion include angular displacement, angular velocity, angular acceleration, torque, the
10 min read
Rotational Latency
The time required by the read/write head to move from the current sector to the desired sector is called the rotational latency. The rotational latency can be calculated by dividing the angle between the current sector and the desired sector by the rotational frequency. The formula for calculating t
4 min read
Primer CSS Rotation Animation
Primer CSS animations are generally used to get the user's attention towards the animating element and for a better user experience. In this article, we will be seeing Primer CSS Rotation Animation. To apply the rotation animation to an element, we have to add the anim-rotate class to the element. A
2 min read
Semantic-UI Icon Rotated Variation
Semantic UI open-source framework gives icons or glyphs that are used to show pictures related to some elements using CSS and jQuery that is used to create great user interfaces. It is a development framework used to create beautiful and responsive layouts. Semantic UI Icon is a glyph that is used t
2 min read
Android Jetpack Compose - Rotation Animation
Jetpack Compose is a new UI toolkit from Google used to create native Android UI. It speeds up and simplifies UI development using less code, Kotlin APIs, and powerful tools.Prerequisites:Familiar with Kotlin and OOP Concepts as wellBasic understanding of Jetpack ComposeSteps to Implement Rotation A
3 min read
CSS Rotate Property
The rotate property in CSS is used to rotate or spin elements on a webpage. It allows us to rotate HTML elements like text, images, buttons, and more. In this article, we are going to learn how the rotate property works.Syntax: transform: rotate(angle).These are the following topics that we are goin
4 min read
Real-Life Examples of Rotation in Maths
Rotation in math's refers to a type of transformation where an object is moved in a circular motion around a center, axis, or fixed point. This transformation involves rotating each point in a figure by a certain number of degrees around a given point.The result of a rotation is a new figure called
6 min read
How to Resize Rotation Radius using CSS ?
In dynamic CSS, you can resize rotation radius using CSS Custom Properties (Variables). As custom properties are now in the latest browsers from Mozilla, Google, Opera, Apple, and Microsoft â itâs definitely a good time to explore and experiment. The pre-requisites to learn CSS Variables and CSS var
2 min read