11 views

Uploaded by Sunil Bhoj

pppt

save

- 37 Graphics Contest
- Leapfrog Geo Tutorials
- =fsdnna Content the Odyssey Ruububric
- Jun 2004 Prodesktop
- CLO 4.0 Atelier Lo Nuevo
- CV 802 Charles Victor.pdf
- Viewing
- World's Computer Graphics Community
- How to Create a Wavy Wall - Evermotion
- D[1].Sujeeth Sankar
- KET Training Brochure
- AUTOCAD Tips for Beginner
- Basic Graphics Terms
- END GAME
- Game Development with Unity3D.pdf
- Project Management and Executive Assistant
- 40573 guidelines
- Polygons 2 Color Scree Shots 3copies
- Ever Stress Fe 10
- 2017-03-Shaders
- Ch. 12 Report Organization & Presentation
- CSG IT.in.Business
- ANIMA Annotated Sequence Chart 08-09
- biodiversity website rubric
- text features chart
- Lectura Ingles
- RGB-D Edge Detection and Edge-based Registration
- Current Guidelines
- Disease Power Point
- Question Bank
- dg
- A
- Document
- Document
- Rajesh
- b Sc Hons Physics Optics Phht-412 Sem IV
- 54160586 Working Capital Project
- Clean and Sanitize
- Pay Pont Excel
- Sharma
- bhawna.rtf
- Chandan Singh Rawat
- Chandan Singh Rawat
- Alexander
- b Sc Hons Physics Optics Phht-412 Sem IV
- Rakhi Sharma
- 1
- r.s
- Deep
- 30069090 Bharati Airtel Marketing Research Paper Ppt 111225081021 Phpapp01
- Abstract
- fldsjflskjfslf
- Bhawna Sharma
- 90146809-Dabur-Project.docx
- fldsjflskjfslf
- Anand Saxena
- Map
- Horlicks
- fjsdlkjf

You are on page 1of 23

Lecture 15:

Clipping

COMP 175: Computer Graphics November 1, 2011

Remco Chang 15 – Clipping 1/22

COMP 175 | COMPUTER GRAPHICS

Discussions

**Library trip Camera assignment
**

problems debugging methods

**Midterm Eval General discussion on how we can do better
**

15 – Clipping 2/22

Remco Chang

COMP 175 | COMPUTER GRAPHICS Clipping Last week we discussed some simple examples of clipping in Camera We said that OpenGL takes care of a lot of that for free But clipping is an important part of computer graphics: Remco Chang 15 – Clipping 3/22 .

