• No results found

LEC_12_Polygon clipping rules.pdf

N/A
N/A
Protected

Academic year: 2020

Share "LEC_12_Polygon clipping rules.pdf"

Copied!
35
0
0

Loading.... (view fulltext now)

Full text

(1)

Polygon Clipping

(2)

Clipping Polygons

• Clipping polygons is more complex than

clipping the individual lines

– Input: polygon

– Output: original polygon, new polygon, or

nothing

• When can we trivially accept/reject a

polygon as opposed to the line segments

that make up the polygon?

(3)

Why Is Clipping Hard?

• What happens to a triangle during

clipping?

• Possible outcomes:

Nihar Ranjan Roy 3

triangle  triangle triangle

quad triangle

5-gon
(4)

How many sides?

• Seven…

(5)

Why Is Clipping Hard?

• A really tough case:

(6)

Why Is Clipping Hard?

• A really tough case:

Nihar Ranjan Roy 6

(7)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually

– Clip the polygon against the viewport edge’s

equation

(8)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(9)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(10)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(11)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(12)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(13)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(14)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(15)

Sutherland-Hodgeman Clipping

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(16)

Sutherland-Hodgeman Clipping:

• Basic idea:

– Consider each edge of the viewport individually – Clip the polygon against the edge equation

– After doing all edges, the polygon is fully clipped

(17)

Sutherland-Hodgeman Clipping

• Input/output for algorithm:

– Input: list of polygon vertices in order

– Output: list of clipped poygon vertices

consisting of old vertices (maybe) and new

vertices (maybe)

• Note: this is exactly what we expect from

the clipping operation against each edge

(18)

Sutherland-Hodgeman Clipping

• Sutherland-Hodgman basic routine:

– Go around polygon one vertex at a time

– Current vertex has position

p

– Previous vertex had position

s

, and it has been

added to the output if appropriate

(19)

Sutherland-Hodgeman Clipping

• Edge from s to p takes one of four cases:

(Yellow line can be a line or a plane)

Nihar Ranjan Roy 19

(20)

Sutherland-Hodgeman Clipping

Nihar Ranjan Roy 20

1

3

6

4

2

(21)

Sutherland-Hodgeman Clipping

Nihar Ranjan Roy 21

1

3

6

4

2

(22)

Sutherland-Hodgeman Clipping

Nihar Ranjan Roy 22

1

3

6

4

2

(23)

Sutherland-Hodgeman Clipping

Nihar Ranjan Roy 23

(24)

Sutherland-Hodgeman Clipping

Nihar Ranjan Roy 24

1`

2`

3`

(25)

Weiler Atherton polygon clipping Rule

Nihar Ranjan Roy 25

•Walk around the Polygon/window Boundary

(it depends on the direction of traversing)

(26)

Weiler Atherton polygon clipping Rule

Nihar Ranjan Roy 26

(27)

Weiler Atherton polygon clipping Rule

Walking rules

Out to inside

Store the clipped point

Follow the polygon boundary (CCW)

Inside to outside

Store the clipped point

Follow the window boundary

(28)

Weiler Atherton polygon clipping Rule

Walking rules

Out to inside

Store the clipped point

Follow the polygon boundary (CCW)

Inside to outside

Store the clipped point

Follow the window boundary

(29)

Weiler Atherton polygon clipping Rule

Walking rules

Out to inside

Store the clipped point

Follow the polygon boundary (CCW)

Inside to outside

Store the clipped point

Follow the window boundary

(30)

Weiler Atherton polygon clipping Rule

Walking rules

Out to inside

Store the clipped point

Follow the polygon boundary (CCW)

Inside to outside

Store the clipped point

Follow the window boundary

(31)

Weiler Atherton polygon clipping Rule

Walking rules Out to inside

 Store the clipped point

 Follow the polygon boundary (CCW)

Inside to outside

 Store the clipped point

 Follow the window boundary

(32)

Comparison of the two techniques

(33)

Comparison of the two techniques

Nihar Ranjan Roy 33

Sutherland Hodgeman

(34)

Comparison of the two techniques

Nihar Ranjan Roy 34

(35)

Comparison of the two techniques

Nihar Ranjan Roy 35

References

Related documents