Computer Science 474 Spring 2010 Viewing Transformation

Similar documents
Computer Graphics. The Two-Dimensional Viewing. Somsak Walairacht, Computer Engineering, KMITL

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Two-Dimensional Viewing. Chapter 6

CS602 MCQ,s for midterm paper with reference solved by Shahid

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

Chapter 5. Projections and Rendering

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

SHAPE AND STRUCTURE. Shape and Structure. An explanation of Mathematical terminology

Number/Computation. addend Any number being added. digit Any one of the ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Unit 3 Transformations and Clipping

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Part 3: 2D Transformation

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

3D Rendering Pipeline (for direct illumination)

Lesson Polygons

CSCI 4620/8626. Computer Graphics Clipping Algorithms (Chapter 8-5 )

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling

pine cone Ratio = 13:8 or 8:5

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

The radius for a regular polygon is the same as the radius of the circumscribed circle.

CARDSTOCK MODELING Math Manipulative Kit. Student Activity Book

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking

Beaumont Middle School Design Project April May 2014 Carl Lee and Craig Schroeder

Geometry Vocabulary. acute angle-an angle measuring less than 90 degrees

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Instructional Alignment Chart

Unit 10 Study Guide: Plane Figures

6 Mathematics Curriculum

Generating Vectors Overview

absolute value- the absolute value of a number is the distance between that number and 0 on a number line. Absolute value is shown 7 = 7-16 = 16

Mathematics Curriculum

Answer Key: Three-Dimensional Cross Sections

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

Course Number: Course Title: Geometry

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

CS 4204 Computer Graphics

CSE328 Fundamentals of Computer Graphics

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Computer Graphics: Two Dimensional Viewing

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

Geometry Practice. 1. Angles located next to one another sharing a common side are called angles.

Geometry: Semester 2 Practice Final Unofficial Worked Out Solutions by Earl Whitney

Einführung in Visual Computing

Polygons. Discuss with a partner what a POLYGON is. Write down the key qualities a POLYGON has. Share with the class what a polygon is?

Park Forest Math Team. Meet #3. Self-study Packet

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S

Mathematics RIT Score:

S206E Lecture 3, 5/15/2017, Rhino 2D drawing an overview

The University of Calgary

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

Aptitude Test Question

2009 Fall Startup Event Thursday, September 24th, 2009

On Your Own. ). Another way is to multiply the. ), and the image. Applications. Unit 3 _ _

Points and lines, Line drawing algorithms. Circle generating algorithms, Midpoint circle Parallel version of these algorithms

Next Generation Math Standards----Grade 3 Cognitive Complexity/Depth of Knowledge Rating: Low, Moderate, High

2D/3D Geometric Transformations and Scene Graphs

On a coordinate plane, such a change can be described by counting the number of spaces, vertically and horizontally, that the figure has moved.

MET71 COMPUTER AIDED DESIGN

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming

From Vertices To Fragments-1

Chapter 3: Polynomials. When greeted with a power of a power, multiply the two powers. (x 2 ) 3 = x 6

Geometry 10 and 11 Notes

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

How to draw and create shapes

2013 Four-by-Four Competition Thursday, January 31st, Round Four-by-Four Competition Thursday, January 31st, 2013.

Polygons. Discuss with a partner what a POLYGON is. Write down the key qualities a POLYGON has. Share with the class what a polygon is?

Glossary Common Core Curriculum Maps Math/Grade 6 Grade 8

Three-Dimensional Shapes

More on Coordinate Systems. Coordinate Systems (3) Coordinate Systems (2) Coordinate Systems (5) Coordinate Systems (4) 9/15/2011

K-5 Mathematics Missouri Learning Standards: Grade-Level Expectations

MATHEMATICS Grade 7 Advanced Standard: Number, Number Sense and Operations

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

CSC 418/2504 Computer Graphics, Winter 2012 Assignment 1 (10% of course grade)

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

CIRCLES ON TAKS NAME CLASS PD DUE

CSCI 4620/8626. Coordinate Reference Frames

EXAMINATIONS 2017 TRIMESTER 2

