# Liang-Barsky Line Clipping

### Algorithm

1. Initialize line intersection parameters: m1 <- 0, m2
<- 1

2. Compute dx, dy

3. For each window boundary

repeat

compute q, P

if P < 0 (outside> inside) then

compute INT = q / P

if INT > m2 then reject

else if INT > m1 then m1 ¬ INT

else if P > 0 (inside -> outside) then

compute INT <- q / p

if INT < m1 then reject else if INT < m2 then m2 <-
int. else P = 0

if q < 0 reject

4. If m1 is greater than 0 (has been modified) compute new x1,
y1

5. If m2 is less than 1 (has been modified) compute new x2, y2

Go
back to previous screen

HyperGraph
Table of Contents.

HyperGraph Home
page.

Last changed May 13, 1998, G. Scott Owen, owen@siggraph.org