1 / 20

Computer Graphics

Computer Graphics. Lecture 3 By: Asima Latif. Graphics Software. flash, maya, 3D studio max, Adobe photo shop, CorelDraw, image viewer, paintbrush etc. 2D Transformations. changes in orientation that is displacement, rotation or change in size is called geometric transformation.

adonai
Download Presentation

Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Graphics Lecture 3 By: Asima Latif

  2. Graphics Software • flash, • maya, • 3D studio max, • Adobe photo shop, • CorelDraw, • image viewer, • paintbrush etc.

  3. 2D Transformations • changes in orientation that is displacement, rotation or change in size is called geometric transformation. • Basic Transformations • a) Translation • b) Rotation • c) Scaling • translation is independent of others whereas rotation and scaling depends on translation in most of cases.

  4. Translation • A translation is displacement from original place. • This displacement happens to be along a straight line; • two distances involves • one is along x-axis that is tx • second is along y-axis that is ty. • expressed with following equation: • x′ = x + tx , y′ = y + ty • Expressed with matrix:

  5. Matrix equation Here (tx, ty) is translation vector or shift vector. We can express above equations as a single matrix equation by using column vectors to represent coordinate positions and the translation vector:

  6. Translation • Translation is a rigid-body transformation • moves objects without deformation. • every point on the object is translated by the same amount. • A straight line can be translated by applying the above transformation equation to each of the line endpoints and redrawing the line between the new coordinates. • Similarly a polygon can be translated by applying the above transformation equation to each vertices of the polygon and redrawing the polygon with new coordinates. • Similarly curved objects can be translated. • For example to translate circle or ellipse, we translate the center point and redraw the same using new center point.

  7. b) Rotation • A two dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. • To rotate a point, its coordinates and rotation angle is required. • Rotation is performed around a fixed point called pivot point. • assume pivot point to be the origin.

  8. for the rotation around the origin • for a positive angle the rotation will be anticlockwise • where for negative angle rotation will be clockwise. • coordinates are P(x,y) • rotation angle θ. • point is already making angle Ф from origin • distance of point from origin is r • therefore we can represent x and y in the form: x = r cosФ and y = r sinФ

  9. for the rotation around the origin • to rotate point by an angle θ, we have new angle that is (Ф+ θ), • therefore now point P′(x′,y′) can be represented as: x′ = r cos(Ф + θ) = r cosФ cosθ – r sinФ sinθ • and y′ = r sin(Ф + θ) = r cosФ sinθ + r sinФ cosθ • Now replacing r cosФ = x and r sinФ = y x′ = x cosθ – y sinθ and y′ = x sinθ + y cosθ

  10. rotation around the origin • representing above equations with the help of column vectors: P′= R . P • Where • For row vectors • rotation equation is transposed : • P′T = (R . P)T • = PT . RT

  11. Where PT and the other transpose matrix can be obtained by interchanging rows and columns. • for rotation matrix, the transpose is obtained by simply changing the sign of the sine terms.

  12. Rotation about an Arbitrary Pivot Point: • pivot point may be any point as shown in the above figure

  13. Rotation about an Arbitrary Pivot Point • retranslate the pivot point to its original position x′ = xr + (x - xr) cosθ – (y - yr) sinθ y′ = yr + (x - xr) sinθ – (y - yr) cosθ • to move a line along its one end point very simple treat that end point as pivot point and perform rotation on the other • Similarly we can rotate any polygon with taking some pivot point and recalculating vertices and then redrawing the polygon.

  14. c) Scaling • A scaling transformation changes the size of an object. • either increasing the original size or decreasing the original size. • In figure scaling factors used Sx=3 and Sy=2. • simply multiply each coordinate with its respective scaling factor. • x coordinate with factor Sx • and y coordinate with factor Sy. • Therefore, following equations can be expressed: • x′ = x.Sx y′ = y.Sy • In matrix form it can be expressed as: • P′ = S.P

  15. c) Scaling • scaling factor > 1 • the object size will be increased than original size; • scaling factor < 1 • the object size will be decreased than original size • Scaling factor = 1, • no change in size • uniform scaling • Sx= Sy , keeping the original shap • differential scaling • Sx ≠ Sy • alter the original shape that is a square will no more remain square.

  16. c) Scaling • in case of line and polygon we will scale ending points or vertices then redraw the object in circle or ellipse we will scale the radius. • scaling with respect to any point other then origin, same methodology will work that is to apply translation before scaling and retranslation after scaling. • So here if we consider fixed/ pivot point (xf,yf), then following equations will be achieved:

  17. x′ = xf + (x - xf)Sx • y′ = yf + (y - yf)Sy • These can be rewritten as: • x′ = x. Sx + xf (1 – Sx) • y′ = y. Sy + yf (1 – Sy) • Where the terms xf (1 – Sx) and yf (1 – Sy) are constant for all points in the object.

  18. The End

  19. Assignment • Write a program in C++/ java which • Can simply displace a line from one position to another position without changing its size. • Rotate a line without changing its size • Submission dead line: 28- Sept-2009

More Related