当前位置: 首页>>代码示例>>C#>>正文


C# Coordinate.Distance方法代码示例

本文整理汇总了C#中System.Coordinate.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.Distance方法的具体用法?C# Coordinate.Distance怎么用?C# Coordinate.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Coordinate的用法示例。


在下文中一共展示了Coordinate.Distance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

 ///<summary>
 /// Initializes the points.
 ///</summary>
 /// <param name="p0">1st coordinate</param>
 /// <param name="p1">2nd coordinate</param>
 public void Initialize(Coordinate p0, Coordinate p1)
 {
     _pt[0].CoordinateValue = p0;
     _pt[1].CoordinateValue = p1;
     _distance = p0.Distance(p1);
     _isNull = false;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:12,代码来源:PointPairDistance.cs

示例2: IsInCircleCC

 /// <summary>
 /// Computes the inCircle test using distance from the circumcentre. 
 /// Uses standard double-precision arithmetic.
 /// </summary>
 /// <remarks>
 /// In general this doesn't
 /// appear to be any more robust than the standard calculation. However, there
 /// is at least one case where the test point is far enough from the
 /// circumcircle that this test gives the correct answer. 
 /// <pre>
 /// LINESTRING (1507029.9878 518325.7547, 1507022.1120341457 518332.8225183258,
 /// 1507029.9833 518325.7458, 1507029.9896965567 518325.744909031)
 /// </pre>
 /// </remarks>
 /// <param name="a">A vertex of the triangle</param>
 /// <param name="b">A vertex of the triangle</param>
 /// <param name="c">A vertex of the triangle</param>
 /// <param name="p">The point to test</param>
 /// <returns>The area of a triangle defined by the points a, b and c</returns>
 public static bool IsInCircleCC(Coordinate a, Coordinate b, Coordinate c,
     Coordinate p)
 {
     Coordinate cc = Triangle.Circumcentre(a, b, c);
     double ccRadius = a.Distance(cc);
     double pRadiusDiff = p.Distance(cc) - ccRadius;
     return pRadiusDiff <= 0;
 }
开发者ID:leoliusg,项目名称:NetTopologySuite,代码行数:27,代码来源:TrianglePredicate.cs

示例3: Add

 /// <summary>
 /// 
 /// </summary>
 /// <param name="point"></param>
 private void Add(Coordinate point)
 {
     double dist = point.Distance(_centroid);
     if (dist < _minDistance)
     {
         _interiorPoint = new Coordinate(point);
         _minDistance = dist;
     }
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:13,代码来源:InteriorPointPoint.cs

示例4: checkWithinCircle

 private void checkWithinCircle(Coordinate[] pts, Coordinate centre, double radius, double tolerance)
 {
     for (int i = 0; i < pts.Length; i++)
     {
         Coordinate p = pts[i];
         double ptRadius = centre.Distance(p);
         double error = ptRadius - radius;
         Assert.LessOrEqual(error, tolerance);
     }
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:10,代码来源:MinimumBoundingCircleStressTest.cs

示例5: IsRedundant

 /// <summary>
 /// Tests whether the given point is redundant
 /// relative to the previous
 /// point in the list (up to tolerance).
 /// </summary>
 /// <param name="pt"></param>
 /// <returns>true if the point is redundant</returns>
 private bool IsRedundant(Coordinate pt)
 {
     if (_ptList.Count < 1)
         return false;
     var lastPt = _ptList[_ptList.Count - 1];
     double ptDist = pt.Distance(lastPt);
     if (ptDist < _minimimVertexDistance)
         return true;
     return false;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:17,代码来源:OffsetSegmentString.cs

示例6: IsDuplicate

 ///<summary>
 /// Tests whether the given point duplicates the previous point in the list (up to tolerance)
 ///</summary>
 /// <param name="pt">The point to test</param>
 /// <returns>true if the point duplicates the previous point</returns>
 private bool IsDuplicate(Coordinate pt)
 {
     if (_ptList.Count < 1)
         return false;
     var lastPt = _ptList[_ptList.Count - 1];
     var ptDist = pt.Distance(lastPt);
     if (ptDist < _minimimVertexDistance)
         return true;
     return false;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:15,代码来源:OffsetCurveVertexList.cs

示例7: Distance

        public static double Distance(Coordinate p0, Coordinate p1)
        {
            // default to 2D distance if either Z is not set
            if (Double.IsNaN(p0.Z) || Double.IsNaN(p1.Z))
                return p0.Distance(p1);

            var dx = p0.X - p1.X;
            var dy = p0.Y - p1.Y;
            var dz = p0.Z - p1.Z;
            return Math.Sqrt(dx * dx + dy * dy + dz * dz);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:CGAlgorithms3D.cs

示例8: SetMaximum

 public void SetMaximum(Coordinate p0, Coordinate p1)
 {
     if (_isNull)
     {
         Initialize(p0, p1);
         return;
     }
     double dist = p0.Distance(p1);
     if (dist > _distance)
         Initialize(p0, p1, dist);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:PointPairDistance.cs

示例9: Densify

        private void Densify(Coordinate p0, Coordinate p1, double segLength)
        {
            double origLen = p1.Distance(p0);
            int nPtsToAdd = (int)Math.Floor(origLen / segLength);

            double delx = p1.X - p0.X;
            double dely = p1.Y - p0.Y;

            double segLenFrac = segLength / origLen;
            for (int i = 0; i <= nPtsToAdd; i++)
            {
                double addedPtFrac = i * segLenFrac;
                Coordinate pt = new Coordinate(p0.X + addedPtFrac * delx,
                                                p0.Y + addedPtFrac * dely);
                newCoords.Add(pt, false);
            }
            newCoords.Add(new Coordinate(p1), false);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:18,代码来源:SegmentDensifier.cs

示例10: CreateFromControlVectors

        /// <summary>
        /// Creates an AffineTransformation defined by a pair of control vectors. A
        /// control vector consists of a source point and a destination point, which is
        /// the image of the source point under the desired transformation. The
        /// computed transformation is a combination of one or more of a uniform scale,
        /// a rotation, and a translation (i.e. there is no shear component and no
        /// reflection)
        /// </summary>
        /// <param name="src0"></param>
        /// <param name="src1"></param>
        /// <param name="dest0"></param>
        /// <param name="dest1"></param>
        /// <returns>The computed transformation</returns>
        /// <returns><c>null</c> if the control vectors do not determine a well-defined transformation</returns>
        public static AffineTransformation CreateFromControlVectors(Coordinate src0,
                Coordinate src1, Coordinate dest0, Coordinate dest1)
        {
            Coordinate rotPt = new Coordinate(dest1.X - dest0.X, dest1.Y - dest0.Y);

            double ang = AngleUtility.AngleBetweenOriented(src1, src0, rotPt);

            double srcDist = src1.Distance(src0);
            double destDist = dest1.Distance(dest0);

            if (srcDist == 0.0)
                return null;

            double scale = destDist / srcDist;

            AffineTransformation trans = AffineTransformation.TranslationInstance(
                    -src0.X, -src0.Y);
            trans.Rotate(ang);
            trans.Scale(scale, scale);
            trans.Translate(dest0.X, dest0.Y);
            return trans;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:36,代码来源:AffineTransformationFactory.cs

示例11: ClosestPoints

        /// <summary>
        /// Computes the closest points on a line segment.
        /// </summary>
        /// <param name="line"></param>
        /// <returns>
        /// A pair of Coordinates which are the closest points on the line segments.
        /// </returns>
        public virtual Coordinate[] ClosestPoints(ILineSegmentBase line)
        {
            LineSegment myLine = new LineSegment(line);

            // test for intersection
            Coordinate intPt = Intersection(line);

            if (intPt != null)
                return new[] { intPt, intPt };

            /*
            *  if no intersection closest pair contains at least one endpoint.
            * Test each endpoint in turn.
            */
            Coordinate[] closestPt = new Coordinate[2];

            Coordinate close00 = new Coordinate(ClosestPoint(line.P0));
            double minDistance = close00.Distance(line.P0);
            closestPt[0] = close00;
            closestPt[1] = new Coordinate(line.P0);

            Coordinate close01 = new Coordinate(ClosestPoint(line.P1));
            double dist = close01.Distance(line.P1);
            if (dist < minDistance)
            {
                minDistance = dist;
                closestPt[0] = close01;
                closestPt[1] = new Coordinate(line.P1);
            }

            Coordinate close10 = new Coordinate(myLine.ClosestPoint(P0));
            dist = close10.Distance(P0);
            if (dist < minDistance)
            {
                minDistance = dist;
                closestPt[0] = new Coordinate(P0);
                closestPt[1] = close10;
            }

            Coordinate close11 = new Coordinate(myLine.ClosestPoint(P1));
            dist = close11.Distance(P1);
            if (dist < minDistance)
            {
                closestPt[0] = new Coordinate(P1);
                closestPt[1] = close11;
            }

            return closestPt;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:56,代码来源:LineSegment.cs

示例12: DistancePointLine

        /// <summary> 
        /// Computes the distance from a point p to a line segment AB.
        /// Note: NON-ROBUST!
        /// </summary>
        /// <param name="p">The point to compute the distance for.</param>
        /// <param name="A">One point of the line.</param>
        /// <param name="B">Another point of the line (must be different to A).</param>
        /// <returns> The distance from p to line segment AB.</returns>
        public static double DistancePointLine(Coordinate p, Coordinate A, Coordinate B)
        {
            // if start = end, then just compute distance to one of the endpoints
            if (A.X == B.X && A.Y == B.Y) 
                return p.Distance(A);

            // otherwise use comp.graphics.algorithms Frequently Asked Questions method
            /*(1)     	      AC dot AB
                        r =   ---------
                              ||AB||^2
             
		                r has the following meaning:
		                r=0 Point = A
		                r=1 Point = B
		                r<0 Point is on the backward extension of AB
		                r>1 Point is on the forward extension of AB
		                0<r<1 Point is interior to AB
	        */

            var len2 = ((B.X - A.X)*(B.X - A.X) + (B.Y - A.Y)*(B.Y - A.Y));
            var r = ((p.X - A.X)*(B.X - A.X) + (p.Y - A.Y)*(B.Y - A.Y))/len2;

            if (r <= 0.0) 
                return p.Distance(A);
            if (r >= 1.0) 
                return p.Distance(B);


            /*(2)
		                    (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
		                s = -----------------------------
		             	                Curve^2

		                Then the distance from C to Point = |s|*Curve.
      
                        This is the same calculation as {@link #distancePointLinePerpendicular}.
                        Unrolled here for performance.
	        */

            var s = ((A.Y - p.Y)*(B.X - A.X) - (A.X - p.X)*(B.Y - A.Y))/len2;

            return Math.Abs(s) * Math.Sqrt(len2);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:51,代码来源:CGAlgorithms.cs

示例13: Equal

        /// <summary>
        ///
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        protected virtual bool Equal(Coordinate a, Coordinate b, double tolerance)
        {
            if (tolerance == 0)
                return a.Equals(b);

            return a.Distance(b) <= tolerance;
        }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:14,代码来源:Geometry.cs

示例14: Equals

 public bool Equals(Coordinate p0, Coordinate p1, double distanceTolerance)
 {
     return p0.Distance(p1) <= distanceTolerance;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:4,代码来源:RobustLineIntersectionTest.cs

示例15: CheckRobustInCircle

        /// <summary>
        /// Checks if the computed value for isInCircle is correct, using
        /// double-double precision arithmetic.
        /// </summary>
        /// <param name="a">A vertex of the triangle</param>
        /// <param name="b">A vertex of the triangle</param>
        /// <param name="c">A vertex of the triangle</param>
        /// <param name="p">The point to test</param>
        private static void CheckRobustInCircle(Coordinate a, Coordinate b, Coordinate c,
            Coordinate p)
        {
            bool nonRobustInCircle = IsInCircleNonRobust(a, b, c, p);
            bool isInCircleDD = IsInCircleDDSlow(a, b, c, p);
            bool isInCircleCC = IsInCircleCC(a, b, c, p);

            Coordinate circumCentre = Triangle.Circumcentre(a, b, c);
            #if !PCL
            // ReSharper disable RedundantStringFormatCall
            // String.Format needed to build 2.0 release!
            Debug.WriteLine(String.Format("p radius diff a = {0}", Math.Abs(p.Distance(circumCentre) - a.Distance(circumCentre))/a.Distance(circumCentre)));
            if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC)
            {
                Debug.WriteLine(String.Format("inCircle robustness failure (double result = {0}, DD result = {1}, CC result = {2})", nonRobustInCircle, isInCircleDD, isInCircleCC));
                Debug.WriteLine(WKTWriter.ToLineString(new CoordinateArraySequence(new[] { a, b, c, p })));
                Debug.WriteLine(String.Format("Circumcentre = {0} radius = {1}", WKTWriter.ToPoint(circumCentre), a.Distance(circumCentre)));
                Debug.WriteLine(String.Format("p radius diff a = {0}", Math.Abs(p.Distance(circumCentre)/a.Distance(circumCentre) - 1)));
                Debug.WriteLine(String.Format("p radius diff b = {0}", Math.Abs(p.Distance(circumCentre)/b.Distance(circumCentre) - 1)));
                Debug.WriteLine(String.Format("p radius diff c = {0}", Math.Abs(p.Distance(circumCentre)/c.Distance(circumCentre) - 1)));
                Debug.WriteLine("");
            }
            // ReSharper restore RedundantStringFormatCall
            #endif
        }
开发者ID:leoliusg,项目名称:NetTopologySuite,代码行数:33,代码来源:TrianglePredicate.cs


注:本文中的System.Coordinate.Distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。