Giter Site home page Giter Site logo

handylim / nicholl-lee-nicholl-algorithm Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 18 KB

The fast line clipping algorithm that reduces the chances of clipping a single line segment multiple times, as may happen in the Cohen-Sutherland algorithm

License: Apache License 2.0

CSS 1.12% HTML 7.66% JavaScript 91.22%
algorithm line-clipping line clipping-algorithm javascript

nicholl-lee-nicholl-algorithm's Introduction

Nicholl–Lee–Nicholl Algorithm

Nicholl–Lee–Nicholl algorithm is an algorithm that divides the clipping window to 9 area, and matches the start point’s area code to one of the 9 areas. The area code that being handled by algorithm are 3 area which are inside, left, and top-left area of the clipping window. If the case is not one of the case that handled by algorithm, certain parts of that case (which are line position and the clipping window) are temporarily transformed to the one of the handled case depending on the location. The bottom, right and top cases will be transformed to the left case. The top-right , bottom-right and bottom-left will be transformed to the top-left case.

Then, the imaginary lines are drawn from the starting point to the 4 edges of the clipping window. The areas between the imaginary lines are named according to the side(s) where the line will be clipped from if the end point is in that area.

  1. In inside case, the areas are named T for top, L for left, R for right, and B for bottom.
  2. In left case, the areas are named L for left, TL for top and left, LR for left and right, and TB for top and bottom.
  3. In top-left case, the areas are named L for left , T for top, TR for top and right, LB for left and bottom, and TB for top and bottom or LR for left and right.

The last step is just locate the end point of the line that wants to be clipped, and clipped it according to the name of that area against the side(s) of the clipping window.

nicholl-lee-nicholl-algorithm's People

Contributors

handylim avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.