Giter Site home page Giter Site logo

lineintersection's Introduction

LineIntersection

Computational Geometry Assignment 1

Results

We have given an implementation of the Bentley-Ottmann plane sweep algorithm for line segment intersection.
We randomly generated lines by randomly generating their end points and the ran the algorithm on the lines to find the intersection points.

Number of Lines Run Time - Total CPU time(s)
2 ~0.005
10 ~0.005
50 0.011
100 0.023
500 0.110
1,000 0.180
5,000 2.500
10,000 13.400
20,000 61.170

The complexity of the Bentley-Ottmann algorithm is given as O(nlogn + Ilogn)
where n is the number of line segments and I is the number of intersection points.
The run time observed does not indicate how much the complexity is for each input size,
but instead we can observe the trend of how the time takes rows as a function of the imput size.
The actual time also depends upon the memory allocation and allotment for vector and tree data
structures.


## Input ![Input Image](linesInput.png "Input through Qt GUI")
## Output ![Output Image](linesOutput.png "Output displyed using matplotlib")

## An example of the line intersection computation: ### Status Tree Generation Insertion happens at a given Y - Co-ordinate which is 2 for this case. - (0,0) (0,2) - (0,0) (2,2) - (0,0) (2,4) - (0,0) (2,6) - (0,0) (2,8)

Generating the tree:

0.000000 0.000000 2.000000 6.000000 4

0.000000 0.000000 0.000000 2.000000 3

0.000000 0.000000 0.000000 2.000000 1

0.000000 0.000000 2.000000 8.000000 2

0.000000 0.000000 2.000000 8.000000 1

0.000000 0.000000 2.000000 6.000000 1

0.000000 0.000000 2.000000 4.000000 2

0.000000 0.000000 2.000000 4.000000 1

0.000000 0.000000 2.000000 2.000000 1

Popping the line (0,0) - (2,6) at Y = 2 yields the tree:

0.000000 0.000000 2.000000 4.000000 4

0.000000 0.000000 0.000000 2.000000 3

0.000000 0.000000 0.000000 2.000000 1

0.000000 0.000000 2.000000 8.000000 2

0.000000 0.000000 2.000000 8.000000 1

0.000000 0.000000 2.000000 2.000000 2

0.000000 0.000000 2.000000 4.000000 1

Event Queue Generation

Let the event points be (assuming all upper end points to show the value of U stored):

  • (1,2)
  • (2,3)
  • (3,4)
  • (3,6)
  • (3,5)

Generating the tree:

2.000000 3.000000 3 U:2.000000 3.000000 3.000000 4.000000

1.000000 2.000000 1 U:1.000000 2.000000 2.000000 1.000000

3.000000 5.000000 2 U:3.000000 5.000000 4.000000 3.000000

3.000000 4.000000 1 U:3.000000 4.000000 2.000000 3.000000

3.000000 6.000000 1 U:3.000000 6.000000 7.000000 4.000000

Popping results:

Popping event point 3.000000,6.000000 New Tree:

2.000000 3.000000 3 U:2.000000 3.000000 3.000000 4.000000

1.000000 2.000000 1 U:1.000000 2.000000 2.000000 1.000000

3.000000 5.000000 2 U:3.000000 5.000000 4.000000 3.000000

3.000000 4.000000 1 U:3.000000 4.000000 2.000000 3.000000

Main algorithm

For the lines:

  • (1,1) - (11,11)
  • (1,11) - (11,1)
  • (1,11) - (11,11)
  • (11,11) - (11,1)
  • (11,1) - (1,1)
  • (1,1) - (1,11)

Results:

Intersection: 1.000000 11.000000

Intersection: 11.000000 11.000000

Intersection: 6.000000 6.000000

Intersection: 1.000000 1.000000

Intersection: 11.000000 1.000000

Execution complete Execution time in secinds: 0.191

Instructions for running the code:

  • Install Qt5 for gui:
  • Install matplotlib for displaying results:
  • compile run.cpp
  • run code: bash execute.sh

lineintersection's People

Contributors

pulse28 avatar yashdeep97 avatar yohanmr avatar

Watchers

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