• Tidak ada hasil yang ditemukan

Clipping

N/A
N/A
Protected

Academic year: 2024

Membagikan "Clipping"

Copied!
17
0
0

Teks penuh

(1)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

• Any convex region as window

Parametric line (input line AB):

) 1 , 0 (

; ) (

)

( t == A ++ B −− A t t ∈ ∈ L

A

B

(2)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P n

• Q

Implicit line (window edge):

Tells us on which side of the line the point Q is.

n P Q

Q

l ( ) == ( −− ).

(3)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P n

• Q

n P Q

Q

l( ) == ( −− ).

Evaluate

If > 0 inside halfspace of line (plane) If < 0 outside halfspace of line (plane) If = 0 on the line

Should give indications for trivial accept and reject cases.

Inside Outside

(4)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P n

• Q

n P Q

Q

l ( ) == ( −− ).

Inside Outside

) (

)

( t A t B A

L == ++ −−

Window edge Line segment

0 )

( AND 0

)

( A << l B <<

l

0 )

( AND 0

)

(A >> l B >>

l Trivial Reject Trivial Accept

(5)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P

n

(6)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P n

A B

t A B

A t

L ( ) == ++ ( −− )

t for solve

; 0 ))

(

( L t ==

l

n P Q

Q

l ( ) == ( −− ).

0 ).

( ).

(

0 ).

) (

(

0 ).

) ( (

==

−−

++

−− −− −− ==

++ −− ==

n A B

t n P A

n P A

B t A

n P t

L

(7)

Clipping

Cyrus Beck Line Clipping

(Liang and Barsky)

P n

A B

n P B

n P A

n P t A

n B A

n P t A

).

( ).

(

).

( ).

(

).

(

−−

−−

−−

== −−

−−

== −−

(8)

Clipping

B

n Which ‘t’ to select ?

(t=0)

(t=1)

Cyrus Beck Line Clipping

(Liang and Barsky)

A

(9)

Clipping

A

B

n

(t=0)

(t=1)

Cyrus Beck Line Clipping

(Liang and Barsky)

n A B

D

n A B

n P t A

).

(

).

(

).

(

−−

== −− −−

== −−

D > 0 label t as tE Entering

(10)

Clipping

A

B

n

(t=0)

(t=1)

Cyrus Beck Line Clipping

(Liang and Barsky)

n A B

D

n A B

n P t A

).

(

).

(

).

(

−−

== −− −−

== −−

D < 0 label t as tL Leaving

(11)

Clipping

A

B

n

(t=0)

(t=1)

Cyrus Beck Line Clipping

(Liang and Barsky)

t of interest:

largest tE smallest tL

max

t

E min

t

L
(12)

Clipping

If

Cyrus Beck Line Clipping

(Liang and Barsky)

min max

L

E

t

t >>

Reject

(13)

Clipping

Arbitrary Convex Window

P1

V1

Cyrus Beck Line Clipping

(Liang and Barsky)

V2

V3 V4 V5

V6 V7

V8

P2

E1 E2 E3 E4 E5

E6

E7 E8

(14)

Clipping

Arbitrary Convex Window

P1

V1

Cyrus Beck Line Clipping

(Liang and Barsky)

V2

V3 V4 V5

V6 V7

V8

P2

E1 E2 E3 E4 E5

E6

E7

E8

Polygon is convex if for all adjacent edges the sign of cross product is same.

positive xE

E

positive xE

E

: :

3 2

2 1

.

.

.

(15)

Clipping

Arbitrary Window

Cyrus Beck Line Clipping

(Liang and Barsky)

Polygon is non-convex

negative xE

E

positive xE

E

positive xE

E

: : :

4 3

3 2

2 1

. . .

V1 V2

V3 V4

V5 V6

E1

E2 E3 E4

(16)

Clipping

Arbitrary Window

Cyrus Beck Line Clipping

(Liang and Barsky)

V1 V2

V3 V4

V5 V6

E1

E2 E3 E4

Make the polygon convex by adding the edge V3V5

Clip against the convex polygon

=> P3P4

P1

P2

P3

P4

(17)

Clipping

Arbitrary Window

Cyrus Beck Line Clipping

(Liang and Barsky)

V3 V4

V5 Clip against the triangle

=> P5P4

Subtract P5P4 from P3P4

=> P3P5

P3

P4 P5

Referensi

Dokumen terkait