1 / 17

COM366

COM 366 Interactive Computer Graphics Topic 2 : 2-D Transforms. COM366. Translation. COM366. Scaling. COM366. Rotation – 1. COM366. Rotation - 2. . COM366. Matrix Representation. Rotation. Scaling. Translation. COM366. Homogeneous co-ordinates. Translation.

tameka
Download Presentation

COM366

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. COM 366 Interactive Computer Graphics Topic 2 : 2-D Transforms COM366

  2. Translation COM366

  3. Scaling COM366

  4. Rotation – 1 COM366

  5. Rotation - 2  COM366

  6. Matrix Representation Rotation Scaling Translation COM366

  7. Homogeneous co-ordinates Translation Rotation and Scaling COM366

  8. A numerical example Suppose we wish to translate 3 units in the x direction and 2 units in the y direction. Let us imagine we have a node at (4,5) The answer we know will be x’ = 4 + 3 = 7 & y’ = 5 + 2 = 7 x’ = 1*4 + 0*5 + 3*1 = 7y’ = 0*4 + 1*5 + 2*1 = 7 1 = 0*4 + 0*5 + 1*1 COM366

  9. CONCATENATION A translation followed by a Rotation operation x' = R.T.x x' = R.x" = R.(T.x) = R.T.x The ordering of the transformations is critical to the result : COM366

  10. Inverse transformations Take translation as an example x = T-1.T.x COM366

  11. Inverse scaling and rotation Remember cos(-) = cos() and sin(-) = -sin() COM366

  12. Local origin Global origin xf = T-1.RT.xs Rotation about a local origin COM366

  13. Programming the transforms e.g. rotation function Rotatesquare(theta); %First of all define the nodes Node = [-2 -2 2 2 -2; -2 2 2 -2 -2;1 1 1 1 1] %Now convert the rotation angle to radians %Remember 180 degs. = pi radians thetarad = pi*theta/180; %Now let us define the rotation matrix Ctheta = cos(thetarad); Stheta = sin(thetarad); Rot = [Ctheta -Stheta 0; Stheta Ctheta 0; 0 0 1] %Now rotate the square NewNode = Rot*Node; %Draw the square plot(NewNode(1,:),NewNode(2,:)) %Set the limits to the axes and ensure they are of equaldimension axis([-5,5,-5,5]); axis square; COM366

  14. The Linear Transform If T is one of the basic graphic transforms (translation, scaling, rotation) then T is linear in the sense that if 1 and 2 are two parameters then : Put simply in terms of translation a translation of 2 cms followed by a second translation of 3 cms will generate exactly the same image as a single translation of 5 cms. COM366

  15. COM366

  16. COM366

  17. COM366

More Related