Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together.

Similar presentations


Presentation on theme: "Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together."— Presentation transcript:

1 Graphics Matrices

2 Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together

3 Wireframes Most things can be represented graphically by using points (square, pyramid, your face…) Draw lines between points to make up a wireframe Currently the fastest way to build worlds (curves were not allowed - too slow!)

4 2-Dimensional Coordinates x axis y axis ( +, + ) ( +, - ) ( -, - ) ( -, + )

5 3-Dimensional Coordinates Have an extra dimension! “Comes out of paper” - to and fro This new dimension is referred to as “z coordinate” Gives the point depth Example coordinate: ( 2, 5, -4)

6 Right-hand/Left-hand Hold out right hand. Extend Thumb, first and second fingers. This is positive direction (thumb pointing towards your face) Use left hand for Left-hand coordinate system. In this class, we use Right-handed coordinate system! (z comes out of paper with increasing numbers)

7 What does it look like? X axis Y axis z a x i s

8 New Representation of Points 2D old way: (x, y) 2D new way: 3D old way: (x, y, z) 3D new way: [ ] x y x y z

9 An Example of Rotation (45 degrees) Question: how does x value “behave” as it increments from 0 degrees to 360 degrees?

10 Matrix Multiplication Used to change one point to another Good for rotating and translating! Will multiply the point by a matrix to give us another point A matrix is an n x m set of data (can be numbers or functions) n = number of rows, m = number of columns Sound complex? Let’s see!

11 What does it look like? (2D Matrix) 3 4 1 9

12 How do I multiply? My 2D coordinates are (7, 8) = 3 4 1 9 7 8

13 The X coordinate Multiply, Add, Multipy, Add…… 1 9 8 3 47 New x coord is: 3*7 + 4*8

14 The Y Coordinate 3 4 1 9 7 8 New y coord is: 7*1 + 9*8

15 Now in 3D! Our point is (9, -10, 12) 123 375 46 8 9 -10 12 New x coord is: 9 * 1 + (-10) * 2 + 12 * 3

16 New y coordinate 123 375 46 8 9 -10 12 New y coord is: 9 * 3 + (-10) * 7 + 12 * 5

17 New z coordinate 123 375 46 8 9 -10 12 New z coord is: 9 * 4 + (-10) * 6 + 12 * 8

18 More and More! (larger matrices) 123 375 46 8 9 -10 12 15 11 7 19 21 (Note: have to do this nine times! Here, we are trying to find the upper left value of the new matrix)

19 Another Pass... 123 375 46 8 9 -10 12 15 11 7 19 21 (Note: here we find the middle (of the nine calculations). This is where the two boxes intersect!)

20 Using what you’ve learned Now you can rotate wireframes in 2D and in 3D This stuff really is used (most video games, simulations, VR etc…) We can rotate (say, a cube) about the x, y, and/or z axis (demonstration) Must specify the degree or amount of rotation (45 o, 90 o, 123 o, 450 o, etc…)

21 An Example of Rotation (45 degrees)

22 2D rotation Matrix  = number of degrees cos (  ) -sin (  ) sin (  )cos (  )

23 3D rotations Can rotate in 3D space too! Able to rotate around each axis –x axis –y axis –z axis

24 Rotations around X axis 1 0 cos (  ) 0 0 0 sin (  ) -sin (  )

25 *Rotations about Y axis* 1 0 cos (  ) 0 0 0 sin (  ) -sin (  )

26 Rotations about Z Axis 1 0 cos (  ) 0 0 0 sin (  ) -sin (  )

27 What about all three? There is a need to rotate about more than one axis at a time Must multiply rotation matrices together first before multiplying new points (multiply z-rotation times x-rotation. Then multiply points with this new matrix)

28 Animation Algorithm (in psuedo-code) Get original points p of object loop rotate all p points by  to create p ’ redraw lines between all points p ’ increment  end loop // remember to keep original points!

29


Download ppt "Graphics Matrices. Today’s Lecture Brought to you by the integer 6 and letter ‘K’; 2D and 3D points Matrices Rotations Translation Putting it all together."

Similar presentations


Ads by Google