66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Priority_Queue;
|
|
|
|
namespace TMI_practicum
|
|
{
|
|
public static class SweepLineAlgorithm
|
|
{
|
|
public static IEnumerable<Intersection> Solve(IList<Circle> circles)
|
|
{
|
|
// fuck deze priority queue piece of shit.... >:(
|
|
SimplePriorityQueue<Event, double> events = new SimplePriorityQueue<Event, double>();
|
|
Stack<Intersection> intersections = new Stack<Intersection>();
|
|
var segments = new List<Segment>();
|
|
|
|
|
|
|
|
|
|
foreach (var circle in circles)
|
|
{
|
|
events.Enqueue(new Event(Event.EventType.Start, circle.X - circle.R), circle.X - circle.R);
|
|
events.Enqueue(new Event(Event.EventType.End, circle.X + circle.R), circle.X + circle.R);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
private struct Event
|
|
{
|
|
public EventType Type { get; }
|
|
public double X { get; }
|
|
|
|
public enum EventType
|
|
{
|
|
Start,
|
|
End,
|
|
Intersect
|
|
}
|
|
|
|
public Event(EventType type, double xCoordinate)
|
|
{
|
|
Type = type;
|
|
X = xCoordinate;
|
|
}
|
|
}
|
|
|
|
|
|
private struct Segment
|
|
{
|
|
public SegmentType Type { get; }
|
|
public Circle Circle { get; }
|
|
public enum SegmentType
|
|
{
|
|
Top,
|
|
Bottom
|
|
}
|
|
|
|
public Segment(Circle circle, SegmentType type)
|
|
{
|
|
Circle = circle;
|
|
Type = type;
|
|
}
|
|
}
|
|
}
|
|
} |