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

Post on 28-Mar-2015

222 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Many slides are borrowed from Foley & Van Dam

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

??

Line Clipping

• Endpoints Configuration– Both inside:

• ?

– One in, one out: • ?

– Both outside:• ?

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • ?

– Both outside:• ?

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • ?

– Both outside:• ?

Line Clipping

• Endpoints Configuration– Both inside:

• No need for clipping

– One in, one out: • 1 intersection point

– Both outside:• ?

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.

Simultaneous Equations

Any better algorithm?P1 P2 Observation

Out Out ?

Exterior half plane Possible interior half plane

Any better algorithm?P1 P2 Observation

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

Exterior half plane Possible interior half plane

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

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

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

1

2

34

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

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

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

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

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

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)

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

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!

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!

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?

top related