Review. Scan Conversion. Rasterizing Polygons. Rasterizing Polygons. Triangularization. Convex Shapes. Utah School of Computing Spring 2013



Similar documents
Lesson 2.1 Inductive Reasoning

SECTION 7-2 Law of Cosines

Practice Test 2. a. 12 kn b. 17 kn c. 13 kn d. 5.0 kn e. 49 kn

Ratio and Proportion

1. Definition, Basic concepts, Types 2. Addition and Subtraction of Matrices 3. Scalar Multiplication 4. Assignment and answer key 5.

Quick Guide to Lisp Implementation

Appendix D: Completing the Square and the Quadratic Formula. In Appendix A, two special cases of expanding brackets were considered:

Section 5-4 Trigonometric Functions

Angles 2.1. Exercise Find the size of the lettered angles. Give reasons for your answers. a) b) c) Example

Maximum area of polygon

The remaining two sides of the right triangle are called the legs of the right triangle.

Chapter. Contents: A Constructing decimal numbers

Section 7-4 Translation of Axes

Unit 6: Exponents and Radicals

Words Symbols Diagram. abcde. a + b + c + d + e

EQUATIONS OF LINES AND PLANES

MATH PLACEMENT REVIEW GUIDE

Calculating Principal Strains using a Rectangular Strain Gage Rosette

Reasoning to Solve Equations and Inequalities

LECTURE #05. Learning Objective. To describe the geometry in and around a unit cell in terms of directions and planes.

1. Find the zeros Find roots. Set function = 0, factor or use quadratic equation if quadratic, graph to find zeros on calculator

