Window to Viewport Transformations

Slides:



Advertisements
Similar presentations
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Advertisements

1 Computer Graphics Chapter 4 2D Viewing Algorithms.
Mapping between Scene and Screen. Screen (0, W-1) (W-1, H-1) (W-1, 0)(0, 0) Projection Plane (Xmin, Ymin)(Xmax, Ymin) (Xmax, Ymax) (Xmin, Ymax) Screen.
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
Monday: Announcements Unit 5 Retest: Deadline is Friday at 8:35am. Must have test correction complete to retest and come to at least one tutorial session.
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Introduction to 3D viewing 3D is just like taking a photograph!
Using Matrices to Perform Geometric Transformations
Mathematical Fundamentals
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Copyright  1999 by James H. Money. All rights reserved. Except as permitted under United States Copyright Act of 1976, no part of this publication may.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Section 1.1 Graphs and Graphing Utilities. Points and Ordered Pairs.
Lecture Notes: Computer Graphics.
Computational Biology, Part E Basic Principles of Computer Graphics Robert F. Murphy Copyright  1996, 1999, 2000, All rights reserved.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
REVIEW Math 1113 Precalculus Fall 2010 Instructor: Ayona Chatterjee.
Geometric Transformations
1 General Camera ©Anthony Steed Overview n Simple camera is limiting and it is necessary to model a camera that can be moved n We will define.
Transformational Geometry CS418 Computer Graphics John C. Hart.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Geometric Transformations
Algebra 2 Fall Semester Exam Review Test Format Final Exam is all calculator 35 Questions All Multiple Choice.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Objective – Students will be able to investigate graphs with different viewing windows or viewing screens. Therefore learning how important it is to choose.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
1 U08181 Computer Graphics Clipping Transformations –Transformations and matrices –Homogeneous matrices –Transformations in SVG.
Solving Systems of Equations by Graphing.  System of Equations- Two or more equations with the same variables  Consistent- A system of equations with.
Section 1.1 Graphs and Graphing Utilities
Computer Graphic 2 D Viewing.
Matrices Rules & Operations.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
7.1 – Cartesian Co-ordinate System & Linear Equations in Two Variables
Unit 5 Transformations Review
11. Viewing Transformations
Geometric Transformations Hearn & Baker Chapter 5
Computer Graphics CC416 Week 15 3D Graphics.
Mathematics of the Simple Camera
CS1550 Fundamentals For Computer Graphics Transformations-1
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
Graphics Fundamentals
CSCE 441 Computer Graphics 3-D Viewing
Understanding the Viewing Rectangle/Window of the Graphing Calculator
Introduction to Computer Graphics CS 445 / 645
2D Viewing Pipeline.
UNIT 2 – Linear Functions
CENG 477 Introduction to Computer Graphics
Viewing Transformations
WINDOWING AND CLIPPING
Section 1.1 Graphs and Graphing Utilities
Unit 2: Transformations of functions
Warmup NO CALCULATORS Convert into radians or degrees.
Section 1.1 Graphs and Graphing Utilities
Transformations 3 University of British Columbia
Computer Graphics Lecture 20
WINDOWING AND CLIPPING
2D Graphics Lecture 4 Fri, Aug 31, 2007.
CS1550 Fundamentals For Computer Graphics Transformations-2
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Viewing Transformations II
Warm Up 6.3 Complete the chart for the given counterclockwise rotations about the origin. 90o 180o 270o R(3, -3) S(1, 4) Use.
Presentation transcript:

Window to Viewport Transformations CS 455 – Computer Graphics Window to Viewport Transformations

Compositing Transformations Does order matter? Case 1: translate by (–2, 0), scale by (2, 2) Case 2: scale by (2, 2), translate by (-2, 0) Begin: red, 1st transform: purple, 2nd: green Y Y 2,3 2,3 3,1 1,1 3,1 1,1 X X Case 1(translate then scale) Case 2 (scale then translate)

Compositing Transformations Does order matter? Case 1: translate by (–2, 0), scale by (2, 2) Case 2: scale by (2, 2), translate by (-2, 0) Begin: red, 1st transform: purple, 2nd: green Y Y 0,2 4,2 2,6 0,6 -2,2 2,2 2,2 6,2 4,6 2,3 -1,1 0,3 2,3 3,1 3,1 1,1 1,1 X X Case 1(translate then scale) Case 2 (scale then translate)

Composition Example In general, transformations are not commutative Scale(2.0,2.0); Translate(-2.0,0.0); drawTriangle(); Translate(-2.0, 0.0); Scale(2.0,2.0); drawTriangle(); In general, transformations are not commutative

Window-to-Viewport Transform Need to transform points from “world” view (window) to the screen view (viewport) Maintain relative placement of points (usually) Can be done with a translate-scale-translate sequence Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 60 50 40 x 30 20 10 10 20 30 40 50 60 70 80 u

