Skip to content

rob-the-bot/intersect_circles

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Detecting circle intersections in C++

An implementation of the Bentley-Ottmann sweep line algorithm for finding all intersections of a set of circles. For an input consisting of n circles with k crossings, the algorithm takes time O((n+k) log n). In cases where k = o(n^2 / log n), this is an improvement on a naive algorithm that tests every pair of circles, and takes O(n^2). The algorithm works like the Bentley-Ottmann algorithm for finding segment intersections, but uses circle arcs instead of segments.

Example usage

#include "intersect_circles.hpp"

Circle c1 = Circle(Point(0,0), 1); // Circle(center, radius)
Circle c2 = Circle(Point(1,1), 1);
Circle c3 = Circle(Point(1,-1), 1);
Circle c4 = Circle(Point(2,0), 1);

std::vector<Circle> circles = {c1, c2, c3, c4};
std::vector<Point> intersections = circleIntersect(circles);

g++ -o example example.cpp intersect_circles.cpp

./example

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%