public double GetMinEpsilon(TPoint2D shortcutEnd, bool doExtremePointQueries) { double[] distances; if (doExtremePointQueries) { //O(4log n) distances = new [] { Geometry2D.Distance(shortcutStart, shortcutEnd, upper.ExtremePointFromShortcutLine(shortcutEnd)), Geometry2D.Distance(shortcutStart, shortcutEnd, lower.ExtremePointFromShortcutLine(shortcutEnd)), upper.ExtremeDistanceLeftOfShortcut(shortcutEnd), lower.ExtremeDistanceLeftOfShortcut(shortcutEnd) }; } else { //O(2log n) distances = new [] { upper.ExtremeDistanceLeftOfShortcut(shortcutEnd), lower.ExtremeDistanceLeftOfShortcut(shortcutEnd) }; } return(distances.Max()); }
public static double GetMinEpsilon(Trajectory2D trajectory, int start, int end) { var maxDistance = 0.0; for (var k = start + 1; k < end; k++) { var point = trajectory[k]; maxDistance = Math.Max(maxDistance, Geometry2D.Distance(trajectory[start], trajectory[end], point)); } return(maxDistance); }
public static int GetSplit(Trajectory2D trajectory, int start, int end, out double maxDistance) { maxDistance = 0.0; var split = -1; var startPoint = trajectory[start]; var endPoint = trajectory[end]; for (var k = start + 1; k < end; k++) { var point = trajectory[k]; var dist = Geometry2D.Distance(startPoint, endPoint, point); if (dist > maxDistance) { maxDistance = dist; split = k; } } return(split); }
public void Intersect(TPoint2D shortcutEnd, double epsilon) { //angle between shortcut line and epsilon circles var distance = Geometry2D.Distance(Origin, shortcutEnd); //if within epsilon circle, keep wedge and continue with next if (distance <= epsilon) { return; } //get angle of shortcut line with respect to the unit circle var worldAngle = Geometry2D.Angle(Origin, shortcutEnd); var wedgeAngle = Math.Asin(epsilon / distance); //build wedge var wedgeStart = Geometry2D.SubtractRadians(worldAngle, wedgeAngle); var wedgeEnd = Geometry2D.SumRadians(worldAngle, wedgeAngle); var newWedge = new Wedge(Origin, wedgeStart, wedgeEnd); //intersect wedge Intersect(newWedge); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Creates a circle event. </summary> /// <remarks>Circle events are created at the circumcenters of three sites - the sites for poly1/2/3.</remarks> /// <param name="poly1"> The first polygon. </param> /// <param name="poly2"> The second polygon. </param> /// <param name="poly3"> The third polygon. </param> /// <param name="yScanLine"> The y coordinate scan line. </param> /// <returns> A new circle event. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// internal static CircleEvent CreateCircleEvent(FortunePoly poly1, FortunePoly poly2, FortunePoly poly3, double yScanLine) { // Locals CircleEvent cevtRet = null; // Determine a circumcenter for the sites of poly1/2/3. if (Geometry2D.FFindCircumcenter(poly1.VoronoiPoint, poly2.VoronoiPoint, poly3.VoronoiPoint, out var ptCenter)) { // Determine y coordinate for the side of the circle // The event will fire when the scan line hits that y position var radius = Geometry2D.Distance(poly1.VoronoiPoint, ptCenter); ptCenter.Y -= radius; // If the circumcenter is above the scan line we've already passed it by, so don't put it in the queue if (ptCenter.Y <= yScanLine) { cevtRet = new CircleEvent(ptCenter, radius); } } return(cevtRet); }
private static EnhancedPoint InitializeEnhancedPoint(TPoint2D p, TPoint2D shortcutStart) { return(new EnhancedPoint(p, Geometry2D.Distance(p, shortcutStart))); }