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.
|Genre:||Health and Food|
|Published (Last):||12 August 2011|
|PDF File Size:||12.53 Mb|
|ePub File Size:||1.95 Mb|
|Price:||Free* [*Free Regsitration Required]|
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!
Diagram 1 GOAL - Clip line to the inside of the lighter blue area To begin with, we assume that we want to draw the whole line. In reality of course, this would only apply if the line was fully inside the lighter blue area. But bear with me, since the following algorithm will gradually clip it down, edge by edge. So the beginning of the line P0 will be represented by 0, and the end of the line P1 by 1. We can store these values in variables, as we will need to adjust them as the algorithm progresses.
We need to find out some values before we proceed. Anyway, we start with a Now go to next edge. Otherwise, skip to next edge. Do the same for the other edges! There are slight differences though. The complete code! White onwards other than the code which you can freely use.
Liang-Barsky Line Clipping Algorithm with C/C++
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.
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.
Liang Barsky Line Clipping Algorithm in C and C++