Nicholl Lee Nicholl Line Clipping
By creating more regions around the clip window the Nicholl Lee Nicholl Line Clipping algorithm avoids multiple clipping of an individual line segment.
In Cohen-Sutherland line clipping sometimes multiple calculations of the intersection point of a line done before actual window boundary intersection or line completely rejected.
These multiple intersection calculations are avoided in NLN line clipping procedure.
NLN line clipping performs the fewer comparisons and divisions so it more efficient.
But NLN line clipping cannot extend for three dimensions while Cohen-Sutherland and Liang-Barsky algorithm can be easily extended for three dimensions.
The forgiven line we find the first point falls in which region out of nine regions shown in the figure below but three regions shown in the figure by putting the point only considered. And if a point falls in other regions than we transfer that point in one of the three regions.
- Three possible positions for a line endpoint p1 in the NLN line-clipping algorithm.
- We can also extend this procedure to all nine regions.
- Regions named in such a way that name. In which region p2 falls is gives the window edge which intersects the line.
- For example, region LT says that line needs to clip at left and top boundary.
- Moreover, For finding that in which region line 𝒑𝟏𝒑𝟐 falls we compare the slope of the line to the slope of the boundaries:
For example, p1 is in the edge region and for checking whether p2 is in region LT we use the following equation.
- After checking slope condition we need to check whether it crossing zero, one or two edges.
- This can do by comparing coordinates of 𝑝2 with coordinates of window boundary.
- For left and right boundary we compare coordinates and for top and bottom boundary we compare
- If a line does not fall within any defined region than clip entire line.
- Otherwise, calculate intersection.
- After finding region we calculate intersection point using the parametric equation which are:
- 𝒙 = 𝒙𝟏 + (𝒙𝟐 − 𝒙𝟏)𝒖
- 𝒚 = 𝒚𝟏 + (𝒚𝟐 − 𝒚𝟏)𝒖
For left or right boundary, 𝑥 = 𝑥𝑙 𝑜𝑟 𝑥𝑟 respectively, with 𝑢 = (𝑥𝑙/𝑟 – 𝑥1)/ (𝑥2 – 𝑥1). So that can obtain from the parametric equation as below: Nicholl Lee Nicholl Line Clipping
Keep the portion which is inside and clips the rest.