2d transformations in Computer Graphics | Computer graphics

2d transformations in Computer Graphics | Computer graphics

Introduction to Transformation

What is Transformation?

  • Transformation refers to changing graphics, such as shifting points or resizing objects. It includes operations like translating, scaling, and rotating.
  • Transformations are represented in a 2D plane.

Translation

  • Translating a point involves shifting it from one position to another on the screen by adding translation values Tx and Ty to its coordinates.
  • For example, if a point has coordinates (X, Y), after translation it becomes (X + Tx, Y + Ty).
  • The values Tx and Ty are referred to as the translation vector.

Rotation of Points

Understanding Rotation

  • Rotation involves turning a point around an origin by an angle theta.
  • When rotating a point P with coordinates (x,y), the new coordinates after rotation can be calculated using trigonometric functions based on the angle theta.

Calculating New Coordinates

  • The new x-coordinate after rotation is given by x' = r cos(theta + phi) , while the y-coordinate is y' = r sin(theta + phi) .
  • The formulas for cosine and sine of sums are applied here:
  • Cosine: cos(a+b)=cos(a)cos(b)-sin(a)sin(b)
  • Sine: sin(a+b)=sin(a)cos(b)+cos(a)sin(b)

Matrix Representation of Transformations

Using Matrices for Transformations

  • Transformations can be represented in matrix form. For instance:
  • The transformation matrix for rotation can be expressed as:

| cos(theta) -sin(theta) |

| sin(theta) cos(theta) |

Row vs Column Major Order

  • Depending on whether you use row major or column major order, the representation of transformations may vary slightly but will yield equivalent results.

Clockwise vs Counterclockwise Rotation

Direction of Rotation

  • The derivation for clockwise rotation differs from counterclockwise. In clockwise rotation:
  • Adjustments are made to account for negative angles when calculating new coordinates.

Final Notes on Rotational Matrices

  • Both clockwise and counterclockwise rotations can be expressed using similar matrix forms; however, attention must be paid to signs in calculations depending on direction.

Scaling and Transformation in Geometry

Understanding Scaling Transformations

  • The discussion begins with the derivation of transformations involving coordinates, specifically focusing on how to express changes in size through scaling.
  • Scaling is defined as a transformation that alters the dimensions of an object, either expanding or compressing it. This process can be applied uniformly or non-uniformly.
  • New coordinates after scaling are obtained by multiplying original coordinates (x, y) by their respective scaling factors (sx for x and sy for y).
  • Uniform scaling occurs when sx equals sy, maintaining the object's proportions while changing its size.
  • The effects of different scaling factors are discussed: if sx is less than 1, the object shrinks; if greater than 1, it enlarges.

Matrix Representation of Scaling

  • The transformation can be represented mathematically using matrices where new coordinates (p') are derived from old coordinates (p) multiplied by a scaling matrix (S).
  • An example illustrates how applying different values to sx and sy affects the size of an object during scaling.
  • It’s emphasized that for matrix multiplication to work correctly, the number of columns must match the number of rows in the matrices involved.

Reflection Transformations

Basic Concepts

  • Reflection is described as creating a mirror image across a specified axis. For instance, reflecting an object across the x-axis results in negative y-coordinates while keeping x-coordinates unchanged.
  • Reflecting across axes alters only specific coordinate values: x remains constant while y becomes negative when reflected over the x-axis.

Advanced Reflections

  • When reflecting over lines such as y = x or y = -x, both coordinates change positions or signs accordingly.
  • A detailed explanation shows how reflection over these lines transforms points based on their original positions relative to those axes.

Shearing Transformations

Introduction to Shearing

  • Shearing involves altering one coordinate while preserving another. For example, in x-shear transformations, only x-coordinates change while y-coordinates remain constant.

Effects of Shearing

  • In shearing transformations like y-shear, only changes occur in y-coordinates which causes horizontal lines to tilt up or down without affecting their position along the x-axis.

Visualizing Shear Changes

  • Diagrams illustrate how objects shift left/right or up/down depending on whether they undergo x-shear or y-shear transformations respectively.
Video description

#2DTransformation #graphics #ComputerGraphics #Scaling #Reflection 2d transformation in computer Graphics 2d transformations in computer Graphics 2d transformation in hindi 2d transformation in computer Graphics numericals 2d transformations 2d transformation Hello friends . This is the series of computer graphics .In this video I have discussed 2d transformation in computer graphics. 2d transformation numericals: https://youtu.be/23iTamqDSpc shearing numerical: https://youtu.be/vp3mZC3AH4w composite transformation with numerical: https://youtu.be/hLdDLcue2nE 3d transformation : https://youtu.be/k_oSY-TBQEc 3d rotation numerical: https://youtu.be/dhIXC3dEhzc Do check other videos on this channel. It has videos related to Pointers, LinkedList , Computer Graphics,Java etc. #abhics789 #CSE #Abhishek #AbhishekSharma #computerGraphics If you learnt something new do share this video and subscribe my channel for more videos like this . There are a lot of videos available on this channel. The links are given below: pointers playlist: https://www.youtube.com/playlist?list=PL9FuOtXibFjUkzTyKn-BqdfNLn8IAV6H5 Linked List in C(for interviews): https://www.youtube.com/playlist?list=PL9FuOtXibFjX-qFVTGWqJ_4qOjboFS8fF C Programming tips and tricks: https://www.youtube.com/playlist?list=PL9FuOtXibFjX-TE09tBPPRSI3Agzz2C3i computer graphics: https://www.youtube.com/playlist?list=PL9FuOtXibFjXwiZuSKOemCso_etrnsZX3 .Net C# : https://www.youtube.com/playlist?list=PL9FuOtXibFjXPGF1RfDpV73a81EHJNgPu engineering economics: https://www.youtube.com/playlist?list=PL9FuOtXibFjW3cONv7t08tt1jAoYcsvod Java tricky programs : https://www.youtube.com/playlist?list=PL9FuOtXibFjU_-AWkM-GUXcgNHcJHw2UJ