Boardworks Ltd KS3 Mathematics. S1 Lines and Angles

Pick up some wrapping paper.

Lesson 1. Unit 2 Practice Problems. Problem 2. Problem 1. Solution 1, 4, 5. Solution. Problem 3

Unit 1, Lesson 1: Tiling the Plane

The exam begins at 2:40pm and ends at 4:00pm. You must turn your exam in when time is announced or risk not having it accepted.

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

CS 325 Computer Graphics

Chapter 8: Implementation- Clipping and Rasterization

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Patterns in Geometry. Polygons. Investigation 1 UNIT. Explore. Vocabulary. Think & Discuss

3.6: First Person Computer Games

CSAP Achievement Levels Mathematics Grade 7 March, 2006

Scott Foresman Investigations in Number, Data, and Space Content Scope & Sequence Correlated to Academic Language Notebooks The Language of Math

Data Representation in Visualisation

3D Rendering and Ray Casting

Performance Level Descriptors. Mathematics

Transcription:

Viewing Transformation Previous readings have described how to transform objects from one position and orientation to another. One application for such transformations is to create complex models from simple primitives. For example, a robot arm may be composed of cylinders, spheres, and polygons of different sizes and orientations. Transformations may be used as part of the modeling process to describe how the primitive elements are transformed and combined to form the more complex object. Modeling will be described in a later reading. Another application of transformations is to modify the entire scene so that it appears different on the screen to the viewer. For example, if the scene is rendered from the viewer s position and orientation, and the viewer position changes, then the scene needs to be transformed accordingly before being drawn to the screen. This is best described by considering two separate coordinate systems. The world coordinate system, or world space, is where objects are defined. This space may be very application specific. For example, if modeling subatomic particles, coordinates may be specified in angstroms while if modeling the universe, light years may be more appropriate. The position of the viewer may be some arbitrary location in world space. However, angstroms and light years do not fit on the screen very well, so a different space is necessary to define where to put things on the screen. This is known as screen space. The typical measurements for screen space are in pixels. Although we think of the screen as two dimensional, screen space can be defined as three dimensional, in which the Z axis is perpendicular to the screen and defines what objects are in front of other objects for display purposes. The process of converting from world space to screen space is known as the viewing transformation. Various pieces of information are combined to transform objects defined in world space to places on the screen to draw graphic primitives. Examples of the necessary information are: Viewer position and orientation Point being looked at Distance from viewer to projection window Location and orientation of viewing window (viewport) on the screen This reading will focus on the concepts and process of the 2 D viewing transformation while the next reading will expand these to the 3 D case. Windows and Viewports As described, world coordinates are specified in whatever units make sense for the application. An architect drawing a 2 D set of plans for a building may use feet or meters for defining the drawing while a cartographer creating a map of a country may use miles or kilometers. Regardless of the unit, it is necessary to specify what portion of the world is going to be displayed to the screen. This is done by specifying a window in the world that will get mapped to the screen. The window can be specified by the corners of the rectangle in world space coordinates. This is shown in Figure 1. Whatever is visible in 1

the window in world coordinates gets mapped to the screen coordinates. Note that if the window is not the same size or aspect ratio as the screen display area, distortion of the displayed image can result. Also note that there is no requirement for the window to be aligned with the world axes, and may be rotated by some amount. This might indicate the viewer has tilted his head. Figure 1. Viewport in world space mapped to screen. In screen space, rather than map the window to the entire screen, the user can select an area of the screen to display the window in, known as the viewport. A single screen can contain several viewports of the same scene, or different scenes. The viewport can be sized differently than the window or rotated to different orientations. Figure 2 shows a screen containing different viewports of the world space window shown in Figure 1. Note how the differently shaped and oriented viewports change the image. Although different systems use different terminology, we will use the term window to refer to the rectangular area in world space that represents what we want to view. It is, literally, the window into the world through which we are looking. The viewport is the porthole on the screen that we are looking through to see the objects in the window. Figure 2. Different viewports of same window. 2

