Doc Mar 07 2024

You might also like

Download as pdf
Download as pdf
You are on page 1of 18
3.6 Rolation about an Arbitrary Poin 3.2 Transiation Transformation 3.7 Composite Transformation 3.3. Scaling Transformation: 3.8 Scaling Relative to a fixed Pivot — 3.4 Rotation Transformation: 3.9 Rotation About a Pivot Point 3.5. Maufx Representation and 3.10 General Transformation Equation 3.11 Other Transformation ‘3.1 INTRODUCTION Graphics having coded numbers can be modified by certain operations called Tran: These operations are possible through software or hardware. Transformations allow | uniformly change the dimension and size of the picture. Matrices are an integral part of mathematics and it is the matrix concept that Possible to develop programs for scaling, rotation and translation. Our computer graphic are made up of a series of line segments which are represent by the co-ordinates of their en Points and changes in an image can be easily made by Performing mathematical ‘on these coordinates. Multiplications of matrices is not commutative i © AXB=BxA, The multiplication of two matrices gives a resultant matrix, which has the same number of rows as the first matrix and same number of columns as the second matrix. The resultant matrix C is given in terms of the elements of matrices A and B by the formula. Cii,k) = A(i,j)xB Uj, k) and of course, multiplication is associative ie, A(BC) = (AB)C Similarly, we have the concept of identify matrix which when. multiplied with any other matrix A gives the original matrix. A=AL where 1 is the Identity matrix, ‘Two Dimensional Transformation [EB] TRANSLATION TRANSFORMATION. The translation transformation is X =x4+Ty Yayet, Transform matrix. For example, Consider a triangle defined by its three vertices (20, 0), (60, 0), (40, 100) being translated 100 units to the right and 10 units up (T,, = 100, T, = 10). The new vertices are given by (120, 10), (160, 10) and (140, 110). Itis shown by This is a transformation that we see in so many graphics and graphic systems. The change of Size and that too in interactive manner (if required) gives graphic a new dimension in computing, There are times when we require a change of scale to suit our requirements. Transformation of the form S, 0 mu Change the size and properties of the displayed image. This type of transformation is led scaling transformation. S, is the scale factor for the X axis and Sy for the Y axis. When ‘we scale the image, every point except the origin changes. Suppose the point Q, has coordinates [X,, Y;]. As can be seen, itis represented by1x2 latrix and when multiplied by 2 x 2 matrix ‘scaling matrix S, a resultant matrix of order 1 x 2 ined which can be interpreted as another point Q, with coordinates [X,Y] after scaling. AFTER (DOUBLING) FIGURE 3.2. Scaling Transformation. Cor Thus, the matrix S has rs for us by giving anew point Q, ag ing S, =2and S, = 2, then the ing a new point with dout re scaled until the e done wonder tion was performed usI both X and Y direction givi ‘er points of the image a [X, Y;] is muttiplied by 2 in [Xp Yz)- In the same way othe undergoing scaling. The contents of matrix S do matter when we are mul ‘Suppose the scaling matrix S were identity matrix. s-(5 4) 4 Then the image would not chan i pli identit \ thesenat 1g \ge, as anything multiplied by identity matrix Itiplying our points on thal Woemote a TN eee (a) 7 FIGURE 3.3, o In general terms, transformation of the form » Reflection A reflection is a 180° rotation out into three space and back into the two space about an axis in the xy plane. ; A reflection about y = 0, the x-axis, is obtained by using 10 Dios ’ for the triangle ABC is given by The method for selecting and enlarging portions of a drawing is called Windowing and the technique for not showing that part of the drawing which one is not interested is called Clipping. “Its often useful to think of two models of the item we are displaying. There is the object model and there is the image of the object, which appears on the display. _ The object model is said to reside in object space and this model represents the object using physical units of length. The image model is measured in screen co-ordinates (we have normalized the screen coordinates so that they have range between 0 and 1). 4 ‘We must have some way of converting from the object space units of measure to those of the image space (Screen Space). This can be done by the scaling transformations. The physical dimensions of the object are scaled until they are suitable for display. It maybe, however, that the object is too complex to show in its entirety or that we are particularly interested in just a portion of it, We would like to image a box and would only : ‘what is enclosed in the box and such a box is called Window. It might also happen that we don't wish to use the entire screen fro display. We would like image a box on the screen and have the image confined to that box. Such box in the screen called a Viewport. 51 —_—— ‘When the window is changed we see a different part of the object shown at ¥ ortion on the display. If we change the Viewport, we see the same part of the object e different place on the display. In specifying both Window and Viewport, we have enough information to determ anslation and scaling transformation necessary to map from the object space to th pace. This can be both with the following steps : ' > ORIGINAL OBJECT FIGURE 4.1. Viewing Transformation, 1. First the object together with its window is translated n ‘the window is at the origin. ee guemaaaa 2. Second the object and the window are scaled until the wi le wind. ofa ee converts object and window into majoras ae 3. The first transformation step in another translation t e correct position on the screen. 1 a We are doing two things : we are changing the window size to b Viewport (scaling) and we are positioning it at the desired location (translating). transformation which performs these steps is called the viewing ao niion, oa four window has left and right boundaries of 3 and 5 and lower and upper bounda Oand 4 then the first translation matrix would be sac 100 010 301 (4:3) CLIPPING ALGORITHMS i it is com : we examine each li to determine whether or not it i clipping amine each line of the display t 1 i ide f e window, lies completely outside the window or crosses the window boundary, Hfitis inside, the line is displayed. If itis outside nothing is Senn is aan ae ae ‘we must determine the point of intersection and draw only the por A . NX \ he aa FIGURE 4.2. Clipping Process, 4.3.1 Cohen-Sutherland Algorithm (For Line’ This algorithm makes clever use of bit operations (out-codes) to perform the tesi Line segments endpoints are each given 4 bit binary codes. 1010 0110 FIGURE 4.3, Out Codes. The lines which forms the window boundary divide the Plane into nine regions with the out-codes given above. I the line is entirely within the window then both end points will have out-codes 0000. Segments with the property are accepted, In Fig. 4.4, Line segment ST is accepted, segments AB and CD to be quickly removed. Take logical AND of the out-codes for the two endpoints. If the result is non-zero then line segment may be rejected. Difficulty may come when the line crosses ons e or more lines whi boundary (example EF and W). For these cases, ich contain the clipping the point of interse ction between the line sgment — . undary lines may be used to break up the line segment. The resulting eces may be tested for acceptance or rejection. FIGURE 4.4. Line Segment's Acceptance/Rejection. Following is the brief outline of the algorithm : ® First we compute out-codes for the two end-points (P, and P.) of the segment. Next, we enter a loop. ®@ Within the loop, we check to see if both out-codes are zero, if yes we enter the segment into the display file, exit the loop and return. © |f out-codes are not both zero, we then perform the logical AND function and check for @ non-zero result. If this test is non-zero then we reject the line, exit the loop and return. © |f neither of these tests is satisfied, we must divide the line segment and repeat the loop. 4.3.2 Sutherland-Hodgeman Algorithm (For Polygon Clipping) The Cohen-Sutherland algorithm works well for lines and we would like a method, which may be used with polygon as well. The method unbundles the clipping test to clip against ‘ach of the four boundaries individually. The idea behind the algorithm is that we can easily Slip 4 line segment against any one of the window boundaries, | (CUP AGAINST ALL FOUR BOUNDARIES TOP, BOTTOM, LEFT AND RIGHT BEFORE CLIPPING AFTER CLIPPING FIGURE 4.5, at. SAAR 4.3.3 Area Clipping op f area can be represented is by boundary and boundary o' 4 5 the ae pee ic cariod by line itself. So almost any shape or other graphic en Ve, likewise be broken down into straight-line segments and can then be clipped with the the Cohen-Sutherland algorithm. For the Cohen-Sutherland algorithm please refer to the page number 54. 4.3.4 Text Clipping The picture we display generally contain other kinds of graphic entity besides segments : they nearly always contain some alphanumeric characters, and they often inciuse Circular arcs or other forms of curve. Characters are often clip The test for visibility can be the character. If the diagon omitted. When accurate chi Aid y ped simply by omitting any character that is only partially visible Performed by examining the diagonal of the rectangle bounding lal is completely visible, the character is displayed; otherwise itis aracter clipping is needed, 4.3.5 Blanking There are two types of blanking : 1. Vertical Blanking 2. Horizontal Blanking. Nertical Blanking: The Vertical blanking, also knowr : Nas the vert inking interval or VBLANK, is the time found between the last line of one ee i ; : fi ie . oe the next. Itis present in analog television, VGA, and Dv serene ieee the beginning is transmitted is not displayed on the sq During this time, een. Horizontal Blanking : lines, to allow the beam t horizontal blanking int synchronizing pulse as wel note raster located just after the gt i Fenian the hori: 3 'S not Visible on the egarae anking portion Positioned in time such that it

You might also like