GithubHelp home page GithubHelp logo

nol0n / segment_intersection Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 40 KB

A B-Tree implementation of sweep line algorithm for segment intersection

CMake 3.51% C++ 96.49%
2-3-tree b-tree segment-intersection sweep-line sweep-line-algorithm template

segment_intersection's Introduction

Краткое описание

Тут в программе алгоритм проверки наличия пересечения в множестве отрезков, только самого факта наличия пересечения, без возврата конкртной точки пересечения, пары отрезков и т.д.

Реализовано два метода

  • Наивный - проверка всез со всеми, что занимает O(n^2)
  • Алгоритм заметающей прямой, где в качестве структуры данных для хранения отрезков используется B-Tree (2-3 Tree, не B+ Tree), его сложность - O(n*log(n))

Сами методы находятся в service.cpp

B-Tree

Данная стуктура данных реализована в виде шаблонного класса в заголовочных файлах, находится в папке headers. Там класс звена и самого дерева. (мне кажется, что наибольший инетерес здесь представляет именно этот класс).

Спасибо этому человеку, без его разбора, я бы вряд-ли написал это дело в разумные сроки.

Сборка и использование

  1. склоинруйте репозиторий

    git clone https://github.com/nol0n/segment_intersection.git

  2. создайте папку build (я предпочитаю out-of-source build, когда папка с бинарниками лежит рядом с папкой репозитория)

    mkdir ..\build

  3. перейдите в папку build

    cd .\build

  4. сконфигурирейте проект (при работе я использовал mingw)

    cmake ..\segment_intersection -G Ninja

  5. соберите проект

    cmake --build .

В папке директория_сборки\application будет seg_test, при его запуске будет выполнено два небольших теста, где сравниваается быстродействие алгоритмов. Результаты будут записаны в файлы рядом с исполняемым файлом.

segment_intersection's People

Contributors

nol0n 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.