1 / 24

Example

6. 2. 5. 1. Example. What are the real world coord. of the object in Fig.1a (centered in the window)? Calculate display coord. for the object in the viewport centered in the screen below (Fig.1b). 1000. (0,0). Real world window. 225. 750. 400. screen. viewport. Fig.1a. Fig.1b. 6.

vinny
Télécharger la présentation

Example

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. 6 2 5 1 Example • What are the real world coord. of the object in Fig.1a (centered in the window)? Calculate display coord. for the object in the viewport centered in the screen below (Fig.1b). 1000 (0,0) Real world window 225 750 400 screen viewport Fig.1a Fig.1b

  2. 6 v3 2 v1 v2 5 1 Example • What are the real world coord. of the object in Fig.1a (centered in the window)? Calculate display coord. for the object in the viewport centered in the screen below (Fig.1b). 1000 (0,0) 225 w3 750 400 400 w1 w2 225 Fig.1a Fig.1b v1x= (w1x – wxmin) . vxmax – vxmin + vxmin = (2-1). 200/4 + 400 = 450 wxmax – wxmin

  3. 6 v3 2 v1 v2 5 1 Example • Note the position of the origin: we must be careful for y coordinates on screen!!! 1000 (0,0) 225 w3 750 400 400 w1 w2 225 Fig.1a Fig.1b v1y = (w1y – wymin) . vymax – vymin + vymin = (3-2). 300/4 + 225 = 300 wymax – wymin The actual value is: 750-300 = 450

  4. Co-ordinate Systems • Objects in computer graphics are given numerical descriptions that characterize their shape and dimensions. • The numbers refer to some coordinate system, most often Cartesian co-ordinates x,y and z

  5. Transforming Pictures • Sometimes objects exhibit certain symmetries, so only a part of it needs to be described, and the rest constructed by reflecting, rotating and translating the original part • A designer may want to view and object from different vantage points, by rotating the object, or by moving a “synthetic camera” viewpoint. • In animation, one or more objects must move relative to one another, so that their local co-ordinate systems must be shifted and rotated as the animation proceeds.

  6. Transforming Pictures Example: Object parts defined in a local co-ordinate system: etc... Parts “assembled” by transforming each of the constituent parts:

  7. Transforming Pictures Example: 5 steps of a “rotating cube” animation • At each frame of the animation, the object is transformed, in this case by a rotation • It could also be transformed by changing its size (scaling), or its shape (deforming), or its location (translation) • Further animation effects can be achieved by not changing the object, but the way it is viewed • i.e. the window to viewport transformation) at each frame (e.g. by zooming).

  8. Transformations • There are two ways to view a transformation • An Object Transformation alters the coordinates of each point according to some rule, leaving the underlying coordinate system unchanged • A Coordinate Transformation produces a different coordinate system, and then represents all original points in this new system • Both ways have advantages, and are closely related to one another

  9. .4, 2 1,1 Object Transformation • The object is moved • Example of object transformation

  10. Coordinate Transformation • The coordinates are repositioned (1,1) (1,1) • Example of coordinate transformation (e.g., window-viewport transformation)

  11. vxmax - vxmin . vxmin + vx = (wx- wxmin) wxmax - wxmin Window-viewport transformation • Intuitively: • Convert wx to a distance from the window corner • “Scale” this w distance to get a v distance • Add to viewport corner to get vx (1) (2) (3)

  12. Window-viewport transformation 1. Convert wx to a distance from the window corner WYmax WYmin WXmax WXmin Window translated to origin (viewing coordinates) Window in world coordinates 2. Scale this w distance to get a v distance VYmax 3. Add to viewport cornerto get vx VYmin VXmax VXmin Window scaled to size of viewport Translation into final position

  13. 2D Object Transformations • A 2D object transformation alters each point P into a new point Q using a specific formula or algorithm. • It therefore alters the co-ordinates of P (Px,Py) into new values which specify point Q (Qx,Qy) • This can be expressed using some function T, that maps co-ordinate pairs into co-ordinate pairs: T(PX,PY) = (QX,QY) or: T(P) = Q

  14. Affine Transformations • Whole collections of points may be transformed by the same transformation T • e.g. lines or a dodecahedrons • The image of a line, L, under T, is the set of all images of the individual points of L • Affine Transformations, preserve lines, and are the most commonly-used transformations in computer graphics

  15. Affine Transformations • Any general two-dimensional affine transformation can always be expressed as a composition of • Translation, rotation, scaling, reflection and shear • So in simple terms an affine transformation is a transformation such as translate, rotate, scale, reflection or shear in which parallel lines remain parallel even after being transformed • An affine transformation involving only translation, rotation and reflection preserves angles and lengths as well as parallel lines

  16. ( ) ( ) ( ) ( ) tx ty QX QY = a b c d PX PY + Matrix Representation • If affine transformation T maps P onto Q, then Q is related to P as follows: QX = aPX + bPY + tx QY = cPX + dPY + ty • where a, b, c, d, tx and ty are all constants • This gives rise to the following matrix representation: • i.e. Q = MP + Tr

  17. ( ) SX 0 0 SY ( ) ( ) ( ) PX PY SX 0 0 SY QX QY = Scaling • A scaling changes the size of an object with two scale factors, SX and SY • So, (QX,QY) = (SX*PX, SY*PY) • Therefore, M will be the matrix: • So

  18. (1,10) (10,10) (10,1) (1,1) QX QY = 1 10 10 10 10 1 1 1 30 0 2 Scaling Example • Original Shape • Px1 = 1 Py1 =10 • Px2 = 10 Py2 =10 • Px3 = 10 Py3 =1 • Px4 = 1 Py4 =1 • Sx = 3 Sy=2 • Scaling Formula • Formula applied to shape:

  19. QX QY = (3*1)+(0*10) (0*1)+(2*10) (3*10)+(0*10) (0*10)+(2*10) (3*10)+(0*1) (0*10)+(2*1) (3*1)+(0*1) (0*1)+(2*1) QX QY = 3 20 30 20 30 2 3 2 QX QY = 1 10 10 10 10 1 1 1 30 0 2 Scaling Example • Note the new co-ordinates may now need to be translated as the figure although scaled has now moved

  20. Scaling Example • Note the new co-ordinates may now need to be translated as the figure although scaled has now moved Y (3,20) (30,20) (1,10) (10,10) (3,2) (30,2) X (1,1) (10,1)

  21. Scaling Example (things to note) • Scaling factor SX scales objects in the x direction • Scaling factor SY scales objects in the y direction • Unequal scaling values result in Differential Scaling • Equal values result in Uniform Scaling • Scaling factors less than 1 reduce the size of the object

  22. ( ) 1 0 0 1 ( ) ( ) ( ) QX QY = Tx Ty PX PY + Translation • A translation moves an object into a different position in a scene • So, (QX,QY) = (PX+tX, PY+tY) • This is achieved by the offset vector Tr = ( ) • For a translation alone, there is no rotation or shearing, so the matrix M must be the identity matrix • So, tx ty

  23. ( ) PX PY Rotation • Using the trigonometric relations, we get the following equations: QX = PXcos(q) - PYsin(q) QY = PXsin(q) + PYcos(q) • So ( ) ( ) QX QY = cos(q) -sin(q) sin(q) cos(q)

  24. ( ) ( ) ( ) ( ) tx ty QX QY = a b c d PX PY + Hint • All the transformations can be represented using the following • Should be identity matrix if only translation required

More Related