public override double GetMaxPlaneZ(Pnt point) { double zPlane = Plane.GetZ(point.X, point.Y) + MaxOffset * Math.Abs(UnitNormal[2]); return(zPlane); }
/// <summary> /// Initializes a new instance of the <see cref="Box"/> class. /// </summary> /// <param name="min">The minimum point.</param> /// <param name="max">The maximum point.</param> public Box([NotNull] Pnt min, [NotNull] Pnt max) { Dimension = min.Dimension; Min = min; Max = max; }
private static void GetClosePart([NotNull] SegmentProxy neighbor, [NotNull] IPnt near, double searchDistanceSquared, bool is3D, out double min, out double max) { IList <double[]> limits; Pnt p = Pnt.Create(near); bool cut = SegmentUtils.CutCurveCircle(neighbor, p, searchDistanceSquared, is3D, out limits); if (cut == false || limits.Count == 0) { min = SegmentUtils.GetClosestPointFraction(neighbor, p, is3D); max = min; } else { min = double.MaxValue; max = double.MinValue; foreach (double[] limit in limits) { foreach (double d in limit) { min = Math.Min(d, min); max = Math.Max(d, max); } } } min = Math.Max(min, 0); max = Math.Max(max, 0); min = Math.Min(min, 1); max = Math.Min(max, 1); }
private int Check([NotNull] PlaneHelper planeHelper, [NotNull] Pnt point, double xyTolerance, OffsetMethod checkMethod, [NotNull] IFeature feature, [NotNull] IFeature related) { if (IsCoincident(planeHelper, point, xyTolerance)) { return(NoError); } switch (checkMethod) { case OffsetMethod.Vertical: return(CheckNonCoincidentVertical(planeHelper, point, feature, related)); case OffsetMethod.Perpendicular: throw new NotImplementedException( "Perpendicular not yet implemented"); default: throw new ArgumentOutOfRangeException( nameof(checkMethod), checkMethod, @"Unknown check method"); } }
public SegmentProximity([NotNull] Pnt point, bool as3D, [NotNull] SegmentProxy segmentProxy) : base(point, as3D) { _segmentProxy = segmentProxy; }
private int CheckCoincidence([NotNull] IFeature feature, [NotNull] Pnt point, [NotNull] ISpatialReference spatialReference, double xyTolerance, [NotNull] NearFeatureCoincidence nearFeatureCoincidence) { double pointTolerance = _pointTolerance < 0 ? xyTolerance : _pointTolerance; double edgeTolerance = _edgeTolerance < 0 ? xyTolerance : _edgeTolerance; if (feature == nearFeatureCoincidence.Feature) { // same feature if (!VerifyWithinFeature) { return(_noError); } return(CheckCoincidenceSameFeature(point, feature, GetProximities(point, nearFeatureCoincidence), pointTolerance, edgeTolerance, spatialReference)); } return(CheckCoincidenceDifferentFeatures(point, feature, nearFeatureCoincidence.Feature, GetProximities(point, nearFeatureCoincidence), pointTolerance, edgeTolerance, spatialReference)); }
public PointProximity([NotNull] Pnt point, bool as3D, [NotNull] Pnt proximityPoint) : base(point, as3D) { _proximityPoint = proximityPoint; }
public PointFeaturePointEnumerator([NotNull] IFeature feature) : base(feature) { var point = (IPoint)feature.Shape; _point = QaGeometryUtils.CreatePoint3D(point); }
public static Pnt2D CutDirDir([NotNull] Pnt s0, [NotNull] Pnt dir0, [NotNull] Pnt s1, [NotNull] Pnt dir1, out double f) /* * (x1) (a1) (x2) (a2) (x) * ( ) + t*( ) = ( ) + v*( ) ==> ( ) * (y1) (b1) (y2) (b2) (y) * * return : Point2D : lines cut each other at Point (non parallel) * null : lines are parallel * t = square of distance between the parallels */ { Pnt p = s1 - s0; double det = dir0.VectorProduct(dir1); if (Math.Abs(det) > _epsi * (Math.Abs(s0.X) + Math.Abs(s1.X) + Math.Abs(s0.Y) + Math.Abs(s1.Y)) / 1000.0) { f = p.VectorProduct(dir1) / det; return((Pnt2D)(s0 + f * dir0)); } // parallel lines det = dir0.VectorProduct(p); f = (det * det) / dir0.OrigDist2(2); return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Box"/> class. /// </summary> /// <param name="p0">The first point.</param> /// <param name="p1">The second point.</param> /// <param name="verify">if set to <c>true</c> the minimum and maximum point /// are determined based on the point coordinates.</param> public Box([NotNull] Pnt p0, [NotNull] Pnt p1, bool verify) { Dimension = p0.Dimension < p1.Dimension ? p0.Dimension : p1.Dimension; if (verify) { for (var i = 0; i < Dimension; i++) { if (p0[i] <= p1[i]) { continue; } // swap the coordinate values for this dimension double t = p1[i]; p1[i] = p0[i]; p0[i] = t; } } Min = p0; Max = p1; }
private bool IsConnected([NotNull] IIndexedSegments geometry, [NotNull] IBox pntsearchBox, [NotNull] Pnt center, double toleranceSquare, out int connectedPart, out int connectedFraction) { foreach (SegmentProxy segment in geometry.GetSegments(pntsearchBox)) { foreach (bool atStart in GetConnectedCandidateAtStarts(geometry, segment)) { Pnt endPnt = atStart ? segment.GetStart(false) : segment.GetEnd(false); double dx = endPnt.X - center.X; double dy = endPnt.Y - center.Y; double dist2 = dx * dx + dy * dy; if (dist2 < toleranceSquare) { connectedPart = segment.PartIndex; connectedFraction = atStart ? segment.SegmentIndex : segment.SegmentIndex + 1; return(true); } } } connectedPart = -1; connectedFraction = -1; return(false); }
protected override bool VerifyContinue(SegmentProxy seg0, SegmentProxy seg1, SegmentNeighbors processed1, SegmentParts partsOfSeg0, bool coincident) { TryAssignComplete(seg1, processed1, partsOfSeg0); SegmentParts coincidentPartsOfSeg0; var key = new SegmentPart(seg0, 0, 1, true); if (!_coincidentParts.TryGetValue(key, out coincidentPartsOfSeg0)) { coincidentPartsOfSeg0 = new SegmentParts(); _coincidentParts.Add(key, coincidentPartsOfSeg0); } if (coincident) { partsOfSeg0.IsComplete = true; coincidentPartsOfSeg0.Add(key); return(false); } //return true; IBox seg0Box = seg0.Extent; seg0Box = new Box(Pnt.Create(seg0Box.Min), Pnt.Create(seg0Box.Max)); if (_coincidenceTolerance > 0) { seg0Box.Min.X -= _coincidenceTolerance; seg0Box.Min.Y -= _coincidenceTolerance; seg0Box.Max.X += _coincidenceTolerance; seg0Box.Max.Y += _coincidenceTolerance; } if (!seg0Box.Intersects(seg1.Extent)) { return(true); } var cap = new RoundCap(); NearSegment hullStart; NearSegment hullEnd; bool isCoincident; IList <double[]> limits = FindNeighborhood( new SegmentHull(seg0, 0, cap, cap), new SegmentHull(seg1, _coincidenceTolerance, cap, cap), _is3D, 0, out hullStart, out hullEnd, out isCoincident); IList <SegmentPart> addParts = GetSegmentParts(seg0, seg1, limits, isCoincident); coincidentPartsOfSeg0.AddRange(addParts); bool isComplete = SegmentPart.VerifyComplete(coincidentPartsOfSeg0); partsOfSeg0.IsComplete = isComplete; return(!isComplete); }
private static Pnt CreatePoint(double x, double y) { Pnt p = Pnt.Create(2); p.X = x; p.Y = y; return(p); }
public override bool IsInFootprint(Pnt point) { _query.Value.PutCoords(point.X, point.Y); bool disjoint = ((IRelationalOperator)Footprint).Disjoint(_query.Value); return(!disjoint); }
private IEnumerable <Proximity> GetProximities( [NotNull] Pnt point, [NotNull] NearFeatureCoincidence nearFeatureCoincidence) { IBox searchBox = CreateSearchBox(point); return(nearFeatureCoincidence.GetProximities(point, Is3D, searchBox)); }
public override IEnumerable <Proximity> GetProximities(Pnt point, bool as3D, IBox box) { if (box.Contains((IPnt)_point)) { yield return(new PointProximity(point, as3D, _point)); } }
public override Pnt GetNearestVertex() { double fraction = Fraction; Pnt vertex = fraction < 0.5 ? _segmentProxy.GetStart(as3D: true) : _segmentProxy.GetEnd(as3D: true); return(vertex); }
public override IEnumerable <Pnt> GetPoints(IBox searchBox) { foreach (WKSPointZ wksPoint in _wksPoints) { Pnt point = QaGeometryUtils.CreatePoint3D(wksPoint); if (searchBox.Contains((IPnt)point)) { yield return(point); } } }
public Pnt3D GetPointAlong(double distance, bool asRatio) { if (!asRatio) { distance = distance / DirectionVector.Length; } Pnt result = StartPoint + distance * DirectionVector; return(new Pnt3D(result[0], result[1], result[2])); }
public static Pnt operator +(Pnt p0, IPnt p1) { int iDim = Math.Min(p0.Dimension, p1.Dimension); Pnt pSum = Create(iDim); for (var i = 0; i < iDim; i++) { pSum[i] = p0[i] + p1[i]; } return(pSum); }
public static Pnt operator -(Pnt p0, IPnt p1) { int iDim = Math.Min(p0.Dimension, p1.Dimension); Pnt pDiff = Create(iDim); for (var i = 0; i < iDim; i++) { pDiff[i] = p0[i] - p1[i]; } return(pDiff); }
/// <summary> /// linear product /// </summary> public static Pnt operator *(double f, Pnt p) { int iDim = p.Dimension; Pnt pSkalar = Create(iDim); for (var i = 0; i < iDim; i++) { pSkalar[i] = f * p[i]; } return(pSkalar); }
private static double GetDistanceToVertices([NotNull] IPoint point, [NotNull] IFeature neighbourFeature, [NotNull] IPoint nearestPoint, double maxNeededDistance) { double minDistance2 = double.MaxValue; SegmentProxy nearestSegment = null; var isEndNearest = false; Pnt qaPoint = QaGeometryUtils.CreatePoint3D(point); IEnumerable <SegmentProxy> segments = EnumSegments(qaPoint, neighbourFeature, maxNeededDistance); foreach (SegmentProxy segment in segments) { if (GetNearest(qaPoint, segment.GetStart(false), ref minDistance2)) { nearestSegment = segment; isEndNearest = false; } if (GetNearest(qaPoint, segment.GetEnd(false), ref minDistance2)) { nearestSegment = segment; isEndNearest = true; } } double minDistance; if (nearestSegment != null) { minDistance = Math.Sqrt(minDistance2); if (minDistance <= maxNeededDistance) { Pnt nearest = !isEndNearest ? nearestSegment.GetStart(true) : nearestSegment.GetEnd(true); nearestPoint.PutCoords(nearest.X, nearest.Y); nearestPoint.Z = nearest[2]; } } else { minDistance = double.MaxValue; } return(minDistance); }
public static Pnt Create([NotNull] IPnt point) { int dimension = point.Dimension; Pnt p = Create(dimension); for (var i = 0; i < dimension; i++) { p[i] = point[i]; } return(p); }
public override double GetMinPlaneZ(Pnt point) { // TODO hack to avoid exception if (MathUtils.AreEqual(0, Plane.C)) { return(double.NaN); } double zPlane = Plane.GetZ(point.X, point.Y) - MinOffset * Math.Abs(UnitNormal[2]); return(zPlane); }
public static bool Equals2D([NotNull] Pnt p0, [NotNull] Pnt p1, double tolerance) { return(MathUtils.IsWithinTolerance(Math.Abs(p0.X - p1.X), tolerance, MathUtils.GetDoubleSignificanceEpsilon( p0.X, p1.X)) && MathUtils.IsWithinTolerance(Math.Abs(p0.Y - p1.Y), tolerance, MathUtils.GetDoubleSignificanceEpsilon( p0.Y, p1.Y))); }
public override IEnumerable <Proximity> GetProximities(Pnt point, bool as3D, IBox box) { foreach (WKSPointZ wksPoint in _wksPoints) { Pnt part = QaGeometryUtils.CreatePoint3D(wksPoint); if (box.Contains((IPnt)part)) { yield return(new PointProximity(point, as3D, part)); } } }
public override IEnumerable <Proximity> GetProximities(Pnt point, bool as3D, IBox box) { foreach (SegmentProxy segmentProxy in _indexedSegments.GetSegments(box)) { if (!segmentProxy.Extent.Intersects(box)) { continue; } yield return(new SegmentProximity(point, as3D, segmentProxy)); } }
private static bool GetNearest([NotNull] Pnt point, [NotNull] Pnt nearPoint, ref double minDistance2) { double distance2 = point.Dist2(nearPoint); if (distance2 >= minDistance2) { return(false); } minDistance2 = distance2; return(true); }
public double GetPointDistance([NotNull] IPnt vertex) { Pnt difference = Point - vertex; double distance2D; if (MathUtils.AreSignificantDigitsEqual(Point.X, vertex.X)) { distance2D = MathUtils.AreSignificantDigitsEqual(Point.Y, vertex.Y) ? 0 : Math.Abs(difference.Y); } else if (MathUtils.AreSignificantDigitsEqual(Point.Y, vertex.Y)) { distance2D = MathUtils.AreSignificantDigitsEqual(Point.X, vertex.X) ? 0 : Math.Abs(difference.X); } else { // both differences are significant double distanceSquared = difference.X * difference.X + difference.Y * difference.Y; if (As3D) { if (!MathUtils.AreSignificantDigitsEqual(Point[2], vertex[2])) { distanceSquared += difference[2] * difference[2]; } } return(Math.Sqrt(distanceSquared)); } if (As3D) { double distanceSquared = distance2D * distance2D; if (!MathUtils.AreSignificantDigitsEqual(Point[2], vertex[2])) { distanceSquared += difference[2] * difference[2]; } return(Math.Sqrt(distanceSquared)); } return(distance2D); }