started to implement second algorithm
This commit is contained in:
66
TMI-practicum/SweepLineAlgorithm.cs
Normal file
66
TMI-practicum/SweepLineAlgorithm.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user