Mapping objects from the window to the viewport can be accomplished by defining a viewing transformation and applying it to every object visible in the window. Logically, if you defined a transformation that successfully transforms the corners of the window to the corners of the viewport, that transformation will work properly for all objects contained in the window. To accomplish this, we will develop the transformation in a two step process. First, transform the window to a normalized or canonical window of unit size centered about the world origin. Next, transform the canonical window to the correct location and orientation for the viewport. A window can be defined by:,, center of the window in world coordinates width and height of the window in world coordinates angle of rotation of the window about its center To transform the window, we will translate the center to the world origin, rotate by to align it with the axes, and scale by 1/,1/. Using the standard transformation matrices previously described. This sequence can be annotated by:,, (1) Applying this transformation to all points in the window will result in the coordinates lying between 0.5 and 0.5 in both the and directions. The next step is to transform this canonical window to the viewport. Similar to a window, a viewport can be defined by:,, center of the viewport in screen coordinates width and height of the viewport in screen coordinates angle of rotation of the viewport about its center The proper sequence to transform the canonical coordinates is scale to the appropriate size, rotate about the origin, and translate the origin to the viewport center. In matrix notation,,, (2) These two sequences, (1) and (2), can be combined into a single viewing transformation matrix. When each point in the window is multiplied by this matrix, the appropriate screen coordinates result. Clipping If all of the objects in world space are transformed with the viewing transformation, there will be objects both inside and outside of the viewing area. The process of removing parts of the scene that are not visible in the window/viewport is known as clipping. In Figure 1, the pentagon in the lower right portion of world space was clipped totally out of the final scene and the circle was partially clipped. Clipping can be done at various points along the viewing process. For example, all objects can be clipped to the edges of the original viewing window, and only visible objects need to be transformed to the final screen coordinates. Alternatively, all objects can be transformed, and the transformed objects can be clipped to the viewport. To simplify the clipping operation, we will assume clipping occurs after 3

the first part of the viewing transformation (1). Thus, all objects are transformed to the canonical coordinates in world space before being clipped. The advantage of this is that the clipping window is a well defined rectangle centered about the origin. After clipping, only the visible points remain and are transformed with the second part of the viewing transformation, (2), for final display. The process of clipping depends on the type of object being clipped. Clipping Points The simplest drawing primitive to clip is the point. The, coordinates of the point simply need to be checked against the boundaries of the clipping window to determine if the point is inside or outside the window. Here the advantage of deferring clipping until after the first transformation can be seen. If the window were rotated in world space, the determination of inside or outside is not as simple. The disadvantage of waiting until after the first transformation is that all points need to transformed, even if the viewing window is a relatively small part of the overall scene. If there is a performance issue for the particular application, the clipping operation may be accomplished before the transformation. Clipping Lines Since we are conducting clipping to a rectangle, we can identify four discrete cases as shown in Figure 3. If both ends of the line are interior to the rectangle, as in A, the entire line is visible. If both ends are exterior the line may be totally invisible, as in B, or partially visible as in D, in which case the end line segments would be clipped and removed. Finally, if only one end of the line is interior, as in C, then the line needs to be clipped to the appropriate boundary. Figure 3. Possible line clipping configurations: A totally interior; B totally exterior; C one end interior; D ends exterior, crosses boundary An easy way to accomplish the line clipping cases shown above is to successively clip each line against the half spaces defined by the edges of the window. The half space is defined by extending the boundary line infinitely in each direction, with one side designated as being 4

outside the window. Figure 4 shows the progressive clipping of the lines to each of the four half spaces defined by the window. For the half space defined by the top edge of the window, both lines B and C were intersected with the half space line, the portion of both lines lying in the outside part of the half space were discarded. Lines A and D had both ends on the inside of the half space and were kept. For the right edge half space, line D was clipped, and the remainder of line B was discarded as both ends were on the outside of the half space. The bottom edge clipped line D, and the left edge did not clip or remove any lines. The remaining parts of the lines are all contained in the window and can be transformed to the viewport accordingly. Clipping Polygons Figure 4. Clipping lines to half spaces defined by window boundaries. Clipping polygons will follow a similar strategy as clipping lines. Each edge of each polygon can be classified similar to Figure 3. An additional complication in clipping polygons is that a corner of the window may become a corner of the clipped polygon as shown in Figure 5. Note the star in the lower left corner, when clipped, will consist of two edges formed from part of the left and bottom edge of the window along with parts of the original polygon as shown on the right. 5

