Net migration rate

From formulasearchengine
Revision as of 00:10, 2 December 2013 by 84.3.71.228 (talk)
Jump to navigation Jump to search

In computer graphics, the Liang–Barsky algorithm (named after You-Dong Liang and Brian A. Barsky) is a line clipping algorithm. The Liang–Barsky algorithm uses the parametric equation of a line and inequalities describing the range of the clipping window to determine the intersections between the line and the clipping window. With these intersections it knows which portion of the line should be drawn. This algorithm is significantly more efficient than Cohen–Sutherland.

The idea of the Liang-Barsky 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=x0+u(x1x0)=x0+uΔx
y=y0+u(y1y0)=y0+uΔy

A point is in the clip window, if

xminx0+uΔxxmax

and

yminy0+uΔyymax,

which can be expressed as the 4 inequalities

upkqk,k=1,2,3,4,

where

p1=Δx,q1=x0xmin (left)
p2=Δx,q2=xmaxx0 (right)
p3=Δy,q3=y0ymin (bottom)
p4=Δy,q4=ymaxy0 (top)

To compute the final line segment:

  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=qkpk 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,qkpk). For u2, look at boundaries for which pk>0 (inside -> out). Take u2 to be the minimum of (1,qkpk). If u1>u2, the line is outside and therefore rejected.

See also

Algorithms used for the same purpose:

References

  • Liang, Y.D., and Barsky, B., "A New Concept and Method for Line Clipping", ACM Transactions on Graphics, 3(1):1-22, January 1984.
  • Liang, Y.D., B.A., Barsky, and M. Slater, Some Improvements to a Parametric Line Clipping Algorithm, CSD-92-688, Computer Science Division, University of California, Berkeley, 1992.
  • James D. Foley. Computer graphics: principles and practice. Addison-Wesley Professional, 1996. p. 117.