The Liang-Barsky line clipping algorithm in a nutshell! At Skytopia, we pride ourselves in making some of the most difficult concepts as easy to understand as possible. It was created after I went through torture trying to research it myself for my uni course. We hope you agree that the colour coding, examples, numerous diagrams pixel-precise and to scale!
|Country:||Central African Republic|
|Published (Last):||23 June 2008|
|PDF File Size:||15.19 Mb|
|ePub File Size:||9.30 Mb|
|Price:||Free* [*Free Regsitration Required]|
The line is divided in two parts. Mid points of line is obtained by dividing it in two short segments. Again division is done, by finding midpoint.
This process is continued until line of visible and invisible category is obtained. Let xi,yi are midpoint x5lie on point of intersection of boundary of window. Advantage of midpoint subdivision Line Clipping: It is suitable for machines in which multiplication and division operation is not possible.
Because it can be performed by introducing clipping divides in hardware. Step4: For the line to be clipped. Ymis midpoint of Y coordinate. Step5: Check each midpoint, whether it nearest to the boundary of a window or not. Step6: If the line is totally visible or totally rejected not found then repeat step 1 to 5. Step7: Stop algorithm. Example: Window size is -3, 1 to 2, 6. A line AB is given having co-ordinates of A -4, 2 and B -1, 7.
Does this line visible. Find the visible portion of the line using midpoint subdivision? A and B""are now endpoints Find mid of A and B"" A -4, 2 B "" -1, 6 Liang-Barsky Line Clipping Algorithm: Liang and Barsky have established an algorithm that uses floating-point arithmetic but finds the appropriate endpoints with at most four computations. This algorithm uses the parametric equations for a line and solves four inequalities to find the range of the parameter for which the line is in the viewport.
Let P x1, y1 , Q x2, y2 is the line which we want to study. The parametric equation of the line segment from gives x-values and y-values for every point in terms of a parameter that ranges from 0 to 1. Algorithm of Liang-Barsky Line Clipping: 1. Calculate the values tL,tR,tT and tB tvalues.
If t max?
Mid Point Subdivision Line Clipping Algorithm:
Next Page The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane. Point Clipping Clipping a point from a given window is very easy. Consider the following figure, where the rectangle indicates the window. Point clipping tells us whether the given point X, Y is within the given window or not; and decides whether we will use the minimum and maximum coordinates of the window. Line Clipping The concept of line clipping is same as point clipping.
The Liang-Barsky line clipping algorithm in a nutshell!
Clipping Case: If the line is neither visible case nor invisible case. It is considered to be clipped case. First of all, the category of a line is found based on nine regions given below. All nine regions are assigned codes. Each code is of 4 bits. If both endpoints of the line have end bits zero, then the line is considered to be visible. The center area is having the code, , i.