Presentation is loading. Please wait.

Presentation is loading. Please wait.

CGPage: 1 東吳資訊管理 江清水 Computer Game : Basic 1.Computer Graphics and Its application 2.2D Coordinate Geometry 3.1 2D geometry -- points and polygons 3.2.

Similar presentations


Presentation on theme: "CGPage: 1 東吳資訊管理 江清水 Computer Game : Basic 1.Computer Graphics and Its application 2.2D Coordinate Geometry 3.1 2D geometry -- points and polygons 3.2."— Presentation transcript:

1 CGPage: 1 東吳資訊管理 江清水 Computer Game : Basic 1.Computer Graphics and Its application 2.2D Coordinate Geometry 3.1 2D geometry -- points and polygons 3.2 Object transformation and Coordinates System transformation 3.3 2D Transformation -- Scaling, Translation, Rotation. 3.4 Homogeneous Coordinates 3.5 Composite 2D Transformation 3.6 Other Transformation -- Reflection (Mirror) and Shearing (Skip) 4. 2D Viewing Operations 4.1 Window-to-Viewport Mapping 4.2 2D Clipping 5. 3D Coordinate System 5.1 Coordinates System -- Right-handed and Left-Hand Coordinate system (a) 5.2 3D gemoetry -- points and polyhedra (a) 5.3 3D Transformation -- Scaling, Translation and Rotation. 5.4 Composite 3D Transformation -- Rotation about arbitrary Axis 5.5 Other Transformation -- Reflection and Shearing 6. 3D Viewing Operations 6.1 Projections -- Orthgraphic Projections and Perspective Projections(a 6.2 View Transformation 6.3 View Volume and Z-clipping 7. Visual Realism (Skip) 7.1 Rendering techniques 7.2 Hidden line removal algorithm 7.3 z-buffer algorithm 7.4 illumination and shading 7.5 Ray-tracing algorithm 7.6 Color and light

2 CGPage: 2 東吳資訊管理 江清水 Computer Graphics vs. Pattern Recognition 3D arrows with 3D box Computer Graphics Pattern Recognition

3 CGPage: 3 東吳資訊管理 江清水 Some of today's most popular applications in computer graphics are : Computer Game Presentation Graphics Electronic design and circuit layout Mechanical design and drafting Process Control Data Analysis –2D contour; 3D continuous mesh surface plot –air flow and fluid flow –4D image; structural analysis of any properties Simulation Chemical and molecular analysis User Interface Animation Art Geometric and solid modeling Computer Graphics Application

4 CGPage: 4 東吳資訊管理 江清水 2D Geometry - points and polygons X Y A point in 2D is represented by two real numbers (X,Y) A line segment is represented by its two end points (X 1,Y 1 ) (X 2,Y 2 ), or a 2x2 matrix [ ] X 1 Y 1 X 2 Y 2 X Y

5 CGPage: 5 東吳資訊管理 江清水 A polygon is represented by an list of points (X 1,Y 1 ), (X 2,Y 2 ),..... (X n,Y n ) or a n x 2 matrix [ ] For example, a triangle is represent by [ ] X 1 Y 1 : X n Y n X 1 Y 1 X 2 Y 2 X 3 Y 3 X Y

6 CGPage: 6 東吳資訊管理 江清水 Object transformation and Coordinates System transformation 2 1 1 2 8 Y X (2,4) (6,2) (2,2) Object transformation is different from the coordinates system transformation

7 CGPage: 7 東吳資訊管理 江清水 Translation (2,1) Rotation (  /2) counter clock wise about the origin X Y Y X Object Transformation Scale (1/2) about the origin Y X

8 CGPage: 8 東吳資訊管理 江清水 Y X Y X Coordinates system transformation YY XX 1 23 Translation (2,1) Rotation (  /2) counter clock wise about the origin Scale (1/2) about the origin If not described explicitly, transformation always means object transformation

9 CGPage: 9 東吳資訊管理 江清水 There are 3 "basic" transformations: (1) Translation (2) Scaling (3) Rotation A series of transformations can be combined (concatenated) into one. (1) Translation : T(T x, T y ) X Y (x,y) (x',y') 2D Translations TxTx TyTy

10 CGPage: 10 東吳資訊管理 江清水 (2) Scaling (about the origin) : S(S x, S y ) What about "Mirror Images"? How do we avoid distortion? What happens when the scale factor equal to zero? X Y (x,y) Y X (x',y') S(-2, -1)

11 CGPage: 11 東吳資訊管理 江清水 (3) Rotation (about the origin counterclockwise) : x = R cos  y = R sin  x' = R cos(  R(cos  cos  sin  sin  y' = R sin(  R(sin  cos  cos  sin  So, x ' = xcos  - ysin  y ' = xsin  + ycos  X Y (x,y) (x',y')  

12 CGPage: 12 東吳資訊管理 江清水 Concatenation -- A series of transformations can be combined (concatenated) into one. Example: scaling about arbitrary point. 1. Translate so that point (a,b) becomes the temporary origin: x 1 = x - a y 1 = y - b 2. Scale to the correct size: x 2 = S x *x 1 y 2 = S y* y 1 3. Translate again to restore the coordinates of (a,b): x 3 = x 2 + a y 3 = y 2 + b (a,b) X Y (x,y)

13 CGPage: 13 東吳資訊管理 江清水 Algebraic representations for transformations are very limited: (1) A special procedure is need for each basic transformation and other known concatenated forms. (2) It is difficult to provide general transformation capabilities in algebraic form in the computer. (3) How can one find the inverse of a concatenated equation (to restore the original position, for example)?

14 CGPage: 14 東吳資訊管理 江清水 Let the point (x,y) be a row vector [x y]: x' = ax + by and y' = cx + dy can be expressed in the matrix equation: [x' y'] = [x y] * [ ] 2x2 Let P' = [x' y'] and P = [x y], this becomes the matrix equation: P' = P * T where P' =[x' y'], P = [x y], T = Consider three basic transformations, can we find a "T" for each? What about translations? X'=X+Tx, Y'=Y+Ty No, P' =[x' y']=[x y] [ ] +[T x T y ]=P*T+Q What about scaling? X'=Sx*X, Y'=Sy*Y Yes, P' =[x' y']=[x y] [ ] =P*T What about rotation? x'=xcos  -ysin , y'=xsin  +ycos  Yes, P' =[x' y']=[x y] [ ] a c b d [ ] 1 0 0 1 S x 0 0 S y cos  sin  -sin  cos 

15 CGPage: 15 東吳資訊管理 江清水 Homogeneous Coordinates Let the point (x,y) be a row vector [x y 1]: x' = ax + by + e and y' = cx + dy + f can be expressed in the matrix equation: [x' y' 1] = [x y 1] [ ] 3x3 This becomes the matrix equation P' = P * T where P'=[x' y' 1], P= [x y 1], T= [ ] Now, can we find a "T" for each transformation? What about translations? Yes, T= [ ] What about scaling? Yes, T= [ ] What about rotation? Yes, T= [ ]

16 CGPage: 16 東吳資訊管理 江清水 To check, what should the matrix be if we: (1) translate by (0,0) ? P'=P* [ ] =P* [ ] =P (2) scale by (1,1) ? P'=P* [ ] =P* [ ] =P (3) rotate by 0 o ? P'=P* [ ] =P* [ ] =P (4) rotate by 90 o ? P'=[x' y' 1]=[x y 1] [ ] =[1 0 1]* [ ] =[0 1 1] Draw the pictures and find the new vertices of the triangle for the following transformations (See the figure below) : (x, y) = (1, 0) (x ', y ' ) = (0, 1) X Y (2,2) (2,1) (4,1) A B C

17 CGPage: 17 東吳資訊管理 江清水 (5) translate A by (2,1). (6) translate A by (-2,1). (7) scale A by (2,1). (8) scale A by (-1,1). X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C

18 CGPage: 18 東吳資訊管理 江清水 (9) scale A by (1,0). (10) scale A by (0,0). (11) rotate A by 0 o. (12) rotate A by 90 o. X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C X Y (2,2) (2,1) (4,1) A B C

19 CGPage: 19 東吳資訊管理 江清水 Concatenation is easy now. Consider our scaling example: Example: We want to reduce the size or the box, without changing the position of point (a, b) Functional form and matrix form for each transformations: (1) translate: T(-a,-b) (2) scale : S(S x,S y ) (3) translate: T(a,b) (a,b) Y (x, y) X Composite 2D Transformation

20 CGPage: 20 東吳資訊管理 江清水 Combining the matrix equations: P 3 =P 2 * T (-a,-b)=(P 1 *S(S x, S y ) )*T(a, b) =P*T(-a, -b) *S(S x, S y )*T(a, b) Multiply the matrices : Now, the matrix equation is : or, in algebraic form : Thus, a single 3x3 matrix can represent any combination of basic transformations in a simple form.

21 CGPage: 21 東吳資訊管理 江清水 We can define a window as a rectangular region of the world coordinate space, and the viewport as a rectangular region of the device coordinate system. Window-to-viewport Mapping (0,1/2) (-1,1) (1,1) (0,0) (1,1) WINDOW VIEWPORT (Normalize) (3/4,1) (1/4,0) (Distortion) (0,1/2) (-1,1) (1,1) WINDOW

22 CGPage: 22 東吳資訊管理 江清水 The problem is to "map" coordinates from the window units into the viewport units. Derive the mapping from (x w,y w ), a coordinate in the window, to (x v, y v ), the corresponding point in the viewport:  Remove window coordinate system x 1 = y 1 = The problem is to "map" coordinates from the window units into the viewport units. Derive the mapping from (x w,y w ), a coordinate in the window, to (x v, y v ), the corresponding point in the viewport:  Remove window coordinate system x 1 = y 1 = (cx w,cy w ) (cx v,cy v ) sx w sy w sy v windowviewport sx v (x w,y w ) (x v,y v ) (cx w,cy w ) sx w sy w window (x 1,y 1 )

23 CGPage: 23 東吳資訊管理 江清水 (cx v,cy v ) sy v viewport sx v (x 2,y 2 )  Convert units x 2 = y 2 =  Remove to viewport center x v = y v = so x v = y v = (1) What happens if the ratios sx v /sx w and sy v /sy w are not equal? (2) If you want a set of data in the window, how do you decide the size of the window?

24 CGPage: 24 東吳資訊管理 江清水 (3) Can the window-to-viewport mappintg represented in matrix form?

25 CGPage: 25 東吳資訊管理 江清水 u Homework: Find the transformation matrix that will map points contained in a window whose lower left corner is at (2,2) and upper right corner is at (6,5) onto a viewport that has a lower left corner at (1/2, 1/2) and upper right corner at (1,1).

26 CGPage: 26 東吳資訊管理 江清水 (4) Derive the window to viewport mapping for viewports defined on devices which have the origin at the upper left of the screen, with the horizontal coordinate increasing right, and the vertical coordinate increasing down. h (0,0) window x y v (100,100) viewport  (80,80)  (100,100)

27 CGPage: 27 東吳資訊管理 江清水 The process of clipping decides which part, if any, of a primitive lies inside the window. The algorithms used for line clipping can be divided into two parts: (1) Check all the line segments and separate those that intersect the window boundary. (The curve is represented by a sequence of line segment) (2) Clip the line segments obtained from step 1 by calculating their intersections with the window boundaries. Clipping 2D Clipping

28 CGPage: 28 東吳資訊管理 江清水 (1) How can we sure that a line segment is totally inside the window (such as A) ? Both endpoints of the segment fall within the boundaries. (2) How can we sure that a line segment is totally outside the window (such as E,F,G)? Let two endpoints are (x 1,y 1 ),(x 2,y 2 ) If ( max{x 1,x 2 } x max or max{y 1,y 2 } y max ) then the line segment is totally outside the window. We introduce an efficient procedure, the Cohen-Sutherland algorithm, to check the intersection property and further clip the line segment if necessary. X min X max Y min Y max A B C D E F G

29 CGPage: 29 東吳資訊管理 江清水 Cohen-Sutherland Algorithm The 2D plane is divided into 9 regions. Each region is designated by a 4-bit (base 2) integer code. Each bit of the code is set to 1 (true) or 0 (false), starting with the left most one. The bits are assigned by the follow rule: bit 1 = 1 if the region is above the window. bit 2 = 1 if the region is below the window. bit 3 = 1 if the region is on the right of the window. bit 4 = 1 if the region is on the left of the window. X min X max Y min Y max (1001) (0001)(0000)(0010) (0100)(0110) (1000)(1010) (0001)

30 CGPage: 30 東吳資訊管理 江清水 (1) Given a point (x,y), we would like to assign a "region code" to it by using Cohen-Suterlandalgorithm. In C this can be coded: code = 0 if (x < x min ) code = 1 if (x > x max ) code = 2 if (y < y min ) code += 4 if (y > y max ) code += 8 (2) According to the C code in (1), what code will be assigned if the point is on the boundary of the window? (0000)  0 (3) How about the point on the line X max and not on the boundary of the window? (0100) or (1000) depending on y

31 CGPage: 31 東吳資訊管理 江清水 (4) Draw precise picture for the partition of 2D plane according to the C code in (1). (Using solid line and dotted line) Let's consider the line clipping now. At first, the visibility of the line segment is determined as follows: (1) Visible -> Both endoint codes are (0000).

32 CGPage: 32 東吳資訊管理 江清水 (2) Invisible -> Bitwise logical AND of the endpoint codes is not (0000). (3) Indeterminate -> Bitwise logical AND of the endpoint codes is (0000), but at least one of the endpoint does not have a (0000) code. On the third situation, the line endpoints are "pushed" towards the boundary line until the first or the second situation occurs. (0001) (0010) (0000) Y max Y min X min X max

33 CGPage: 33 東吳資訊管理 江清水 The algorithm steps: 1. Calculate IC1 and IC2, the code of the two endpoints. 2. If (IC1 + IC2.eq. 0) then "Visible". 3. If ( (IC1.AND. IC2).NE. 0) then "Invisible". 4. If ( IC1.EQ. 0) then { Swap(IC1, IC2); Swap(X1,X2); Swap(Y1,Y2); } // At lease one point is outside the // viewport. Insure that point #1 is // one of the outside point. 5. Push endpoint #1 towards X min, X max, Y min, or Y max, depending on which region endpoint #1 occupies (via IC1). bit 1 = 1  toward Y max bit 2 = 1 toward Y min bit 3 = 1 toward X max bit 4 = 1 toward X min If endpoint #1 towards Y max, then { Y max = Y = X 1 + t(Y 2 - Y 1 ), find t and calculate X = X 1 + t(X 2 - X 1 ) } 6. Go To Step #1 above.

34 CGPage: 34 東吳資訊管理 江清水 Example: Let Xmin = 2, Xmax = 8, Ymin = 2 and Ymax = 8, check the visibility of the following segments using the Cohen-Sutherland Algorithm and, if necessary, clip them against the appropriate window boundaries. Line AB: A(3,10) B(6,12) Line CD: C(4,1) D(10,6) X min =2X max =8 Y min =2 Y max =8 A(3,10) B(6,12) C(4,1) D(10,6)

35 CGPage: 35 東吳資訊管理 江清水 Example: Let Xmin = 2, Xmax = 8, Ymin = 2 and Ymax = 8, check the visibility of the following segments using the Cohen-Sutherland Algorithm. Line AB: A(3,10) B(6,12) Line CD: C(4,1) D(10,6)

36 CGPage: 36 東吳資訊管理 江清水 u

37 CGPage: 37 東吳資訊管理 江清水 How will the algorithm handle these examples? (A)(B) (C)(D)

38 CGPage: 38 東吳資訊管理 江清水 3D Coordinates System Right-handed Coordinates System X Y Y X X Y Left-handed Coordinates System X Y X Y We will use vight-handed Coordinates System in our class. Y X

39 CGPage: 39 東吳資訊管理 江清水 5.2 3D Geometry We can use the way to represent 3D points and polyhedras as the way to represent 2D points and polygons. For example: Y X Z (0,2,0) (0,0,0) (3,0,0) (0,0,1) [ ] 0 0 0 3 0 0 0 2 0 0 0 1 represents a tetrahedron In homogenlous coordinates system represents the same tetrahedron

40 CGPage: 40 東吳資訊管理 江清水 3D Transformations Let's discuss 3D transformations, going directly to matrix and functional forms: (1) Translation: [x' y' z' 1] = [x y z 1] * [ ] (2) Scaling: [x' y' z' 1] = [x y z 1] * [ ] (3) Rotation: Rotating about X(Y or Z) does not change X's. The value of Y' and Z' does not depend on X. Row 4 and column 4 are always the same. The problem is to locate sin, -sin and cos.

41 CGPage: 41 東吳資訊管理 江清水 (a) Rotate about Z: (b) Rotate about Y: X Y Z X Y Z [x' y' z' 1] = [x y z 1] * [ ] cos  sin  0 0 -sin  cos  0 0 0 0 1 0 0 0 0 1 [y' z' 1] = [y z 1] * [ ] cos  sin  0 -sin  cos  0 0 0 1 Z X Eye

42 CGPage: 42 東吳資訊管理 江清水 (c) Rotate about X: [x' y' z' 1] = [x y z 1] * [ ] 1 0 0 0 0 cos  sin  0 0 -sin  cos  0 0 0 0 1 X Y Z [x' y' z' 1] = [x y z 1] * [ ] cos  0 -sin  0 0 1 0 0 sin  0 cos  0 0 0 0 1 [x' z' 1] = [x z 1] * [ ] cos  -sin  0 sin  cos  0 0 0 1 [z' x' 1] = [z x 1] * [ ] cos  sin  0 -sin  cos  0 0 0 1 [y' z' 1] = [y z 1] * [ ] cos  sin  0 -sin  cos  0 0 0 1

43 CGPage: 43 東吳資訊管理 江清水 Homework: Rotate the block counterwisely  degree about X, Y, Z axis respectively. Find new coordinate for each vertex. Z X Y Z X Y Z X Y Z X Y Rotate about Y Rotate about X Rotate about Z (0,3,0) (0,0,2) (1,0,0)

44 CGPage: 44 東吳資訊管理 江清水 Different eye position has different view. Projection

45 CGPage: 45 東吳資訊管理 江清水 After the projection, the distance between your eyes and the object vertices is unknown. With the help of hidden-line removal algorithm, you can know which vertex is closer to you.

46 CGPage: 46 東吳資訊管理 江清水 Orthgraphic Parallel Projections vs. Perspective Projections Orthgraphic Parallel Projections: The center of projection is located at infinity and the projectors are prependicular to the projection plane. Perspective projections: The center of projection is located at a finite distance from the projection plane.

47 CGPage: 47 東吳資訊管理 江清水 Orthgraphic parallel Projection : [x,y,z] [x,y,0] Y X Z Projection Plane : XY-Plane (Z=0) Projector : parallel to Z axis The Problem for finding projection point are simple: project to [ x y 0 ] [ x y z ] will

48 CGPage: 48 東吳資訊管理 江清水 Perspective Projection : How to get a picture? (1) Freeze the scene. (2) Freeze you head (eyes). Perspective:

49 CGPage: 49 東吳資訊管理 江清水 What information we need to project a picture into a projection plane via perspective projection? (1) eye position (2) object position (3) picture plane Anything else? (4) Up direction

50 CGPage: 50 東吳資訊管理 江清水 u Z X Y Up 1 = [ ] 010010 Up 2 = [ ] Up 3 = [ ] 100100 110110

51 CGPage: 51 東吳資訊管理 江清水 Consider the eye coordinate system: Projection plane: XY-plane (Z=0) Eye position: [0 0 d] Projector: the line from [x y z] to a given eye position. The problem for finding projection point becomes: Find the intersection point for projcetion plane and projector. XeXe YeYe ZeZe [x y z] [x p y p 0] [0 0 d] = Eye Position

52 CGPage: 52 東吳資訊管理 江清水 (1) Look alone the -X e direction: (2) Look alone the -Y e direction: (x,y,z) YeYe ZeZe ypyp XeXe YeYe ZeZe [x y z] [x p y p 0] [0 0 d] = Eye Position y p : y = d : d-z y p = (d/(d-z)) * y XeXe YeYe ZeZe [x y z] [x p y p 0] [0 0 d] = Eye Position x p : x = d : d-z x p = (d/(d-z)) * x y d -z (x,y,z) ZeZe XeXe xpxp -z x d

53 CGPage: 53 東吳資訊管理 江清水 (3) Represented in matrix form : In homogeneous coordinates system, the points [ x y z 1] and [wx wy wz w] (w  0) represents the same points. So, the point x p = (d/(d-z)) * x y p = (d/(d-z)) * y [x p y p 0 1]=[x y z 1] [ ] d/(d-z) 0 0 0 0 d/(d-z) 0 0 0 0 0 0 0 0 0 1 [x p y p 0 1] = [dx/(d-z) dy/(d-z) 0 1] = [x y 0 1-(z/d)] =[x y z 1] [ ] 1 0 0 0 0 1 0 0 0 0 0 -1/d 0 0 0 1

54 CGPage: 54 東吳資訊管理 江清水 (a) How to draw a 3D line into the picture plane ? (b) What happens when Z (c) What about d (4) Questions : X Y Z [x t y t z t ] [x f y f z f ]  [x' f y' f 0] [x' t y' t 0]

55 CGPage: 55 東吳資訊管理 江清水 u Exercise: (1) Draw The rectangle whose vertices are P=(10,10,-10), Q=(-10,10,-10) R=(-10,10,10), S=(10,10,10) and XY plane is projection plane, (0,0,15) is the eye position. X Y Z S P Q R... (0,0,5) (0,0,15) 1 2 3 4 X Y

56 CGPage: 56 東吳資訊管理 江清水 u (2) Move your eye from (0,0,15) to ((0,0,15), what you will see? X Y X Y Z S P Q R... (0,0,5) (0,0,15) 1 2 3 4

57 CGPage: 57 東吳資訊管理 江清水 (d) How about z > d (i.e., point is behind the eye) ? (e) How about z  d (i.e., point is near the eye) ? X Y Z X Y Z X Y Z

58 CGPage: 58 東吳資訊管理 江清水 View Transformation In general, we may want to observe object from some other position (in stead of (0,0,d)) and direction (in stead of - Z e ), say from point (x f, y f,z f ) to point (x t,y t,z t ). Notice that the world data and view vector now are given in world coordinates, not eye coordinates. XwXw YwYw ZwZw world view vector data (X f,Y f,Z f ) (X t,Y t,Z t ) representing object

59 CGPage: 59 東吳資訊管理 江清水 We must transform the object data from world coordinates into eye coordinates before we can perform orthographic parallel or perspective projection. This transformation called viewing transformation. Where is the eye coordinate system? We make the arbitrary Y e (Up direction) which perpedicular to Z e XwXw YwYw ZwZw world data ZeZe XeXe YeYe

60 CGPage: 60 東吳資訊管理 江清水 We want a "neat" viewing transformation, V, such that [x e y e z e 1] = [x w y w z w 1] * V i.e., multiply all world points by V and it will be just as if the eye was at (0,0,d) or (0,0,  ), depend on perspeative or orthographic parallel projection, looking at (0,0,0). Visualize the process as transforming the Z e and Y e axes to Z w and Y w axes. This is accomplished using four basic transformations: 1. Translate the vector so that (x t, y t, z t ) = (0, 0, 0). 2. Rotate the result so that the transformed (x f, y f, z f )' swings into the Y w -Z w plane. 3. Rotate the result so that (x f, y f, z f )'' swings down onto the Z w axis. 4. Rotate this result so that Y e swings down onto the Y w axis.

61 CGPage: 61 東吳資訊管理 江清水 Step 1. The first step is just a simple translation. XwXw YwYw ZwZw XeXe YeYe ZeZe T 1 = = [ ]

62 CGPage: 62 東吳資訊管理 江清水 Step 2. Rotate  degrees about Y w to swing eye' into the Y w -Z w plane. tan(2  -  =X'/Z'=tan(-   = Check the sign (check rotation direction) Step 3. Swing eye'' down by  degrees to (0,0,d) by rotating eye'' about X w.  = XwXw YwYw ZwZw   eye' eye''

63 CGPage: 63 東吳資訊管理 江清水 Now, the eye coordinate system and world coordinate system are shown in the following picture. Step 4. Rotate X e about Z w  degrees. (asswne X e = (X 3, Y 3, 0))  = -tan -1 Y  ' /X  ' XwXw YwYw ZwZw XeXe YeYe ZeZe  

64 CGPage: 64 東吳資訊管理 江清水 Our transformation equation becomes: [x e y e z e 1] = [x w y w z w 1] T 1 R 2 R 3 R 4 To check your transformatios, try: eye = (0,1,0) aim = (0,0,0) Y e = (1,0,0) XwXw YwYw ZwZw (0,1,0) w (1,0,0) w (0,0,1) w XeXe YeYe ZeZe

65 CGPage: 65 東吳資訊管理 江清水 Homework: Try again with Y e = (0,0,1) and other values are the same. XwXw ZwZw YwYw (0,1,0) w (0,0,1) e (0,0,0) w (0,0,0) e (1,0,0) w (-1,0,0) e (0,0,1) w (0,1,0) e

66 CGPage: 66 東吳資訊管理 江清水 View Volume We saw that as z -> d, severe distortion occures, like a "fisheye" lens. Also, data far from the observer (z << 0) becomes dots! To eliminate these effects, we'll introduce two clipping planes, parallel to the X e -Y e plane: (1) A front clipping plane at z=z front (2) A back clipping plane at z=z back This creates a viewing volume, which is a pyramid, and is now a 6-sided frustum. XeXeXeXe YeYeYeYe ZeZeZeZe Back Clipping Plane Front Clipping Plane Projection Plane

67 CGPage: 67 東吳資訊管理 江清水 Z-Clipping Now the full clipping procedure becomes: (1) Clip on front and back planes. (2) Perspective projection to 2D window. (3) Clip on the 2D window. To determine the visibility of a point P(x,y,z), just test its z value: If ((z > z front ) or (z<z back )) then "Invisible", else "Visible". (1) Under what conditions that a line segment will not be clipped? P 1 = (X 1, Y 1, Z 1 ) P 2 = (X 2, Y 2, Z 2 ) Z back  Z 1, Z 2  Z front (2) How to clip a line segment using Z-clipping? (1) Z = Z 1 + (Z 2 -Z 1 )t (2)replace Z = Z front or Z end, find t (3)find (X Y Z) = (X 1 Y 1 Z 1 ) + t(X 2 -X 1, Y 2 -Y 1, Z 2 -Z 1 )

68 CGPage: 68 東吳資訊管理 江清水 Three types of perspective projections: (1) one-point (2) two-point (3) three-point


Download ppt "CGPage: 1 東吳資訊管理 江清水 Computer Game : Basic 1.Computer Graphics and Its application 2.2D Coordinate Geometry 3.1 2D geometry -- points and polygons 3.2."

Similar presentations


Ads by Google