2 d transformations
Upcoming SlideShare
Loading in...5
×
 

2 d transformations

on

  • 448 views

Computer Graphics

Computer Graphics

Statistics

Views

Total Views
448
Views on SlideShare
448
Embed Views
0

Actions

Likes
0
Downloads
42
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

2 d transformations 2 d transformations Document Transcript

  • Computer Graphics2D TransformationsA transformation is any operation on a point in space (x, y) that maps the points coordinates into a new setof coordinates (x1,y1).TranslationIn translation an object is displaced a given distance and direction from its original position. If thedisplacement is given by the vector v = txI + tyJ, the new object point P(x, y) can be found by applyingthe transformation Tv to P(x, y). See the figure below P = Tv(P)where x = x + tx and y = y + ty.As an example, consider a triangle defined by three vertices (20,0), (60, 0), and (40, 100) being translated100 units to the right along the x-axis ( tx = 100) and 10 units up along the y-axis (ty = 10). The newvertices are (120, 10), (160, 10), and (140, 110), see figure below:RotationIn rotation, the object is rotated ø° about the origin. The convention is that the direction of the rotation isCCW if ø is a positive angle and CW if the ø is a negative angle. The transformation for rotation Rø is P = Rø(P) where x = x cos(ø) - y sin(ø) and y = x sin(ø) + y cos(ø) For example a triangle (20,0), (60,0), (40,100) rotated 45° clockwise about the origin is (14.14, -14.14), (42.43, -42.43), (98.99, -42.43)K. Adisesha 1
  • Computer GraphicsScalingScaling is the process of expanding or compressing the dimensions of an object. Positive scalingconstants Sx and Sy are used to describe changes in length with respect to the x direction and y direction. Ascaling constant > 1 creates an expansion (magnification) of length, and < 1 a compression (reduction) oflength. Scaling occurs along the x-axis and y-axis to create a new point from the original. This is achievedusing the following transformation: P = TSx,Sy (P),where x = Sx * x ,and y = Sy * yIf Sx and Sy are not equal, they have the effect of distorting pictures by elongating or shrinking them alongthe directions parallel to the coordinate axes. The mirror image of an object can be generated by using thenegative values for Sxand Sy.Homogeneous CoordinatesTranslation, scaling and rotation were expressed non-homogenously:P´ = P + TP´ = S × PP´ = R × PComposition is difficult to express using the standard notation above. Homogeneous coordinates allow allthree to be expressed homogeneously, using multiplication by 3 × 3 matrices.Add a third coordinate to a point P(x,y). So instead of representing the point using an (x,y) coordinatepair, each point is represented by three values, (x, y, W).P2d (x, y) -> Ph (wx, wy, w), w xb9 0Given Ph (x, y, w), w xb9 0Then P2d (x, y) = P2d (x/w, y/w)W is 1 for affine transformations in graphics. Affine transformations have the property of preservingparallism of lines, but not the lengths and angles. See example in figure 5.6 on page 207 in your ComputerGraphics text.Shear an affine transformationA shear is a transformation that distorts the shape of an object along either or both of the axies. Like scaleand translate, a shear can be done along just one or along both of the coordinate axes. A shear along oneaxis (say, the x-axis) is performed in terms of the points coordinate in the other axis (the y-axis). Thus ashear of 1 in the x-axis will cause the x-coodinate of the point ot distort by 1*(y-coordinate).K. Adisesha 2
  • Computer GraphicsTo shear in the x direction the equation is:x1 = x + ayy1 = yWhere b = 0Where x1 and y1 are the new values, x and y are the original values, and a is the scaling factor in the xdirection. The matrix is as follows.Shearing in the y direction is similar except the roles are reversed.x1 = xy1 = y + bxWhere a = 0.Where x1 and y1 are the new values, x and y are the original values, and b is the scaling factor inthe y direction. The matrix is as follows. ExampleOriginal Y-Shear X-ShearK. Adisesha 3
  • Computer GraphicsCompositionR(ø) rotates about the origin; to rotate about P1 Translate P1 to origin RotateTranslate origin back to P1K. Adisesha 4