many slides are borrowed from foley & van dam. topics viewing transformation pipeline in 2d line...

43
Many slides are borrowed from Foley & Van Dam

Upload: irea-reap

Post on 28-Mar-2015

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Many slides are borrowed from Foley & Van Dam

Page 2: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Topics

• Viewing Transformation Pipeline in 2D• Line and polygon clipping (Slow Fast)– Simultaneous Equations– Cohen-Sutherland Line Clipping Algorithm– Cyrus-Beck / Liang-Barsky Line Clipping Algorithm

• Sutherland-Hodgman Polygon Clipping

Page 3: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 4: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 5: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 6: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 7: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

??

Page 8: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 9: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Line Clipping

• Endpoints Configuration– Both inside:

• ?

– One in, one out: • ?

– Both outside:• ?

Page 10: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • ?

– Both outside:• ?

Page 11: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • ?

– Both outside:• ?

Page 12: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • 1 intersection point

– Both outside:• ?

Page 13: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • 1 intersection point

– Both outside:• 2/0 intersection points

Is more than 2 intersection points possible?

No, intersection of 2 convexes is still a convex.

Page 14: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Simultaneous Equations

Page 15: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 16: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out ?

Exterior half plane Possible interior half plane

Page 17: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out No intersection with the line(reject)In In ?

Exterior half plane Possible interior half plane

Page 18: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out No intersection with the line(reject)In In No intersection with the line

Out/In In/Out ?

Exterior half plane Possible interior half plane

Page 19: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out No intersection with the line(reject)In In No intersection with the line

Out/In In/Out One intersection point with the line

Exterior half plane Possible interior half plane

Page 20: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out No intersection with the line(reject)In In No intersection with the lineO One intersection point with the line

Exterior half plane Possible interior half plane

1 0

1 10 00 11 0

Same encoding

Different encoding

Page 21: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 22: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

1

2

34

Page 23: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cohen-Sutherland for Line Clipping

For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11:

trivially reject; //outside of the windowreturn;

case 00: continue; //no intersection point

case 10 or 01:compute intersection point;refresh one endpoint by the intersection point; continue

0

0

1

Page 24: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cohen-Sutherland for Line Clipping

For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11:

trivially reject; //outside of the windowreturn;

case 00: continue; //no intersection point

case 10 or 01:compute intersection point;refresh one endpoint by the intersection point;

2

Replace endpoint with the intersection Pt

0

1

Page 25: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cohen-Sutherland for Line Clipping

For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11:

trivially reject; //outside of the windowreturn;

case 00: continue; //no intersection point

case 10 or 01:compute intersection point;refresh one endpoint by the intersection point;

3

continue

0

0

Page 26: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cohen-Sutherland for Line Clipping

For line i from 1 to 4 switch P0.bit[i] &P1.bit[i ] case 11:

trivially reject; //outside of the windowreturn;

case 00: continue; //no intersection point

case 10 or 01:compute intersection point;refresh one endpoint by the intersection point;

4

Replace endpoint with the intersection pt

1

0

Page 27: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any even better algorithm?

• A trivial quiz……There are multiple layers of doors for entering a room, and

multiple layers of doors for exiting a room. Assume we don’t know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left.

Door Entering Time Leaving Time

A 0.1

B 0.5

C 0.6

D 0.8

Page 28: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any even better algorithm?

• A trivial quiz……There are multiple layers of doors for entering a room, and

multiple layers of doors for exiting a room. Assume we don’t know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left.

Door Entering Time Leaving Time

A 0.1

B 0.5

C 0.6

D 0.8

Time range of the person in the roomMax(0.1,0.5) – Min(0.6,0.8)

Page 29: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any even better algorithm?

• A trivial quiz……There are multiple layers of doors for entering a room, and

multiple layers of doors for exiting a room. Assume we don’t know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left.

Door Entering Time Leaving Time

A 0.1

B 0.6

C 0.3

D 0.8

Page 30: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Any even better algorithm?

• A trivial quiz……There are multiple layers of doors for entering a room, and

multiple layers of doors for exiting a room. Assume we don’t know the order of the doors. There are only 4 doors A, B, C, D. The doors testify when the person P entered and left

Door Entering Time Leaving Time

A 0.1

B 0.6

C 0.3

D 0.8

Time range of the person in the roomMax(0.1,0.6) – Min(0.3,0.8)

Never in the room!

Page 31: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cyrus-Beck/Liang-Barsky Line ClippingP1

P0

E (t = 0.03)

L (t = 0.85)L(t = 0.8)

E (t = -0.03)

Entering Time:t = 0.13Leaving Time:

t = 0.8

• Ignore t’s <0 or >1• Max(Entering) ~Min(Leaving)• Max(E) > Min(L) ? Totally outside!

Page 32: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations

Cyrus-Beck/Liang-Barsky Line Clipping

• Questions we need to answer:– How to decide entering or leaving– Knowing entering or leaving, how to compute t?

Page 33: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 34: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 35: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 36: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 37: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 38: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 39: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 40: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 41: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 42: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations
Page 43: Many slides are borrowed from Foley & Van Dam. Topics Viewing Transformation Pipeline in 2D Line and polygon clipping (Slow Fast) – Simultaneous Equations