public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit) { PointF p = cs.Convert(point); DrawPoint(p); Pen penDot = (Pen)pen.Clone(); penDot.DashStyle = DashStyle.Dot; double pi2 = 2 * Geometry.HalfAngle(unit); // draw points on the west double x_tmp = point[0] - pi2; while (x_tmp >= box.Min[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, penDot); x_tmp -= pi2; } // draw points on the east x_tmp = point[0] + pi2; while (x_tmp <= box.Max[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, penDot); x_tmp += pi2; } }
public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit, bool drawDots) { PointF p = cs.Convert(point); DrawPoint(p); double pi2 = 2 * Geometry.HalfAngle(unit); Pen pen = drawDots ? this.penDot : this.pen; // draw points on the west double x_tmp = point[0] - pi2; while (x_tmp >= box.Min[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, pen); x_tmp -= pi2; } // draw points on the east x_tmp = point[0] + pi2; while (x_tmp <= box.Max[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, pen); x_tmp += pi2; } }
public Turn(Geometry.Point p, char m, char o0, char o1) { point = p; method = m; operation0 = o0; operation1 = o1; }
public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope) { Geometry.Point p_min = new Geometry.Point(Center[0] - Radius, Center[1] - Radius); Geometry.Point p_max = new Geometry.Point(Center[0] + Radius, Center[1] + Radius); return(calculateEnvelope ? Geometry.Envelope(p_min, p_max, traits) : Geometry.Aabb(p_min, p_max, traits.Unit)); }
private static void DrawPoint(Geometry.Point point, Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits) { LocalCS cs = new LocalCS(box, graphics); Drawer drawer = new Drawer(graphics, settings.color); if (traits.Unit == Geometry.Unit.None) { PointF p = cs.Convert(point); drawer.DrawPoint(p); } else // Radian, Degree { drawer.DrawPeriodicPoint(cs, point, box, traits.Unit, settings.showDots); } }
private static PointF[] DensifyAndConvert(LocalCS cs, Geometry.Point p0, Geometry.Point p1, double length, Geometry.Unit unit) { double distNorm = Geometry.NormalizedAngleSigned(p1[0] - p0[0], unit); bool intersPole = IsAntipodal(distNorm, unit); double halfPi = Geometry.HalfAngle(unit) / 2; double poleLat = p1[1] - p0[1] >= 0 ? halfPi : -halfPi; int intersPoleIndex = -1; Geometry.Point[] densPoints = Geometry.SphericalDensify(p0, p1, length, unit); PointF[] result = new PointF[densPoints.Length + (intersPole ? 2 : 0)]; int k = 0; for (int j = 0; j < densPoints.Length; ++j, ++k) { double densDistNorm = Geometry.NormalizedAngleSigned(densPoints[j][0] - p0[0], unit); densPoints[j][0] = p0[0] + densDistNorm; if (intersPole && intersPoleIndex == -1 && Math.Abs(densDistNorm) > halfPi) { intersPoleIndex = j; Geometry.Point p = j == 0 ? p0 : densPoints[j - 1]; float poleF = cs.ConvertY(poleLat); result[k++] = new PointF(cs.ConvertX(p[0]), poleF); result[k++] = new PointF(cs.ConvertX(densPoints[j][0]), poleF); } result[k] = cs.Convert(densPoints[j]); } // last segment if (intersPole && intersPoleIndex == -1) { int j = densPoints.Length; intersPoleIndex = j; float poleF = cs.ConvertY(poleLat); result[j] = new PointF(cs.ConvertX(densPoints[j - 1][0]), poleF); result[j + 1] = new PointF(cs.ConvertX(p1[0]), poleF); } return(result); }
public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit, bool drawDots) { PointF p = cs.Convert(point); DrawPoint(p); double twoPi = Geometry.FullAngle(unit); Pen pen = drawDots ? this.penDot : this.pen; // NOTE: Use AssignChanged becasue for big coordinates subtracting/adding // twoPi doesn't change the value of x_tmp which causes infinite loop float x = Math.Min(Math.Max(p.X, 0.0f), cs.Width); double nPeriodsWest = (point[0] - box.Min[0]) / twoPi; float pixelsWest = x; double nPeriodsEast = (box.Max[0] - point[0]) / twoPi; float pixelsEast = cs.Width - x; if (nPeriodsWest <= pixelsWest / 5) { // draw points on the west double x_tmp = point[0]; while (Util.Assign(ref x_tmp, x_tmp - twoPi) && x_tmp >= box.Min[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, pen); } } if (nPeriodsEast <= pixelsEast / 5) { // draw points on the east double x_tmp = point[0]; while (Util.Assign(ref x_tmp, x_tmp + twoPi) && x_tmp <= box.Max[0]) { p.X = cs.ConvertX(x_tmp); DrawPoint(p, pen); } } }
public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope) { Geometry.Box box = null; for (int i = 0; i < this.Count; ++i) { Geometry.Point p = this[i]; // TODO: in general it's not necessary to create a box here Geometry.Box b = new Geometry.Box(new Geometry.Point(p[0], p[1]), new Geometry.Point(p[0], p[1])); if (box == null) { box = b; } else { if (calculateEnvelope) { Geometry.Expand(box, b, traits); } else { Geometry.Expand(box, b); } } } if (box == null) { Geometry.AssignInverse(box); } return(box); }
public PeriodicDrawableRange(LocalCS cs, Geometry.IRandomAccessRange <Geometry.Point> points, bool closed, Geometry.Unit unit, bool densify) { this.closed = closed; this.containsPole = ContainsPole.No; if (points.Count < 2) { return; } // approx. length of densified segments /*double densLength = Math.Min(cs.InverseConvertDimensionX(20), * cs.InverseConvertDimensionY(20));*/ double densLength = Geometry.FromDegree(5, unit); int count = points.Count + (closed ? 1 : 0); xs_orig = new float[count]; points_rel = new PointF[count]; if (densify) { dens_points_rel = new PointF[points.Count][]; } xs_orig[0] = cs.ConvertX(points[0][0]); points_rel[0] = cs.Convert(points[0]); Geometry.Point p0 = points[0].Clone(); for (int i = 1; i < count; ++i) { Geometry.Point p1 = points[i % points.Count].Clone(); xs_orig[i] = cs.ConvertX(p1[0]); double distNorm = Geometry.NormalizedAngleSigned(p1[0] - p0[0], unit); // [-pi, pi] p1[0] = p0[0] + distNorm; points_rel[i] = cs.Convert(p1); if (dens_points_rel != null) { dens_points_rel[i - 1] = DensifyAndConvert(cs, p0, p1, densLength, unit); } p0 = p1; } if (closed && Math.Abs(points_rel[0].X - points_rel[points.Count].X) > 0.1) { // Check which pole double area = 0; p0 = points[0].Clone(); for (int i = 1; i < count; ++i) { Geometry.Point p1 = points[i % points.Count].Clone(); double distNorm = Geometry.NormalizedAngleSigned(p1[0] - p0[0], unit); // [-pi, pi] p1[0] = p0[0] + distNorm; area += Geometry.SphericalTrapezoidArea(p0, p1, unit); p0 = p1; } int areaSign = Math.Sign(area); int dirSign = Math.Sign(points_rel[points.Count].X - points_rel[0].X); this.containsPole = (areaSign * dirSign >= 0) ? ContainsPole.North : ContainsPole.South; } }
public PointF Convert(Geometry.Point p) { return(new PointF(ConvertX(p[0]), ConvertY(p[1]))); }
public Segment(Geometry.Point first, Geometry.Point second) : base(first, second) { }
public NSphere(Geometry.Point center, double radius) : base(center, radius) { }
public Box(Geometry.Point min, Geometry.Point max) : base(min, max) { }