private Reef CheckReefs(Coordinate closestObjCoord, IInheritanceTreeCollection <Geometry> MapObjects, Coordinate nextCoord) { var reefs = MapObjects.GetAll <Reef>(); var subLine = new LineSegment(Coordinate, nextCoord); foreach (Reef reef in reefs) { var reefLine = new LineSegment(reef.Coordinates[0], reef.Coordinates[1]); Coordinate coordinate = reefLine.Intersection(subLine); if (coordinate != null) { Console.WriteLine($"rX1 = {reefLine.P0.X}; rY1 = {reefLine.P0.Y}"); Console.WriteLine($"rX2 = {reefLine.P1.X}; rY2 = {reefLine.P1.Y}"); Console.WriteLine($"X1 = {coordinate.X}; Y1 = {coordinate.Y}"); Console.WriteLine($"X2 = {nextCoord.X}; Y2 = {nextCoord.Y}"); Console.WriteLine($"interX = {coordinate.X}; interY = {coordinate.Y}"); return(reef); } } return(null); }
private IntrestingObj FindClosestObj(IInheritanceTreeCollection <Geometry> MapObjects) { var objects = MapObjects.GetAll <IntrestingObj>(); IntrestingObj closest = objects[0]; foreach (IntrestingObj obj in objects) { if (obj.Distance(this) < closest.Distance(this)) { closest = obj; } } return(closest); }