started to implement second algorithm
This commit is contained in:
@@ -6,7 +6,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace TMI_practicum
|
namespace TMI_practicum
|
||||||
{
|
{
|
||||||
internal class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -34,6 +34,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
|
<Reference Include="Priority Queue, Version=4.2.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<HintPath>..\packages\OptimizedPriorityQueue.4.2.0\lib\net45\Priority Queue.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
@@ -45,6 +49,10 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SimpleAlgorithm.cs" />
|
<Compile Include="SimpleAlgorithm.cs" />
|
||||||
|
<Compile Include="SweepLineAlgorithm.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
4
TMI-practicum/packages.config
Normal file
4
TMI-practicum/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="OptimizedPriorityQueue" version="4.2.0" targetFramework="net461" />
|
||||||
|
</packages>
|
Reference in New Issue
Block a user