From 57314a0a94de75a051228f7f3ab22b757f6693a0 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Wed, 15 May 2019 11:23:57 +0200 Subject: [PATCH] started to implement second algorithm --- TMI-practicum/Program.cs | 4 +- TMI-practicum/SweepLineAlgorithm.cs | 66 +++++++++++++++++++++++++++++ TMI-practicum/TMI-practicum.csproj | 8 ++++ TMI-practicum/packages.config | 4 ++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 TMI-practicum/SweepLineAlgorithm.cs create mode 100644 TMI-practicum/packages.config diff --git a/TMI-practicum/Program.cs b/TMI-practicum/Program.cs index 79df9c6..9a82af8 100644 --- a/TMI-practicum/Program.cs +++ b/TMI-practicum/Program.cs @@ -6,7 +6,7 @@ using System.Linq; namespace TMI_practicum { - internal class Program + internal static class Program { public static void Main(string[] args) { @@ -99,4 +99,4 @@ namespace TMI_practicum } } } -} \ No newline at end of file +} diff --git a/TMI-practicum/SweepLineAlgorithm.cs b/TMI-practicum/SweepLineAlgorithm.cs new file mode 100644 index 0000000..fd51f23 --- /dev/null +++ b/TMI-practicum/SweepLineAlgorithm.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using Priority_Queue; + +namespace TMI_practicum +{ + public static class SweepLineAlgorithm + { + public static IEnumerable Solve(IList circles) + { + // fuck deze priority queue piece of shit.... >:( + SimplePriorityQueue events = new SimplePriorityQueue(); + Stack intersections = new Stack(); + var segments = new List(); + + + + + 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; + } + } + } +} \ No newline at end of file diff --git a/TMI-practicum/TMI-practicum.csproj b/TMI-practicum/TMI-practicum.csproj index 844d10a..61bc847 100644 --- a/TMI-practicum/TMI-practicum.csproj +++ b/TMI-practicum/TMI-practicum.csproj @@ -34,6 +34,10 @@ + + ..\packages\OptimizedPriorityQueue.4.2.0\lib\net45\Priority Queue.dll + True + @@ -45,6 +49,10 @@ + + + +