y) Remco Chang 15 – Clipping 4/22 . ymax) (x.COMP 175 | COMPUTER GRAPHICS Line Clipping (xmin . ymin) (xmax .

COMP 175 | COMPUTER GRAPHICS Parametric Line Formulation for Clipping Remco Chang 15 – Clipping 5/22 .

COMP 175 | COMPUTER GRAPHICS Cohen-Sutherland Line Clipping in 2D Clip Rectangle Remco Chang 15 – Clipping 6/22 .

then we do divide-and-conquer Subdivide line into two segments and test again C B I A H G F Clip rectangle E Use a clip edge to cut line Use outcodes to choose which edge is crossed The bits that are different between outcodes will tell us which edge to examine Pick an order for checking edges: top – bottom – right – left Compute the intersection point Clip edge will be axis-aligned.. E-I at H) 15 – Clipping 7/22 Remco Chang .g.COMP 175 | COMPUTER GRAPHICS Cohen-Sutherland Algorithm D If we can neither trivially accept or reject. might need multiple passes (e. so we can fix either the x or the y Can substitute into the line equation Iterate for the newly created line segment.

y0. y1 = y. ComputeOutCode(x1. repeat check for trivial reject or trivial accept pick the point that is outside the clip rectangle if TOP then x = x0 + (x1 – x0) * (ymax – y0)/(y1 – y0). y0 is the outer point) then x0 = x. y0. x = xmax. else if LEFT then y = y0 + (y1 – y0) * (xmin – x0)/(x1 – x0). y = ymax. outcode0). if (x0. y0. xmax. ComputeOutCode(x1. y1. else if BOTTOM then x = x0 + (x1 – x0) * (ymin – y0)/(y1 – y0). outcode1) until done DrawRectangle(xmin. y1. y0. x1. ComputeOutCode(x0. else if RIGHT then y = y0 + (y1 – y0) * (xmax – x0)/(x1 – x0). ymin. outcode1). y1) ComputeOutCode(x0. x1. y1) Remco Chang 15 – Clipping 8/22 . ymax) DrawLine (x0. x = xmin.COMP 175 | COMPUTER GRAPHICS Cohen-Sutherland Algorithm Algorithm (float x0. outcode0) else x1 = x. y = ymin. y0 = y.

COMP 175 | COMPUTER GRAPHICS Cohen-Sutherland Algorithm in 3D Similar to 2D Divide volume into 27 regions (picture a Rubik’s cube) 6-bit outcode records results of 6 bounds tests 1st / 2nd bits: back & front planes 3rd / 4th bits: top & bottom planes 5th / 6th bits: right & left planes The same operation as the 2D case in using outcodes Back plane 000000 (in front) Front plane 010000 (in front) Top plane 001000 (above) 000000 (below) 100000 (behind) 000000 (behind) Bottom plane 000000 (above) 000100 (below) Right plane 000000 (to left of) 000010 (to right of) Left plane 000001 (to left of) 000000 (to right of) Remco Chang 15 – Clipping 9/22 .

COMP 175 | COMPUTER GRAPHICS Sutherland-Hodgman Polygon Clipping Remco Chang 15 – Clipping 10/22 .

COMP 175 | COMPUTER GRAPHICS Cyrus-Beck / Liang-Barsky Parametric Line Clipping Remco Chang 15 – Clipping 11/22 .

COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping Remco Chang 15 – Clipping 12/22 .

Using Dot Product Find t Note that if t is less than 0 or greater than 1. then the intersection occurs outside of the line segment 15 – Clipping 13/22 Remco Chang .COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping.

Solving t Remco Chang 15 – Clipping 14/22 .COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping.

the normal should not be 0. it must be that: Ni 0 (that is.COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping. if they are. Solving t solve for t: t = Ni • [P0 – PE ] / (-Ni • D) i Caveats: for this equation to be true. P1 P0) Ni • D 0 (edge Ei and line D are not parallel. no intersection) The algorithm needs to check for these 15 – Clipping 15/22 Remco Chang . this could occur only as a mistake) D 0 (that is.

how can you tell?? 15 – Clipping 16/22 Remco Chang . 1] Determine if the intersection is considered potentially entering (PE) or potentially leaving (PL) Problem. Against A Polygon PL PE When applied to line-clipping. there will be multiple t values (a t value for each clip edge test) Eliminate t values outside of [0.COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping.

Against A Polygon Remco Chang 15 – Clipping 17/22 .COMP 175 | COMPUTER GRAPHICS Parametric Line Clipping.

if PE then tE = max(tE. tL = 1.t). if PL then tL = min(tL. end if tE > tL then return nil else return P(tE) and P(tL) as true clip intersections end Remco Chang 15 – Clipping 18/22 . else begin tE = 0. for each candidate intersection with a clip edge if Ni • D 0 then {Ignore edges parallel to line} begin calculate t. {of line and clip edge intersection} use sign of Ni • D to categorize as PE or PL. for each line segment to be clipped if P1 = P0 then line is degenerate so clip as a point.COMP 175 | COMPUTER GRAPHICS Pseudocode Pre-calculate Ni and select PEi for each edge.t).

COMP 175 | COMPUTER GRAPHICS Questions? Remco Chang 15 – Clipping 19/22 .

and same or similar algorithms can be applied 15 – Clipping 20/22 Remco Chang .COMP 175 | COMPUTER GRAPHICS Other Types of Clipping The intersection test can be extended to 3D Here we try to find the intersection point (I) between a line segment (AC) and a cube Problem is the same as the 2D one.

it is similar to the Cyrus-Beck algorithm. but in 3D 15 – Clipping 21/22 Remco Chang . points a and b) Since clipping works with line segments..COMP 175 | COMPUTER GRAPHICS Other Types of Clipping Clipping works on edges of triangles (see right) New vertices might have to be created (e.g.

COMP 175 | COMPUTER GRAPHICS Sutherland-Hodgman Polygon Clipping Keeps polygon info intact Remco Chang 15 – Clipping 22/22 .

COMP 175 | COMPUTER GRAPHICS Questions? Remco Chang 15 – Clipping 23/22 .

- 37 Graphics ContestUploaded byСлободан Душанић
- Leapfrog Geo TutorialsUploaded byJhony Wilson Vargas Barboza
- =fsdnna Content the Odyssey RuububricUploaded byayy lmanon
- Jun 2004 ProdesktopUploaded byKrocodile
- CLO 4.0 Atelier Lo NuevoUploaded bykrajan
- CV 802 Charles Victor.pdfUploaded byNash GoldMan
- ViewingUploaded bynishasaiyed2304
- World's Computer Graphics CommunityUploaded byWurx
- How to Create a Wavy Wall - EvermotionUploaded byMasood67
- D[1].Sujeeth SankarUploaded bySujeeth Sankar
- KET Training BrochureUploaded byChuks Uche
- AUTOCAD Tips for BeginnerUploaded byWilfredoEnghoy
- Basic Graphics TermsUploaded byKalyan Chakravarthy Tripuraneni
- END GAMEUploaded byAmy
- Game Development with Unity3D.pdfUploaded byAnonymous TvuzWBgrI
- Project Management and Executive AssistantUploaded byNaresh Kumar
- 40573 guidelinesUploaded byShaun Gadzikwa
- Polygons 2 Color Scree Shots 3copiesUploaded bymadhu6888
- Ever Stress Fe 10Uploaded byKharisma Rahman Fadillah
- 2017-03-ShadersUploaded bydickykaisar
- Ch. 12 Report Organization & PresentationUploaded byAli Zulfiqar
- CSG IT.in.BusinessUploaded byMuzamil Ahmad Khan
- ANIMA Annotated Sequence Chart 08-09Uploaded byCCA Academic Advising
- biodiversity website rubricUploaded byapi-238949685
- text features chartUploaded byapi-203595942
- Lectura InglesUploaded bylaciudaddecristal
- RGB-D Edge Detection and Edge-based RegistrationUploaded bynewkid2202
- Current GuidelinesUploaded bylelo2k3
- Disease Power PointUploaded bypiglatta7580
- Question BankUploaded byAnoop Cadlord

- dgUploaded bySunil Bhoj
- AUploaded bySunil Bhoj
- DocumentUploaded bySunil Bhoj
- DocumentUploaded bySunil Bhoj
- RajeshUploaded bySunil Bhoj
- b Sc Hons Physics Optics Phht-412 Sem IVUploaded bySunil Bhoj
- 54160586 Working Capital ProjectUploaded bySunil Bhoj
- Clean and SanitizeUploaded bySunil Bhoj
- Pay Pont ExcelUploaded bySunil Bhoj
- SharmaUploaded bySunil Bhoj
- bhawna.rtfUploaded bySunil Bhoj
- Chandan Singh RawatUploaded bySunil Bhoj
- Chandan Singh RawatUploaded bySunil Bhoj
- AlexanderUploaded bySunil Bhoj
- b Sc Hons Physics Optics Phht-412 Sem IVUploaded bySunil Bhoj
- Rakhi SharmaUploaded bySunil Bhoj
- 1Uploaded bySunil Bhoj
- r.sUploaded bySunil Bhoj
- DeepUploaded bySunil Bhoj
- 30069090 Bharati Airtel Marketing Research Paper Ppt 111225081021 Phpapp01Uploaded bySunil Bhoj
- AbstractUploaded bySunil Bhoj
- fldsjflskjfslfUploaded bySunil Bhoj
- Bhawna SharmaUploaded bySunil Bhoj
- 90146809-Dabur-Project.docxUploaded bySunil Bhoj
- fldsjflskjfslfUploaded bySunil Bhoj
- Anand SaxenaUploaded bySunil Bhoj
- MapUploaded bySunil Bhoj
- HorlicksUploaded bySunil Bhoj
- fjsdlkjfUploaded bySunil Bhoj