Presentation is loading. Please wait.

Presentation is loading. Please wait.

16/5/2016 02:47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.

Similar presentations


Presentation on theme: "16/5/2016 02:47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function."— Presentation transcript:

1 16/5/2016 02:47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function Calls or Protocol Data

2 26/5/2016 02:47 UML Modeling in Three Dimensions Two Approaches 0 Constructive Solid Geometry (CSG) -Primitives are a small set of volumetric objects such as cube, pyramid, sphere, etc. -Objects built from normalized set operations on these objects 0 Boundary (surface) representation -Objects are described by their surfaces and can be thought of as being hollow -Surfaces composed (approximated) by simple, convex, planar polygons -Objects can be specified through a set of vertices in three dimensions =Implies underlying coordinate system =Duality: Object Object representation

3 36/5/2016 02:47 UML Representation of a Cube Surface Representation Data Structure 1 2 30 56 7 4 X 0, Y 0, Z 0 X 1, Y 1, Z 1 X 2, Y 2, Z 2 X 3, Y 3, Z 3 X 4, Y 4, Z 4 X 5, Y 5, Z 5 X 6, Y 6, Z 6 X 7, Y 7, Z 7 0 3 2 1 3 7 6 2 A B C D E F...... FACES VERTEX LISTS VERTICES Object: set of points Representation: data structure

4 46/5/2016 02:47 UML Inward and Outward Pointing Faces: Right Hand Rule 01 23 Outside

5 56/5/2016 02:47 UML Transformations 0 Maps an object into another object -In general, a transformation maps every point on an object to another point in the underlying coordinate space. 0 Why do we want/need transformations? -Change size, location, orientation of objects without changing underlying model (or primitive drawing commands) -Animation -Instancing Object New Object Representation New Representation Transformation Operation

6 66/5/2016 02:47 UML P1’P1’ P2’P2’ What Do We Require of Transforms? Line Preserving P1P1 P2P2 Line Not Preserved

7 76/5/2016 02:47 UML Abstract Data Types: Affine Space  Scalar  -Magnitude (e.g. real numbers)  Vector u, v, w, x -Direction -Magnitude -No Position  Point P, Q, R, X -Position -No Direction -No Magnitude

8 86/5/2016 02:47 UML Defined Operations: Scalars  Addition:  -Additive identity: zero  Additive inverse: -  -Subtraction defined in terms of additive inverse  Multiplication:  -Multiplicative identity: 1  Multiplicative inverse: 1/  -Division defined in terms of multiplicative inverse

9 96/5/2016 02:47 UML Defined Operations: Vectors Addition u v u + v | u | =  Magnitude (produces scalar) Dot Product  u v u  v = | u | | v | cos  (produces scalar) Cross Product  u v Produces vector w orthogonal to u and v. w = u x v | w | = | u | | v | sin 

10 106/5/2016 02:47 UML Defined Operations: Scalars and Vectors Multiplication of vector by scalar: Produces vector u v =  u |  u | =  | u |

11 116/5/2016 02:47 UML Defined Operations: Points and Vectors Affine Addition: Point + Vector = Point P Q v Q = P + v Related to point subtraction.

12 126/5/2016 02:47 UML Defined Operations: Points Subtraction (Addition of points has no meaning.) P R u = P - R Produces vector

13 136/5/2016 02:47 UML Lines in Affine Space P Q v Q = P + v R R = P +  v  R’ Line segment from P to Q defined when: 0  1

14 146/5/2016 02:47 UML Planes in Affine Space Planes are defined uniquely by three points: P, Q, R P Q R u v T(  ) S(  ) S(  ) = P +  v T(  ) = P +  u W(  ) = S + (T - S) = P +  v +  u -  v) W (  ) = P +  1 -  v +  u W = P +  v +  u W( ) u = Q - P v = R - P

15 156/5/2016 02:47 UML Representations of Points and Vectors Coordinate system: z y x v P (x, y, z) where:

16 166/5/2016 02:47 UML Homogeneous Coordinates Frame is specified by: Homogeneous coordinate representation: Frame where are linearly independent basis vectors and P 0 arbitrary point

17 176/5/2016 02:47 UML Representation of Vectors In Homogeneous Coordinates

18 186/5/2016 02:47 UML Affine Addition In Homogeneous Coordinate Representation Point Scalar times vector

19 196/5/2016 02:47 UML Transform as a Change of Frame y x y x (2, 3) Want to translate by:  x = 2  y=4 (2, 3) in x’y’ (4,7) in x y y’ x’ 1. Transform frame 2. Find representation in original frame  x = 2  y=4

20 206/5/2016 02:47 UML Transform as a Change of Frame Representation: Frame:

21 216/5/2016 02:47 UML Transformation Matrix Original Frame:Transformed Frame: Express elements of transformed frame in original frame: where:

22 226/5/2016 02:47 UML Transformation of Representation is representation in transformed frame is representation in original frame where is of the form:

23 236/5/2016 02:47 UML Affine Transformations T(point) -> point T(vector) -> vector

24 246/5/2016 02:47 UML P1’P1’ P2’P2’ What Do We Require of Transforms? Line Preserving P1P1 P2P2 Line Not Preserved

25 256/5/2016 02:47 UML Affine Transformation: Line Preservation Matrix multiplication is linear. Therefore: p p+vp+v v T(p) T(p)+  T(v) T(v) Meets our requirements!

26 266/5/2016 02:47 UML Translation Translate the new frame: Assumptions:

27 276/5/2016 02:47 UML Scaling Scale the new frame:

28 286/5/2016 02:47 UML Rotation Rotation around the z axis: 

29 296/5/2016 02:47 UML Rotation About x and y axes Similar derivations give:

30 306/5/2016 02:47 UML Concatenation of Transformations Apply T 1, Then apply T 2 :

31 316/5/2016 02:47 UML OpenGL Matrix Operations glLoadIdentity(); Loads an identity matrix onto the top of the current stack glLoadMatrixf(pointer_to_matrix); Loads arbitrary matrix onto top of the current stack glMultMatrixf(pointer_to_matrix); Postmultiplies current matrix by arbitrary matrix Matricies are one-dimensional arrays of type GLfloat in column major order.

32 326/5/2016 02:47 UML Predefined Postmultiplier Operators in OpenGL glTranslatef(dx, dy, dz); Multiplies current matrix with translation matrix. dx, dy, and dz are translations along x,y, and z axes. glRotatef(angle, x, y, z); Multiplies current matrix with rotation about the line from the origin through the point (x, y, z) by angle. Right hand rule applies. Angle in degrees. glScalef(sx, sy, sz); Multiplies current matrix with scaling matrix. sx, sy, sz are the scale factors along the x, y, and z axes.

33 336/5/2016 02:47 UML Transformation Matrices in OpenGL Stack Current Stack CurrentLoad Matrix Vertices 3D Model Vertices 3D 2D ModelviewProjection Matrix Mode


Download ppt "16/5/2016 02:47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function."

Similar presentations


Ads by Google