Sie sind auf Seite 1von 13

qwertyuiopasdfghjklzxcvbnmqwertyui

opasdfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmqwer
CLIPPING
tyuiopasdfghjklzxcvbnmqwertyuiopas
dfghjklzxcvbnmqwertyuiopasdfghjklzx
01/11/2010

ESTHELA SANDOVAL RAMÓN

cvbnmqwertyuiopasdfghjklzxcvbnmq
PERLA GUADALUPE GARCIA MERCADO

wertyuiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopasdfghj
klzxcvbnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
vbnmqwertyuiopasdfghjklzxcvbnmrty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
2D CLIPPING

Clipping de punto

Se asume que la ventana está definida por:

Xl Xr Yb Yt

Luego punto de corte es sencillo y simple

Punto (x, y) si se traza

x 2 [xl, xr];
y
x 2 [yb; yt]

Preste atención a

(1) las coordenadas homogéneas


(2) ecuaciones de las líneas
LINEA DE RECORTE

Las operaciones de la línea de recorte deben incluir los siguientes


casos:

 Totalmente trazado
 Parcialmente trazados
 No registrados

Tenga en cuenta que a pesara de que ninguno de los 2 vértices se


encuentra dentro de la ventana, cierta parte del segmento de línea
puede ser aun dentro.

Hay muchas técnicas diferentes para recorte de líneas de 2D. Los


fundamentos son:

 Las ecuaciones de la línea y la computación.


 Intersección.
ALGORITMO COHEN-SUTHERLAND

No es el algoritmo más eficiente.

Es el más utilizado.

La técnica clave es el código de 4 bits:

TBRL donde:

T se establece (1) si y> arriba


B se establece (1) si y <inferior
I se establece (1) si x> derecha
L se establece (1) si x <a la izquierda
ALGORITMO

Supongamos dos extremos son P0 y P1.

Si el código (P0), es el código de 0 (P1) es 0000, la línea puede ser


fácilmente aceptada entonces la línea se dibuja.

Si el código (P0) y el código (P1) no es 0000, la línea puede ser


fácilmente rechazada, la línea no se dibuja del todo.

En caso contrario, se deben calcular los puntos de intersección del


segmento de línea y las líneas de la ventana del límite.

*se debe asegurar que todas las líneas del limita.


Intersection Computation
_ Line equation
y = y1 +m(x - x1)
where

_ Line intersection with the left vertical boundary


x=l
Assume the intersection is c

Line ab is clipped w.r.t. x = l, now it becomes cb

_ Line intersection with the top boundary


y=t
Assume the intersection is d

Line cb is clipped w.r.t. y = t, line cb becomes cd

_ Line intersection with the right boundary


x=r
Assume the intersection is e

Line cd is clipped w.r.t. x = r, line cd becomes ce

_ Line intersection with the bottom boundary


y=b
Assume the intersection is f

Line ce is clipped w.r.t. y = b, line ce becomes fe

_ So, the entire process is ab

Note that, various improvements are possible! using parametric


representation of line questions,
P230
create more regions around the clip window,
P233
line clipping using polygon
 convex polygon, P235
 concave polygon, split in into several convex polygon, P236

Polygon Clipping
POLYGON CLIPPING

_ Line clipping algorithms will lead to a set of disjoint line segment


chains
_ In general, clipping each edge will not work !
_ We shall not clip each edge of the polygon w.r.t. the window
boundary one at a time
_ We treat the polygon as a whole object
_ Clip the entire object against each boundary of the window
_ Sutherland-Hodgman algorithm
 any polygon (convex or concave)
 any convex clipping polygon

POLYGON CLIPPING EXAMPLE


Algorithm

_ Sutherland-Hodgman algorithm

_ Vertex list of the current polygon )

_ Clip against edges of the window boundary )

_ New vertex list of the new polygon

_ The algorithm clips against all four edges in a sequential order,


producing a new vertex list each time.
REFERENCIA

http://www.cs.sunysb.edu/~cse328/fall2005-notes-8.pdf

Das könnte Ihnen auch gefallen