poprawiono usuwanie niepoprawnych dzialek
This commit is contained in:
parent
841bdb9ee7
commit
cb2a6b16f3
@ -132,11 +132,7 @@ namespace Assets.AnnotationPass
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove outside field
|
// remove outside field
|
||||||
city.Fields.RemoveAll(field =>
|
city.Fields.RemoveAll(field => !PointUtils.IsClockwise(field.Boundary));
|
||||||
{
|
|
||||||
var points = field.Boundary.Take(3).ToArray();
|
|
||||||
return !PointUtils.IsClockwise(points[0], points[1], points[2]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Annotate(Map map)
|
public void Annotate(Map map)
|
||||||
|
@ -60,6 +60,11 @@ namespace Assets.Common
|
|||||||
return xa * yb - xb * ya < 0;
|
return xa * yb - xb * ya < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsClockwise(IEnumerable<Point> points)
|
||||||
|
{
|
||||||
|
return points.Zip(points.RotateRight(), (a, b) => (b.x - a.x) * (b.y + a.y)).Aggregate((a, b) => a + b) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsPointInside(Point point, Point[] polygon)
|
public static bool IsPointInside(Point point, Point[] polygon)
|
||||||
{
|
{
|
||||||
var j = polygon.Length - 1;
|
var j = polygon.Length - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user