Figure 5. Clipping polygons to window. The described polygon clipping algorithm is known as the Sutherland Hodgeman algorithm after its inventors. The vertices of the polygon to be clipped are ordered from 1 to n in clockwise order and added to a vertex list. Figure 6 shows the initial configuration of a five vertex polygon to be clipped at the top. Each edge, in order of vertices, is clipped to the half space defined by the top of the window, as shown in part A of Figure 6. Notice that when line 2 3 was clipped, a new point at the window top edge was added to the list. When line 3 4 was clipped, another point was added and the old point 3 discarded. The vertex list now represents a polygon with six vertices that has been clipped to the top edge. The process is repeated for the right, bottom, and left edge as shown in B, C, and D. When finished, the clipped polygon has 8 vertices. Figure 6. Step by step polygon clipping. 6

This algorithm works for every convex polygon, polygons with every internal angle less than 180 degrees. Note that it is possible for a concave polygon to result in two separate pieces after clipping as shown in Figure 7. Using the algorithm described, there are seven vertices after clipping as shown in the middle of the Figure. However, if you simply treat the set of vertices as a polygon and connect them together, you end up with the extra line going from vertex 7 to vertex 1 as shown on the right in the Figure. Special consideration needs to be taken to avoid this error. One solution is to convert any concave polygons to convex polygons prior to clipping. For example, any polygon can be converted to triangles which are guaranteed to be convex. Another solution, known as the Weiler Atherton algorithm traverses the vertices of a polygon in order looking at whether edges to be clipped are traversing from outside to inside the window or vice versa. If it is going from inside to outside, the window edge is followed as the next line versus the polygon edge. With this approach, the correct two clipped polygons, as shown in the middle of Figure 7, are generated. Clipping other primitives Figure 7. Concave polygon resulting in error. In addition to points, lines, and polygons, the scene to be clipped may consist of other geometric shapes, such as ellipses or circles, or different types of curves. Special clipping algorithms can be developed for each type of object. Or, more commonly, such primitives are converted to one of the three cases described and clipped accordingly. For example, a filled circle can be represented as a polygon with many edges and clipped using the polygon clipping routine. For text, a simpler approach would be to check the bounding box of each character and only display characters whose bounding box is completely interior to the viewing window. This is shown in the middle image of Figure 8. Note that characters straddling the window boundary are lost. Alternatively, each character can be converted to a polygon and clipped as shown on the right. Figure 8. Clipping text. 7

LAGNIAPPE Pac Man While Pong was one of the earliest computer games created, arguably Pac Man, created by Namco in 1980, is perhaps the most well known. According to the Davie Brown Celebrity Index, Pac Man has the highest brand awareness of any video game character among American consumers, recognized by 94 percent of them. The game was developed primarily by Namco employee Tōru Iwatani over eighteen months. The original title was pronounced pakku man where paku paku describes the sound of the mouth movement when widely opened and then closed in succession. The game was picked up for manufacture in the United States by Bally under the altered title Pac Man. The name was changed from Puck Man to Pac Man, as it was thought that vandals would be likely to change the P in "puck" to an F, forming a common expletive. Puck Man machines can still be found throughout Europe. Guinness World Records has awarded the Pac Man series eight records in Guinness World Records: Gamer's Edition 2008, including "First Perfect Pac Man Game" for Billy Mitchell's July 3, 1999 score; "Most Successful Coin Operated Game"; and "Largest Pac Man Game", when, in 2004, students from New York University created Pac Manhattan, a real life reenactment of the game, in which people dressed as Pac Man and the four ghosts chased each other around Manhattan city blocks. Each player was teamed with a controller who communicated the player's positions using cellular phones. 8