2D Transformation Part 1 by foridulislam

View this thread on steempeak.com
· @foridulislam · (edited)
$0.10
2D Transformation Part 1
ransformation means changing some graphics into something else by applyingrules. We can have various types oftransformationssuch as translation, scaling up or down, rotation,shearing, etc. When a transformation takes place ona 2D plane, it is called2D transformation.Transformations play an important role in computer graphics to reposition the graphics on thescreen and change their size or orientation.Homogenous CoordinatesTo performa sequence of transformation such as translation followed by rotation and scaling, we needto follow a sequential process −Translate the coordinates,Rotate the translated coordinates, andthenScalethe rotated coordinates to complete the composite transformation.To shorten this process,we haveto use 3×3 transformation matrix instead of 2×2 transformation matrix. To convert a 2×2 matrix to 3×3 matrix, we haveto add an extradummy coordinate W.In this way, we can represent the point by 3 numbers instead of 2 numbers, whichis calledHomogenous Coordinatesystem. In this system, we can represent all the transformation equations in matrix multiplication. Any Cartesian point P(X, Y) can be converted to homogenous coordinates by P’ (Xh, Yh, h).TranslationA translation moves an object to a different positionon the screen. You cantranslate a point in 2D by adding translation coordinate (tx, ty) to the original coordinate (X, Y) to get the new coordinate (X’, Y’).
![20180121083203.jpg](https://steemitimages.com/DQmXk2RM8R4NRRqEzAsYetz3XMd7P726kSEjotg3B6mWUmu/20180121083203.jpg)


from the above figure, you can write that -
X’ = X + txY’ = Y + ty
The pair(tx, ty) is calledthe translation vector or shift vector. The above equations can also be represented using the column vectors.


$P =\frac{[X]}{[Y]}$p'=$\frac{[X']}{[Y']}$T=$\frac{[t_{x}]}{[t_{y}]}$



We can write it as −  P’ = P + T
RotationIn rotation,we rotate the object at particular angleθ (theta) from its origin. From the following figure,we can see thatthe point P(X, Y) is located at angleφ from the horizontal X coordinate withdistance r fromthe origin.Let us supposeyou want to rotate itat the angle θ. After rotating it to a new location,you will get a new point P’ (X’, Y’).
![20180121083644.jpg](https://steemitimages.com/DQmVbtLK3jVFBsNQSgtWbaNXMYhBcqotJXpsS6oNGCfNaQo/20180121083644.jpg)


Using standard trigonometric the original coordinate of point P(X, Y) can be represented as −

$X = r \, cos \,\phi ...... (1)$$Y = r \, sin \,\phi ...... (2)$
Same way we can represent the point P’ (X’, Y’) as −


${x}'= r\: cos \:\left ( \phi \:+ \:\theta\right ) =r\: cos \:\phi \: cos \:\theta \: − \: r \: sin \:\phi \: sin \:\theta....... (3)$${y}'= r\: sin \:\left ( \phi \:+ \:\theta\right ) =r\: cos \:\phi \: sin \:\theta \:+ \: r \: sin \:\phi \: cos \:\theta....... (4)$



Substituting equation (1) & (2) in (3) & (4)respectively, we will get
${x}'= x\: cos \:\theta −\: y \: sin\: \theta$${y}'= x\: sin \:\theta +\: y \: cos \:\theta $

Representing the above equation in matrix form,$$[X' Y']= [X Y]\begin{bmatrix} cos\theta & sin\theta \\ −sin\theta & cos\theta\end{bmatrix}OR$$P’ = P . RWhere Ris the rotation matrix$$R =\begin{bmatrix} cos\theta & sin\theta \\ −sin\theta & cos\theta\end{bmatrix}$$The rotation angle can be positive and negative.For positive rotation angle, we can use the above rotation matrix. However, for negative angle rotation,the matrix will change as shown below −$$R =\begin{bmatrix} cos(−\theta) & sin(−\theta) \\ -sin(−\theta)& cos(−\theta)\end{bmatrix}$$$$=\begin{bmatrix} cos\theta & −sin\theta \\ sin\theta & cos\theta\end{bmatrix}\left (\because cos(−\theta ) = cos\theta \; and\; sin(−\theta ) = −sin\theta\right)$$ScalingTo change the size of an object, scaling transformation is used. In the scaling process,you either expand or compress the dimensions of the object. Scaling can be achieved by multiplying the original coordinates of the object with thescaling factor to get the desired result.Let us assumethat the original coordinates are(X, Y), the scaling factors are (SX,SY), and the produced coordinates are(X’, Y’). This canbe mathematically represented as shown below −

X' = X . SXandY' = Y . SY



The scaling factor SX, SYscales the object in X andY direction respectively. The above equations can also be represented in matrix form as below −$$\binom{X'}{Y'} =\binom{X}{Y}\begin{bmatrix} S_{x} & 0\\ 0 & S_{y}\end{bmatrix}$$ORP’ = P . SWhere Sis the scaling matrix. The scaling process is shown in the following figure.

![20180121084053.jpg]
(https://steemitimages.com/DQmW7xRYCKwnV776MsnB3MSnXEkXcTxn6HhQWCTnU3HA6kP/20180121084053.jpg)

f we provide values less than 1 to the scaling factor S,then wecan reduce the size of the object. If we provide values greater than 1, then wecan increase the size of the object.ReflectionReflection is the mirror image of original object. In other words, we can say thatit is a rotation operation with 180°. In reflection transformation, the size of the object does not change.The following figures show reflections with respect to X andY axes, and about the origin respectively.
👍  , , , , ,
properties (23)
post_id26,950,448
authorforidulislam
permlink2d-transformation-part-1
categorydlive-broadcast
json_metadata"{"app": "steemit/0.1", "format": "markdown", "image": ["https://steemitimages.com/DQmXk2RM8R4NRRqEzAsYetz3XMd7P726kSEjotg3B6mWUmu/20180121083203.jpg"], "tags": ["dlive-broadcast", "nature", "chaina", "graphics"]}"
created2018-01-21 02:43:21
last_update2018-01-21 02:45:27
depth0
children2
net_rshares8,946,855,593
last_payout2018-01-28 02:43:21
cashout_time1969-12-31 23:59:59
total_payout_value0.096 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length5,085
author_reputation497,355,204,219
root_title"2D Transformation Part 1"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (6)
@cheetah ·
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://www.tutorialspoint.com/computer_graphics/pdf/2d_transformation.pdf
properties (22)
post_id26,950,488
authorcheetah
permlinkcheetah-re-foridulislam2d-transformation-part-1
categorydlive-broadcast
json_metadata{}
created2018-01-21 02:43:39
last_update2018-01-21 02:43:39
depth1
children0
net_rshares0
last_payout2018-01-28 02:43:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length173
author_reputation750,854,098,279,735
root_title"2D Transformation Part 1"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@juborajmollah ·
nice post bro   @foridulislam
properties (22)
post_id27,012,650
authorjuborajmollah
permlinkre-foridulislam-2d-transformation-part-1-20180121t102848171z
categorydlive-broadcast
json_metadata"{"app": "steemit/0.1", "users": ["foridulislam"], "tags": ["dlive-broadcast"]}"
created2018-01-21 10:28:54
last_update2018-01-21 10:28:54
depth1
children0
net_rshares0
last_payout2018-01-28 10:28:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length29
author_reputation186,685,725,170
root_title"2D Transformation Part 1"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000