-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRounder.cs
63 lines (56 loc) · 2.34 KB
/
Rounder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using lib;
namespace SquareConstructor
{
public class Rounder
{
public static IEnumerable<Polygon[]> FindRounds(Polygon initialPolygon,
Vector roundPoint,
Dictionary<Segment, List<Polygon>> neightbourhood)
{
Segment firstSegment = null;
var lastSegment = GetAnotherSegmentWithPoint(initialPolygon, firstSegment, roundPoint);
var lastPoint = GetAnotherPointOfSegment(lastSegment, roundPoint);
var neightbours = GetNeightbours(initialPolygon, firstSegment, neightbourhood);
foreach (var neightbour in neightbours)
{
var nSegment = GetAnotherSegmentWithPoint(neightbour, firstSegment, roundPoint);
var nPoint = GetAnotherPointOfSegment(nSegment, roundPoint);
if (nPoint.Equals(lastPoint))
return null;//резутат
//if (nPoint.Equals())
//если точка совпадает с последней - это хорошо
//если точка недокуржилась - рекусрия
//если точка перекружилась - стоп
}
return null;
//помнить про луч
}
private static Segment GetAnotherSegmentWithPoint(Polygon polygon, Segment segment, Vector point)
{
return polygon.Segments
.FirstOrDefault(s => (s.Start.Equals(point) || s.End.Equals(point))
&& !s.Equals(segment));
}
private static Vector GetAnotherPointOfSegment(Segment segment, Vector point)
{
return segment.Start.Equals(point) ? segment.End : segment.Start;
}
private static Vector Get90Point(Vector roundPoint, Vector zeroPoint, bool clookwise)
{
throw new NotImplementedException();
}
private static Vector Get180Point(Vector roundPoint, Vector zeroPoint)
{
throw new NotImplementedException();
}
private static Polygon[] GetNeightbours(Polygon polygon, Segment segment, Dictionary<Segment, List<Polygon>> neightbourhood)
{
return null;
//flip
//contact
}
}
}