Window “Window” refers to the area in “world space” or “world coordinates” that you wish to project onto the screen Location, units, size, etc. are all determined by the application, and are convenient for that application Units could be inches, feet, meters, kilometers, light years, etc. The window is often centered around the origin, but need not be Specified as (x,y) coordinates Window (“world”) y (xmax, ymax) -3 -2 -1 1 2 3 -4 4 x (xmin, ymin)

Viewport The area on the screen that you will map the window to Specified in “screen coordinates” - (u,v) coordinates The viewport can take up the entire screen, or just a portion of it Viewport (screen) v (umax, vmax) 60 50 40 30 20 10 (umin, vmin) 10 20 30 40 50 60 70 80 u

Viewport (cont) You can have multiple viewports They can contain the same view of a window, different views of the same window, or different views of different windows Viewport (screen) v 60 50 40 30 20 10 10 20 30 40 50 60 70 80 u

Window-to-Viewport Transform (cont.) The window-to-viewport transform is: 1. Translate lower-left corner of window to origin 2. Scale width and height of window to match viewport’s 3. Translate corner at origin to lower-left corner in viewport Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 Move lower left to origin. Scale to screen size Move lower left from viewport origin to screen lower left x u 10 20 30 40 50 60 70 80

Window-to-Viewport Transform (cont.) The final window-to-viewport transform is:

Window-to-Viewport Transform (cont.) Multiplying the matrix Mwv by the point p gives:

Window-to-Viewport Example Window: (xmin, ymin) = (-3, -3), (xmax, ymax) = (2 , 1) Viewport: (umin, vmin) = (30, 10), (umax, vmax) = (80, 30) Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 x u 10 20 30 40 50 60 70 80

Window-to-Viewport Example Plugging the values into the equation: Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 x u 10 20 30 40 50 60 70 80

Window-to-Viewport Example Plugging the values into the equation:

Window-to-Viewport Example So: Trying some points: (xmin, ymin) = (-3, -3) -> (xmax, ymax) = (2, 1) -> Left eye = (-1, -.8) -> Top of head = (-0.5, 0.5) -> Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 x u 10 20 30 40 50 60 70 80

Window-to-Viewport Example So: Trying some points: (xmin, ymin) = (-3, -3) -> (30, 10) (xmax, ymax) = (2, 1) -> (80, 30) Left eye = (-1, -.8) -> (50, 21) Top of head = (-0.5, 0.5) -> (55, 27.5) Window (“world”) Viewport (screen) v y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 x u 10 20 30 40 50 60 70 80

Window-to-Viewport Transform (cont.) What if the viewport origin is top-left? 1. Use the same equation, but subtract the results from (vmax + vmin) Window (“world”) Viewport (screen) y u 10 20 30 40 50 60 70 80 This is just a change in v by the way, u is unchanged. -3 -2 -1 1 2 3 -4 4 60 50 40 30 20 10 x v

Window-to-Viewport Transform (cont.) Rationale: 1. If vmin = 0, we reverse the results of our equation by subtracting it from vmax, i.e., vmax -> 0 and 0 -> vmax 2. If we take (vmax - vmin) we get the correct scale factor 3. We need to move the point in question back to the v-axis, then scale 4. We need to add vmin to get from the v-axis back to the original point location, so the scaling is correct Thus, we have (vmax - vmin) - (p - vmin) + vmin = vmax + vmin - p

Window-to-Viewport Example - downward pointing v-axis Window: (xmin, ymin) = (-3, -3), (xmax, ymax) = (2 , 1) Viewport: (umin, vmin) = (30, 10), (umax, vmax) = (80, 30) Window (“world”) Viewport (screen) y -3 -2 -1 1 2 3 -4 4 10 20 30 40 50 60 70 80 60 50 40 30 20 10 u x v

Window-to-Viewport Example - downward pointing v-axis The equation for this situation is:

Window-to-Viewport Example - downward pointing v-axis So: Trying some points: (xmin, ymin) = (-3, -3) -> (xmax, ymax) = (2, 1) -> Left eye = (-1, -.8) -> Top of head = (-0.5, 0.5) -> Window (“world”) Viewport (screen) y 10 20 30 40 50 60 70 80 60 50 40 30 20 10 u -3 -2 -1 1 2 3 -4 4 x v

Window-to-Viewport Example - downward pointing v-axis So: Trying some points: (xmin, ymin) = (-3, -3) -> (30, 30) (xmax, ymax) = (2, 1) -> (80, 10) Left eye = (-1, -.8) -> (50, 19) Top of head = (-0.5, 0.5) -> (55, 12.5) Window (“world”) Viewport (screen) y 10 20 30 40 50 60 70 80 60 50 40 30 20 10 u -3 -2 -1 1 2 3 -4 4 x v