public static NewCoordinate ( double values ) : ICoordinate | ||
values | double | An array containing coordinate values |
return | ICoordinate |
private KDTree getCrossPointsIndex(Polyline polyline) { List <MonotoneChain> chains = new List <MonotoneChain>(); foreach (LinePath path in polyline.Paths) { path.AppendMonotoneChains(chains); } List <SDMinCrossPoint> crossPoints = new List <SDMinCrossPoint>(); for (int i = 0; i < chains.Count - 1; i++) { for (int j = i + 1; j < chains.Count; j++) { if (chains[i].BoundsIntersect(chains[j])) { List <ICoordinate> points = chains[i].GetCrossPoints(chains[j]); foreach (ICoordinate p in points) { bool isChainIBoundsPoint = p.ExactEquals(chains[i].FirstPoint) || p.ExactEquals(chains[i].LastPoint); bool isChainJBoundsPoint = p.ExactEquals(chains[j].FirstPoint) || p.ExactEquals(chains[j].LastPoint); if (!(isChainIBoundsPoint && isChainJBoundsPoint)) { SDMinCrossPoint cp = new SDMinCrossPoint(); cp.Point = p; cp.BoundingRectangle = new PointD(p).GetBoundingRectangle(); cp.BoundingRectangle.Grow(PlanimetryAlgorithms.Tolerance); crossPoints.Add(cp); } } } } } BoundingRectangle br = new BoundingRectangle(); foreach (SDMinCrossPoint p in crossPoints) { br.Join(p.BoundingRectangle); } KDTree result = new KDTree(br); result.MaxDepth = 10; result.MinObjectCount = 10; if (br.IsEmpty()) { br.Join(PlanimetryEnvironment.NewCoordinate(0, 0)); } result.BoxSquareThreshold = br.Width * br.Height / 10000; result.Build(crossPoints); return(result); }
private static ICoordinate[] getArcPoints(ICoordinate point, double startAngle, double endAngle, double distance, int pointsPerCircle) { int n = (int)Math.Round(pointsPerCircle * (endAngle - startAngle) / _twoPi); ICoordinate[] result = new ICoordinate[n + 1]; double angle = startAngle; double da = _twoPi / pointsPerCircle; for (int i = 0; i < n; i++) { result[i] = PlanimetryEnvironment.NewCoordinate(point.X + distance * Math.Cos(angle), point.Y + distance * Math.Sin(angle)); angle += da; } result[n] = PlanimetryEnvironment.NewCoordinate(point.X + distance * Math.Cos(endAngle), point.Y + distance * Math.Sin(endAngle)); return(result); }
private static Polygon getCoordinateBuffer(ICoordinate point, double distance, int pointsPerCircle) { if (distance < 0) { return(new Polygon()); } double angle = 0; double da = _twoPi / pointsPerCircle; ICoordinate[] vertices = new ICoordinate[pointsPerCircle]; for (int i = 0; i < pointsPerCircle; i++) { vertices[i] = PlanimetryEnvironment.NewCoordinate(point.X + distance * Math.Cos(angle), point.Y + distance * Math.Sin(angle)); angle += da; } return(new Polygon(vertices)); }