1
0

improvement

This commit is contained in:
2019-05-21 14:49:12 +02:00
parent c022a2915b
commit a7b988a977
4 changed files with 149 additions and 43 deletions

View File

@@ -10,7 +10,8 @@ namespace TMI_practicum
{
public static void Main(string[] args)
{
GetChartData();
CheckAlgo();
//GetChartData();
if (args.Length < 1)
{
Console.WriteLine("Please enter a file.");
@@ -51,6 +52,62 @@ namespace TMI_practicum
}
private static void CheckAlgo()
{
bool failed = false;
int i = 0;
while (!failed)
{
Console.WriteLine("start check {0}", i++);
var circles = CreateRandomCircles(5);
var correctSol = SweepLineAlgorithm.Solve(circles);
var solved = SweepLineEffAlgorithm.Solve(circles);
foreach (var intersection in correctSol)
{
if (solved.Contains(intersection)) continue;
if (solved.Contains(new Intersection(intersection.X + 10e-15, intersection.Y)) ||
solved.Contains(new Intersection(intersection.X - 10e-15, intersection.Y)) ||
solved.Contains(new Intersection(intersection.X + 10e-15, intersection.Y + 10e-15)) ||
solved.Contains(new Intersection(intersection.X + 10e-15, intersection.Y - 10e-15)) ||
solved.Contains(new Intersection(intersection.X - 10e-15, intersection.Y - 10e-15)) ||
solved.Contains(new Intersection(intersection.X - 10e-15, intersection.Y - 10e-15)) ||
solved.Contains(new Intersection(intersection.X, intersection.Y + 10e-15)) ||
solved.Contains(new Intersection(intersection.X, intersection.Y - 10e-15))
) continue;
failed = true;
Console.WriteLine("Not found: {0}\t{1}", intersection.X, intersection.Y);
Console.WriteLine("corrrect");
foreach (var intersection1 in correctSol)
{
Console.WriteLine("{0}\t{1}", intersection1.X, intersection1.Y);
}
Console.WriteLine("wrong");
foreach (var intersection1 in solved)
{
Console.WriteLine("{0}\t{1}", intersection1.X, intersection1.Y);
}
Console.WriteLine("Cirkels");
foreach (var circle in circles)
{
Console.WriteLine("(x-{0})^2 + (y-{1})^2 = {2}^2", circle.X, circle.Y, circle.R);
}
foreach (var circle in circles)
{
Console.WriteLine("{0} {1} {2}", circle.X, circle.Y, circle.R);
}
break;
}
}
}
private static List<Circle> CreateRandomCircles(double amount)
{
var circles = new List<Circle>();
@@ -59,7 +116,7 @@ namespace TMI_practicum
for (int i = 0; i < amount; i++)
{
circles.Add(new Circle(Math.Round(rnd.NextDouble() * 1.0, 15), Math.Round(rnd.NextDouble() * 1.0, 15),
Math.Round(rnd.NextDouble() * 0.01, 15)));
Math.Round(rnd.NextDouble() * 0.90 + 0.05, 15)));
}
return circles;