0% found this document useful (0 votes)
31 views

LBClip

The idea of the L-B clipping algorithm is to do as much testing as possible before computing line intersections. A line parallel to a clipping window edge has pk = 0 for that boundary. If for that k, qk 0, the line proceeds inside to outside. For nonzero pk, u = qk / pk gives the intersection point.

Uploaded by

smj2525
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

LBClip

The idea of the L-B clipping algorithm is to do as much testing as possible before computing line intersections. A line parallel to a clipping window edge has pk = 0 for that boundary. If for that k, qk 0, the line proceeds inside to outside. For nonzero pk, u = qk / pk gives the intersection point.

Uploaded by

smj2525
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

2D Liang-Barsky Clipping (Hearn and Baker)

The idea of the L-B clipping algorithm is to do as much testing as possible before computing line intersections. Consider first the usual parametric form of a straight line: x y = x0 + u (x1 - x0) = x0 + u x = y0 + u (y1 - y0) = y0 + u y

A point is in the clip window if xmin x0 + u x xmax ymin y0 + u y ymax which can be expressed as the 4 inequalities u pk qk where p1 p2 p3 p4 = = = = -x x -y y q1 q2 q3 q4 = = = = k = 1, 2, 3, 4 x0 - xmin xmax - x0 y0 - ymin ymax - y0 (left) (right) (bottom) (top)

1. A line parallel to a clipping window edge has pk = 0 for that boundary. 2. If for that k, qk < 0, the line is completely outside and can be eliminated. 3. When pk < 0 the line proceeds outside to inside the clip window and when pk > 0, the line proceeds inside to outside. 4. For nonzero pk, u = qk/pk gives the intersection point. 5. For each line, calculate u1 and u2. For u1, look at boundaries for which pk < 0 (outside in). Take u1 to be the largest among (0, qk/pk). For u2, look at boundaries for which pk > 0 (inside out). Take u2 to be the minimum of (1, qk/pk). If u1 > u2, the line is outside and therefore rejected.

You might also like