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


C# ICoordinate.Equals方法代码示例

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


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

示例1: ComputeEdgeDistance

        /// <summary> 
        /// Computes the "edge distance" of an intersection point p along a segment.
        /// The edge distance is a metric of the point along the edge.
        /// The metric used is a robust and easy to compute metric function.
        /// It is not equivalent to the usual Euclidean metric.
        /// It relies on the fact that either the x or the y ordinates of the
        /// points in the edge are unique, depending on whether the edge is longer in
        /// the horizontal or vertical direction.
        /// NOTE: This function may produce incorrect distances
        /// for inputs where p is not precisely on p1-p2
        /// (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces distanct 0.0, which is incorrect.
        /// My hypothesis is that the function is safe to use for points which are the
        /// result of rounding points which lie on the line, but not safe to use for truncated points.
        /// </summary>
        public static double ComputeEdgeDistance(ICoordinate p, ICoordinate p0, ICoordinate p1)
        {
            double dx = Math.Abs(p1.X - p0.X);
            double dy = Math.Abs(p1.Y - p0.Y);

            double dist = -1.0;   // sentinel value
            if (p.Equals(p0)) 
                dist = 0.0;            
            else if (p.Equals(p1)) 
            {
                if (dx > dy)
                     dist = dx;
                else dist = dy;
            }
            else 
            {
                double pdx = Math.Abs(p.X - p0.X);
                double pdy = Math.Abs(p.Y - p0.Y);
                if (dx > dy)
                     dist = pdx;
                else dist = pdy;

                // <FIX>: hack to ensure that non-endpoints always have a non-zero distance
                if (dist == 0.0 && ! p.Equals(p0))                
                    dist = Math.Max(pdx, pdy);
                
            }
            Assert.IsTrue(!(dist == 0.0 && ! p.Equals(p0)), "Bad distance calculation");
            return dist;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:44,代码来源:LineIntersector.cs

示例2: ComputeIntersection

        /// <summary>
        /// 
        /// </summary>
        /// <param name="p"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public override void ComputeIntersection(ICoordinate p, ICoordinate p1, ICoordinate p2) 
        {
            double a1;
            double b1;
            double c1;
            /*
            *  Coefficients of line eqns.
            */

            double r;
            /*
            *  'Sign' values
            */

            isProper = false;

            /*
            *  Compute a1, b1, c1, where line joining points 1 and 2
            *  is "a1 x  +  b1 y  +  c1  =  0".
            */
            a1 = p2.Y - p1.Y;
            b1 = p1.X - p2.X;
            c1 = p2.X * p1.Y - p1.X * p2.Y;

            /*
            *  Compute r3 and r4.
            */
            r = a1 * p.X + b1 * p.Y + c1;

            // if r != 0 the point does not lie on the line
            if (r != 0) 
            {
                result = DontIntersect;
                return;
            }

            // Point lies on line - check to see whether it lies in line segment.

            double dist = RParameter(p1, p2, p);
            if (dist < 0.0 || dist > 1.0)
            {
                result = DontIntersect;
                return;
            }

            isProper = true;
            if (p.Equals(p1) || p.Equals(p2))             
                isProper = false;
            
            result = DoIntersect;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:57,代码来源:NonRobustLineIntersector.cs

示例3: IsInList

 /// <summary>
 /// Tests whether a given point is in an array of points.
 /// Uses a value-based test.
 /// </summary>
 /// <param name="pt">A <c>Coordinate</c> for the test point.</param>
 /// <param name="pts">An array of <c>Coordinate</c>s to test,</param>
 /// <returns><c>true</c> if the point is in the array.</returns>
 public static bool IsInList(ICoordinate pt, ICoordinate[] pts)
 {
     foreach (ICoordinate p in pts)
         if (pt.Equals(p))
             return true;
     return true;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:14,代码来源:EdgeRing.cs

示例4: ComputeIntersection

 /// <summary>
 /// 
 /// </summary>
 /// <param name="p"></param>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 public override void ComputeIntersection(ICoordinate p, ICoordinate p1, ICoordinate p2) 
 {
     isProper = false;
     // do between check first, since it is faster than the orientation test
     if(Envelope.Intersects(p1, p2, p)) 
     {
         if( (CGAlgorithms.OrientationIndex(p1, p2, p) == 0) && 
             (CGAlgorithms.OrientationIndex(p2, p1, p) == 0) ) 
         {
             isProper = true;
             if (p.Equals(p1) || p.Equals(p2)) 
                 isProper = false;                    
             result = DoIntersect;
             return;
         }
     }
     result = DontIntersect;
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:24,代码来源:RobustLineIntersector.cs

示例5: DistanceLineLine

        /// <summary> 
        /// Computes the distance from a line segment AB to a line segment CD.
        /// Note: NON-ROBUST!
        /// </summary>
        /// <param name="A">A point of one line.</param>
        /// <param name="B">The second point of the line (must be different to A).</param>
        /// <param name="C">One point of the line.</param>
        /// <param name="D">Another point of the line (must be different to A).</param>
        /// <returns>The distance from line segment AB to line segment CD.</returns>
        public static double DistanceLineLine(ICoordinate A, ICoordinate B, ICoordinate C, ICoordinate D)
        {
            // check for zero-length segments
            if (A.Equals(B))
                return DistancePointLine(A,C,D);
            if (C.Equals(D))
                return DistancePointLine(D,A,B);

            // AB and CD are line segments
            /* from comp.graphics.algo

                Solving the above for r and s yields
                            (Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy)
                        r = ----------------------------- (eqn 1)
                            (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)

             	                (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
                        s = ----------------------------- (eqn 2)
                            (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
                Let Point be the position vector of the intersection point, then
                    Point=A+r(B-A) or
                    Px=Ax+r(Bx-Ax)
                    Py=Ay+r(By-Ay)
                By examining the values of r & s, you can also determine some other
                limiting conditions:
                    If 0<=r<=1 & 0<=s<=1, intersection exists
                    r<0 or r>1 or s<0 or s>1 line segments do not intersect
                    If the denominator in eqn 1 is zero, AB & CD are parallel
                    If the numerator in eqn 1 is also zero, AB & CD are collinear.

            */
            double r_top = (A.Y - C.Y) * (D.X - C.X) - (A.X - C.X) * (D.Y - C.Y);
            double r_bot = (B.X - A.X) * (D.Y - C.Y) - (B.Y - A.Y) * (D.X - C.X);

            double s_top = (A.Y - C.Y) * (B.X - A.X) - (A.X - C.X) * (B.Y - A.Y);
            double s_bot = (B.X - A.X) * (D.Y - C.Y) - (B.Y - A.Y) * (D.X - C.X);

            if ((r_bot==0) || (s_bot == 0))
                return  Math.Min(DistancePointLine(A,C,D),
                        Math.Min(DistancePointLine(B,C,D),
                        Math.Min(DistancePointLine(C,A,B),
                        DistancePointLine(D,A,B) ) ) );

            double s = s_top/s_bot;
            double r = r_top/r_bot;

            if ((r < 0) || ( r > 1) || (s < 0) || (s > 1))
                //no intersection
                return  Math.Min(DistancePointLine(A,C,D),
                        Math.Min(DistancePointLine(B,C,D),
                        Math.Min(DistancePointLine(C,A,B),
                        DistancePointLine(D,A,B) ) ) );

            return 0.0; //intersection exists
        }
开发者ID:izambakci,项目名称:tf-net,代码行数:64,代码来源:CGAlgorithms.cs

示例6: ComputeCollinearIntersection

        /// <summary>
        /// 
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="q1"></param>
        /// <param name="q2"></param>
        /// <returns></returns>
        private int ComputeCollinearIntersection(ICoordinate p1, ICoordinate p2, ICoordinate q1, ICoordinate q2) 
        {
            bool p1q1p2 = Envelope.Intersects(p1, p2, q1);
            bool p1q2p2 = Envelope.Intersects(p1, p2, q2);
            bool q1p1q2 = Envelope.Intersects(q1, q2, p1);
            bool q1p2q2 = Envelope.Intersects(q1, q2, p2);

            if (p1q1p2 && p1q2p2) 
            {
                intPt[0] = q1;
                intPt[1] = q2;
                return Collinear;
            }
            if (q1p1q2 && q1p2q2) 
            {
                intPt[0] = p1;
                intPt[1] = p2;
                return Collinear;
            }
            if (p1q1p2 && q1p1q2)
            {
                intPt[0] = q1;
                intPt[1] = p1;
                return q1.Equals(p1) && !p1q2p2 && !q1p2q2 ? DoIntersect : Collinear;
            }
            if (p1q1p2 && q1p2q2) 
            {
                intPt[0] = q1;
                intPt[1] = p2;
                return q1.Equals(p2) && !p1q2p2 && !q1p1q2 ? DoIntersect : Collinear;
            }
            if (p1q2p2 && q1p1q2) 
            {
                intPt[0] = q2;
                intPt[1] = p1;
                return q2.Equals(p1) && !p1q1p2 && !q1p2q2 ? DoIntersect : Collinear;
            }
            if (p1q2p2 && q1p2q2) 
            {
                intPt[0] = q2;
                intPt[1] = p2;
                return q2.Equals(p2) && !p1q1p2 && !q1p1q2 ? DoIntersect : Collinear;
            }
            return DontIntersect;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:53,代码来源:RobustLineIntersector.cs

示例7: CheckCollapse

 /// <summary>
 /// 
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 private void CheckCollapse(ICoordinate p0, ICoordinate p1, ICoordinate p2)
 {
     if (p0.Equals(p2))
         throw new Exception("found non-noded collapse at: " + p0 + ", " + p1 + " " + p2);
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:11,代码来源:NodingValidator.cs

示例8: CheckCollapse

 private void CheckCollapse(ICoordinate p0, ICoordinate p1, ICoordinate p2)
 {
     if (p0.Equals(p2))
         throw new ApplicationException(String.Format(
             "found non-noded collapse at: {0}, {1} {2}", p0, p1, p2));
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:6,代码来源:NodingValidator.cs

示例9: 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(ICoordinate p, ICoordinate A, ICoordinate B)
        {
            // if start == end, then use pt distance
            if (A.Equals(B)) 
                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
	        */

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

            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.
	        */

            double s =  ( (A.Y - p.Y) * (B.X - A.X) - (A.X - p.X) * (B.Y - A.Y) )
                        /
                        ( (B.X - A.X) * (B.X - A.X) + (B.Y - A.Y) * (B.Y - A.Y) );

            return Math.Abs(s) * Math.Sqrt(((B.X - A.X) * (B.X - A.X) + (B.Y - A.Y) * (B.Y - A.Y)));
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:49,代码来源:CGAlgorithms.cs

示例10: IsInList

 /// <summary>
 /// Tests whether a given point is in an array of points.
 /// Uses a value-based test.
 /// </summary>
 /// <param name="pt">A <c>Coordinate</c> for the test point.</param>
 /// <param name="pts">An array of <c>Coordinate</c>s to test,</param>
 /// <returns><c>true</c> if the point is in the array.</returns>
 public static bool IsInList(ICoordinate pt, ICoordinate[] pts)
 {
     for (int i = 0; i < pts.Length; i++)
         if (pt.Equals(pts[i]))
             return false;
     return true;
 }
开发者ID:izambakci,项目名称:tf-net,代码行数:14,代码来源:EdgeRing.cs

示例11: Project

        /// <summary> 
        /// Compute the projection of a point onto the line determined
        /// by this line segment.
        /// Note that the projected point  may lie outside the line segment.  
        /// If this is the case,  the projection factor will lie outside the range [0.0, 1.0].
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public ICoordinate Project(ICoordinate p)
        {
            if (p.Equals(P0) || p.Equals(P1)) 
                return new Coordinate(p);

            var r = ProjectionFactor(p);
            ICoordinate coord = new Coordinate {X = P0.X + r*(P1.X - P0.X), Y = P0.Y + r*(P1.Y - P0.Y)};
            return coord;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:LineSegment.cs

示例12: FindEdge

 /// <summary>
 /// Returns the edge whose first two coordinates are p0 and p1.
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <returns> The edge, if found <c>null</c> if the edge was not found.</returns>
 public Edge FindEdge(ICoordinate p0, ICoordinate p1)
 {
     for (int i = 0; i < edges.Count; i++) 
     {
         Edge e = (Edge) edges[i];
         ICoordinate[] eCoord = e.Coordinates;
         if (p0.Equals(eCoord[0]) && p1.Equals(eCoord[1]))
             return e;
     }
     return null;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:17,代码来源:PlanarGraph.cs

示例13: Project

        /// <summary> 
        /// Compute the projection of a point onto the line determined
        /// by this line segment.
        /// Note that the projected point
        /// may lie outside the line segment.  If this is the case,
        /// the projection factor will lie outside the range [0.0, 1.0].
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public ICoordinate Project(ICoordinate p)
        {
            if (p.Equals(P0) || p.Equals(P1)) 
                return new Coordinate(p);

            double r = ProjectionFactor(p);
            ICoordinate coord = new Coordinate();
            coord.X = P0.X + r * (P1.X - P0.X);
            coord.Y = P0.Y + r * (P1.Y - P0.Y);
            return coord;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:20,代码来源:LineSegment.cs

示例14: ProjectionFactor

        /// <summary>
        /// Compute the projection factor for the projection of the point p
        /// onto this <c>LineSegment</c>. The projection factor is the constant k
        /// by which the vector for this segment must be multiplied to
        /// equal the vector for the projection of p.
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public double ProjectionFactor(ICoordinate p)
        {
            if (p.Equals(P0)) return 0.0;
            if (p.Equals(P1)) return 1.0;

            // Otherwise, use comp.graphics.algorithms Frequently Asked Questions method
            /*     	          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
            */
            double dx = P1.X - P0.X;
            double dy = P1.Y - P0.Y;
            double len2 = dx * dx + dy * dy;
            double r = ((p.X - P0.X) * dx + (p.Y - P0.Y) * dy) / len2;
            return r;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:30,代码来源:LineSegment.cs

示例15: Equal

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

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


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