Vectors Summary. Projection vector AC = ( Shortest distance from B to line A C D [OR = where m1. and m

AREA OF A SURFACE OF REVOLUTION

How To Find The Re Of Tringle

P.3 Polynomials and Factoring. P.3 an 1. Polynomial STUDY TIP. Example 1 Writing Polynomials in Standard Form. What you should learn

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

CS99S Laboratory 2 Preparation Copyright W. J. Dally 2001 October 1, 2001

50 MATHCOUNTS LECTURES (10) RATIOS, RATES, AND PROPORTIONS

SOLVING EQUATIONS BY FACTORING

Interior and exterior angles add up to 180. Level 5 exterior angle

SOLVING QUADRATIC EQUATIONS BY FACTORING

Math 314, Homework Assignment Prove that two nonvertical lines are perpendicular if and only if the product of their slopes is 1.

Or more simply put, when adding or subtracting quantities, their uncertainties add.

Vectors Recap of vectors

PLWAP Sequential Mining: Open Source Code

Multiplication and Division - Left to Right. Addition and Subtraction - Left to Right.

Volumes by Cylindrical Shells: the Shell Method

Chapter. Fractions. Contents: A Representing fractions

A.7.1 Trigonometric interpretation of dot product A.7.2 Geometric interpretation of dot product

BUSINESS PROCESS MODEL TRANSFORMATION ISSUES The top 7 adversaries encountered at defining model transformations

Graphs on Logarithmic and Semilogarithmic Paper

CS 316: Gates and Logic

The art of Paperarchitecture (PA). MANUAL

UNCORRECTED SAMPLE PAGES

Equivalence Checking. Sean Weaver

Binary Representation of Numbers Autar Kaw

Geometry 7-1 Geometric Mean and the Pythagorean Theorem

Student Access to Virtual Desktops from personally owned Windows computers

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

Lecture 3: orientation. Computer Animation

Homework 3 Solutions

Enterprise Digital Signage Create a New Sign

1 GSW IPv4 Addressing

The Pythagorean Theorem

Inter-domain Routing

MA Lesson 16 Notes Summer 2016 Properties of Logarithms. Remember: A logarithm is an exponent! It behaves like an exponent!

Radius of the Earth - Radii Used in Geodesy James R. Clynch Naval Postgraduate School, 2002

If two triangles are perspective from a point, then they are also perspective from a line.

. At first sight a! b seems an unwieldy formula but use of the following mnemonic will possibly help. a 1 a 2 a 3 a 1 a 2

Vectors. The magnitude of a vector is its length, which can be determined by Pythagoras Theorem. The magnitude of a is written as a.

Brillouin Zones. Physics 3P41 Chris Wiebe

c b N/m 2 (0.120 m m 3 ), = J. W total = W a b + W b c 2.00

Released Assessment Questions, 2015 QUESTIONS

End of term: TEST A. Year 4. Name Class Date. Complete the missing numbers in the sequences below.

Angles and Triangles

9.3. The Scalar Product. Introduction. Prerequisites. Learning Outcomes

CHAPTER 31 CAPACITOR

Cell Breathing Techniques for Load Balancing in Wireless LANs

Active Directory Service

One Minute To Learn Programming: Finite Automata

PROBLEMS 13 - APPLICATIONS OF DERIVATIVES Page 1

1 Fractions from an advanced point of view

Factoring Polynomials

OUTLINE SYSTEM-ON-CHIP DESIGN. GETTING STARTED WITH VHDL August 31, 2015 GAJSKI S Y-CHART (1983) TOP-DOWN DESIGN (1)

Operations with Polynomials

Cypress Creek High School IB Physics SL/AP Physics B MP2 Test 1 Newton s Laws. Name: SOLUTIONS Date: Period:

Pure C4. Revision Notes

Physics 43 Homework Set 9 Chapter 40 Key

Mathematics. Vectors. hsn.uk.net. Higher. Contents. Vectors 128 HSN23100

Forensic Engineering Techniques for VLSI CAD Tools

H SERIES. Area and Perimeter. Curriculum Ready.

Experiment 6: Friction

5.2. LINE INTEGRALS 265. Let us quickly review the kind of integrals we have studied so far before we introduce a new one.

- DAY 1 - Website Design and Project Planning

4.5 Signal Flow Graphs

Distributions. (corresponding to the cumulative distribution function for the discrete case).

Module 5. Three-phase AC Circuits. Version 2 EE IIT, Kharagpur

Chap.6 Surface Energy

Computing the 3D Voronoi Diagram Robustly: An Easy Explanation

Summary: Vectors. This theorem is used to find any points (or position vectors) on a given line (direction vector). Two ways RT can be applied:

Bayesian Updating with Continuous Priors Class 13, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

Algebra Review. How well do you remember your algebra?

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

How To Organize A Meeting On Gotomeeting

Fundamentals of Cellular Networks

Review guide for the final exam in Math 233

Multi-level Visualization of Concurrent and Distributed Computation in Erlang

p-q Theory Power Components Calculations

Transcription:

Uth Shool of Computing Spring 2013 Review Leture Set 4 Sn Conversion CS5600 Computer Grphis Spring 2013 Line rsteriztion Bsi Inrementl Algorithm Digitl Differentil Anlzer Rther thn solve line eqution t eh piel, use evlution of line from previous piel nd slope to pproimte line eqution Bresenhm Use integer rithmeti nd midpoint disrimintor to test etween two possile piels (over vs. over-nd-up) Rsterizing Polgons In intertive grphis, polgons rule the world Two min resons: Lowest ommon denomintor for surfes Cn represent n surfe with ritrr ur Splines, mthemtil funtions, volumetri isosurfes Mthemtil simpliit lends itself to simple, regulr rendering lgorithms Like those we re out to disuss Suh lgorithms emed well in hrdwre Rsterizing Polgons Tringle is the miniml unit of polgon All polgons n e roken up into tringles Conve, onve, omple Tringles re gurnteed to e: Plnr Conve Wht etl does it men to e onve? Conve Shpes A two-dimensionl shpe is onve if nd onl if ever line segment onneting two points on the oundr is entirel ontined. Conve polgons esil tringulted Tringulriztion Conve polgons present hllenge Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Rsterizing Tringles Sn Conversion Intertive grphis hrdwre sometimes uses edge wlking or edge eqution tehniques for rsterizing tringles Intertive grphis hrdwre more ommonl uses rentri oordintes for rsterizing tringles In snline rendering surfes re projeted on the sreen nd spe filling rsterizing lgorithms re used to fill in the olor. Color vlues from light re pproimted. Tringle Rsteriztion Issues Etl whih piels should e lit? A: Those piels inside the tringle edges Wht out piels etl on the edge? Drw them: order of tringles mtters (it shouldn t) Don t drw them: gps possile etween tringles We need onsistent (if ritrr) rule Emple: drw piels on left nd ottom edge, ut not on right or top edge Tringle Rsteriztion Issues Sliver Tringle Rsteriztion Issues Moving Slivers Tringle Rsteriztion Issues Shred Edge Ordering Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Edge Equtions How do we know if it s inside? An edge eqution is simpl the eqution of the line defining tht edge Q: Wht is the impliit eqution of line? A: A + B + C = 0 Q: Given point (,), wht does plugging & into this eqution tell us? A: Whether the point is: On the line: A + B + C = 0 Aove the line: A + B + C > 0 Below the line: A + B + C < 0 Edge Equtions Edge equtions thus define two hlf-spes: Edge Equtions And tringle n e defined s the intersetion of three positive hlf-spes: A 3 + B 3 + C 3 < 0 A 3 + B 3 + C 3 > 0 A 2 + B 2 + C 2 < 0 A 2 + B 2 + C 2 > 0 A 1 + B 1 + C 1 > 0 A 1 + B 1 + C 1 < 0 Edge Equtions So simpl turn on those piels for whih ll edge equtions evlute to > 0: - + + - + - Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Sweep-line Sweep-line: Notes Bsi ide: Drw edges vertill Interpolte olors up/down edges Fill in horizontl spns for eh snline At eh snline, interpolte edge olors ross spn Order three tringle verties in nd Find middle point in dimension nd ompute if it is to the left or right of polgon. Also ould e flt top or flt ottom tringle We know where left nd right edges re. Proeed from top snline downwrds (nd other w too) Fill eh spn Until ottom/top verte is rehed Advntge: n e mde ver fst Disdvntges: Lots of finik speil ses Sweep line: Disdvntges Frtionl offsets: Be reful when interpolting olor vlues! Bewre of gps etween djent edges Bewre of dupliting shred edges Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Polgon Sn Conversion Intersetion Points Other points in the spn Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Determining Inside vs. Outside Verties nd Prit Use the odd-prit rule Set prit even initill Invert prit t eh intersetion point Drw piels when prit is odd, do not drw when it is even How do we ount verties, i.e., do we invert prit when verte flls etl on sn line? Sn line????? How do we ount the interseting verte in the prit omputtion? Verties nd Prit We need to either ount it 0 times, or 2 times to keep prit orret. Wht out: Sn line We need to ount this verte one????? Verties nd Prit If we ount verte s one intersetion, the seond polgon gets drwn orretl, ut the first does not. If we ount verte s zero or two intersetions, the first polgon gets drwn orretl, ut the seond does not. How do we hndle this? Count onl verties tht re the min verte for tht line Verties nd Prit How do we del with horizontl edges???? Horizontl Edges Both ses now work orretl Don t ount their verties in the prit lultion! Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Effet of onl ounting min : Top spns of polgons re not drwn Top Spns of Polgons Shred Polgon Edges Drw Lst polgon wins Wht if two polgons shre n edge? If two polgons shre this edge, it is not prolem. Wht out if this is the onl polgon with tht edge? Ornge lst Solution: Spn is losed on left nd open on right ( min < m ) Sn lines losed on ottom nd open on top ( min < m ) Blue lst Generl Piel Ownership Rule Hlf-plne rule: A oundr piel (whose enter flls etl on n edge) is not onsidered prt of primitive if the hlf plne formed the edge nd ontining the primitive lies to the left or elow the edge. Applies to ritrr polgons s well s to retngles... Shred edge Consequenes: Spns re missing the right-most piel Eh polgon is missing its top-most spn Generl Polgon Rsteriztion Consider the following polgon: D B A F C How do we know whether given piel on the snline is inside or outside the polgon? E Inside-Outside Points Polgon Rsteriztion Polgon Rsteriztion Inside-Outside Points Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Generl Polgon Rsteriztion Bsi ide: use prit test for eh snline edgecnt = 0; for eh piel on snline (l to r) if (oldpiel->newpiel rosses edge) edgecnt ++; // drw the piel if edgecnt odd if (edgecnt % 2) setpiel(piel); Generl Polgon Rsteriztion Count our verties refull G F I H E C J D A B Fster Polgon Rsteriztion How n we optimize the ode? for eh snline edgecnt = 0; for eh piel on snline (l to r) if (oldpiel->newpiel rosses edge) edgecnt ++; // drw the piel if edgecnt odd if (edgecnt % 2) setpiel(piel); Big ost: testing piels ginst eh edge Solution: tive edge tle (AET) Ative Edge Tle Ative Edge Tle Ide: Edges interseting given snline re likel to interset the net snline The order of edge intersetions doesn t hnge muh from snline to snline Preproess: Sort on Y Edge Tle Y m, t min,slope Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Ative Edge Tle Ative Edge Tle Preproess: Sort on Y Edge Tle Preproess: Sort on Y Edge Tle AB: Y m, t min,slope Y m, t min,slope AB: 3 7-5/2 CB: Ative Edge Tle Ative Edge Tle Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: 11 13 0 DE: Ative Edge Tle Ative Edge Tle Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: 11 13 0 DE: 11 7 6/4 EF: Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: 11 13 0 DE: 11 7 6/4 EF: 9 7-5/2 FA: Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Ative Edge Tle Ative Edge Tle Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: 11 13 0 DE: 11 7 6/4 EF: 9 7-5/2 FA: 9 2 0 Preproess: Sort on Y Edge Tle Y m, t min,slope AB: 3 7-5/2 CB: 5 7 6/4 CD: 11 13 0 DE: 11 7 6/4 EF: 9 7-5/2 FA: 9 2 0 Wht out Y min? Ative Edge Tle Ative Edge Tle Preproess: Sort on Y Edge Tle Y m, min,slope Algorithm: snline from ottom to top Sort ll edges their minimum oord (lst slide) Strting t smllest Y oord with in entr in edge tle For eh snline: Add edges with Y min = Y (move edges in edge tle to AET) Retire edges with Y m < Y (ompleted edges) Sort edges in AET intersetion Wlk from left to right, setting piels prit rule Inrement snline Relulte edge intersetions (how?) Stop when Y > Y m for edge tle nd AET is empt Ative Edge Tle Ative Edge Tle Emple Algorithm: snline from ottom to top Sort ll edges their minimum oord (lst slide) Strting t smllest Y oord with in entr in edge tle For eh snline: 1. Add edges with Y min = Y (move edges in edge tle to AET) 2. Retire edges with Y m < Y (ompleted edges) 3. Sort edges in AET intersetion 4. Wlk from left to right, setting piels prit rule 5. Inrement snline 6. Relulte edge intersetions (how?) For ever non-vertil edge in the AET updte for the new (lulte the net intersetion of the edge with the sn line). Stop when Y > Y m for edge tle nd AET is empt Emple of n AET ontining edges {FA, EF, DE, CD} on sn line 8: 1. : ( = 8) Get edges from ET uket (none in this se, = 8 hs no entr) 2. : Remove from the AET n entries where m = (none here) 3. : sort X 4. : Drw sn line. To hndle multiple edges, group in pirs: {FA,EF}, {DE,CD} 5. : = +1 ( = 8+1 = 9) 6. : Updte for non-vertil edges, s in simple line drwing. Snline 8 2 3 9 13 Y vl Current X Slope (FvDFH pges 92, 99) Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Ative Edge Tle Emple (ont.) Tringles (ont.) 1. : ( = 9) Get edges from ET uket (none in this se, = 9 hs no entr in ET) Sn line 9 shown in fig 3.28 elow 2. : Remove from the AET n entries with m = (remove FA, EF) 3. : Sort X 4. : Drw sn line etween {DE, CD} 5. : = +1 = 10 6. : Updte in {DE, CD} 7. : ( = 10) (Sn line 10 shown in fig 3.28 elow) 8. And so on Rsteriztion lgorithms n tke dvntge of tringle properties Grphis hrdwre is optimized for tringles Beuse tringle drwing is so fst, mn sstems will sudivide polgons into tringles prior to sn onversion Y vl Current X Slope (FvDFH pges 92, 99) Wh re Brentri oordintes useful? Brentri Coordintes For n point, if the rentri representtion of tht point:,, < 1 Also,, n e used s mss funtion ross the surfe of tringle to e used for interpoltion. This is used to interpolte normls ross the surfe of tringle to mke polgon surfes look rounder. Consider tringle defined three points,, nd. Define new oordinte sstem in whih is the origin, nd define the oordinte sstem sis vetors Note tht the oordinte sstem will e nonorthogonl. Brentri Coordintes Brentri Coordintes - - With this new oordinte sstem, n point n e written s: rerrnging terms, we get: let then p ( ) ( ) p (1 ) ( 1 ) p Computer Grphis CS5600

Uth Shool of Computing Spring 2013 = 2 = 1 =0 = -1 Brentri Coordintes - =-1 - =0 =1 =2 Brentri Coordintes Now n point in the plne n e represented using its rentri oordintes If 1 0 1 0 1 0 1 p then the point lies somewhere in the tringle Brentri Coordintes Computing Brentri Coordintes If one of the oordintes is zero nd the other two re etween 0 nd 1, the point is on n edge If two oordintes re zero nd the other is one, the point is t verte. The rentri oordinte is the signed sled distne from the point to the line pssing through the other two tringle points Impliit form etween two points (,) nd (,) f (, ) ( ) ( ) =-1 =0 =1 f (, ) ( ) ( ) - d=1 = 2 Brentri Coordintes =-1 =0 =1 =2 PDF Slides = 1 - =0 - = -1 Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Computer Grphis CS5600 Computing Brentri Coordintes To ompute the rentri oordintes of point: ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( 1 Brentri Coordinte Applet http://i33www.ir.uk.de/pplets/mo/html/noplugin/inhlt.html Rsterize This! (Rsteriztion intuition) When we render tringle we wnt to determine if piel is within tringle. (rentri oords) Clulte the olor of the piel (use rentri oors). Drw the piel. Repet until the tringle is ppropritel filled. Rsteriztion Pseudo Code Rsteriztion Rsteriztion

Uth Shool of Computing Spring 2013 Rsteriztion Bounding Bo Ym, Xm Ym, Xm Y???, Xmin Y???, Xmin Ymin, X??? Ymin, X??? weighted omintion of verties P P 1 0,, 1 onve omintion of points Brentri Coordintes 1 P2 P3 P 3 P 1 P (1,0,0) 0 (0,0,1) 0. 5 P 2 1 (0,1,0) Brentri Coordintes for I nterpoltion how to ompute,,? use iliner interpoltion or plne equtions interpolte,, z d... one omputed, use to interpolte n # of prmeters from their verte vlues 1 2 3 r r1 r2 r3 g g g et. 1 2 g3 Interpolttion: Gourud Shding Gourud Shding Snline Alg need liner funtion over tringle tht ields originl verte olors t verties use rentri oordintes for this ever piel in interior gets olors resulting from miing olors of verties with weights orresponding to rentri oordintes olor t piels is ffine omintion of olors t verties lgorithm modif snline lgorithm for polgon sn-onversion : linerl interpolte olors long edges of tringle to otin olors for endpoints of spn of piels linerl interpolte olors from these endpoints within the snline Color( 1 Color( ) Color( 1 ) : 2 3 2 ) Color( ) 3 X min X X X X X * C m ur m ur Cmin 1 * m X min X m X min X ur m X m Computer Grphis CS5600

Uth Shool of Computing Spring 2013 Filling Tehniques Another pproh to polgon fill is using filling tehnique, rther thn sn onversion Pik point inside the polgon, then fill neighoring piels until the polgon oundr is rehed Boundr Fill Approh: Drw polgon oundr in the frme uffer Determine n interior point Strting t the given point, do If the point is not the oundr olor or the fill olor Set this piel to the fill olor Propgte to the piel s neighors nd ontinue Filling Tehniques Flood Fill Approh: Set ll interior piels to ertin olor The oundr n e n other olor Pik n interior point nd set it to the polgon olor Propgte to neighors, s long s the neighor is the interior olor This is used for regions with multi-olored oundries Propgting to Neighors Most frequentl used pprohes: 4-onneted re 8-onneted re Region to e filled 4-onneted 8-onneted Fill lgorithms hve potentil prolems E.g., 4-onneted re fill: Fill Prolems Fill Prolems Similrl, 8-onneted n lek over to nother polgon Strting point Fill omplete Strting point Fill omplete Another prolem: the lgorithm is highl reursive Cn use stk of spns to redue mount of reursion Computer Grphis CS5600

225 235 225 235 225 235 Uth Shool of Computing Spring 2013 Pttern Filling Often we wnt to fill region with pttern, not just olor Define n n m pimp (or itmp) tht we wish to replite ross the region 54 pimp How do ou determine the nhor point A point on the polgon Left-most point? The pttern will move with the polgon Diffiult to deide the right nhor point Sreen (or window) origin Esier to determine nhor point The pttern does not move with the ojet Pttern Filling Ojet to e ptterned Finl ptterned ojet Pttern Filling How do we determine whih olor to olor point in the ojet? Use the MOD funtion to tile the pttern ross the polgon For point (, ) Use the pttern olor loted t ( MOD m, MOD n) Pttern Emple For the pttern shown, wht olor does the piel t lotion (235, 168) get olored, ssuming the pttern is nhored t the lower left orner of the ojet? Pttern 168 163??? Pttern Emple Pttern Emple 168??? The pttern piel (2, 0) should mp to sreen lotion (235, 168) Pttern The pttern is 54 163 Need to find the reltive distne to the point to drw: X = (235 225) = 10 Y = (168 163) = 5 (2, 0) Let s mp the pttern onto the polgon nd see 168 163??? Net figure out whih pttern piel orresponds to this sreen piel: X pttern = 10 MOD 4 = 2 Y pttern = 5 MOD 5 = 0 (0, 0) pttern lotion Computer Grphis CS5600

Uth Shool of Computing Spring 2013 The End Leture Set 4 Sn Conversion 103 Computer Grphis CS5600