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


C# Coordinate.Equals2D方法代码示例

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


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

示例1: Compare

        /// <summary>
        ///  Compares two <see cref="Coordinate" />s for their relative position along a segment
        /// lying in the specified <see cref="Octant" />.
        /// </summary>
        /// <param name="octant"></param>
        /// <param name="p0"></param>
        /// <param name="p1"></param>
        /// <returns>
        /// -1 if node0 occurs first, or
        ///  0 if the two nodes are equal, or
        ///  1 if node1 occurs first.
        /// </returns>
        public static int Compare(OctantDirection octant, Coordinate p0, Coordinate p1)
        {
            // nodes can only be equal if their coordinates are equal
            if (p0.Equals2D(p1))
                return 0;

            int xSign = RelativeSign(p0.X, p1.X);
            int ySign = RelativeSign(p0.Y, p1.Y);

            switch (octant)
            {
                case OctantDirection.Zero:
                    return CompareValue(xSign, ySign);
                case OctantDirection.One:
                    return CompareValue(ySign, xSign);
                case OctantDirection.Two:
                    return CompareValue(ySign, -xSign);
                case OctantDirection.Three:
                    return CompareValue(-xSign, ySign);
                case OctantDirection.Four:
                    return CompareValue(-xSign, -ySign);
                case OctantDirection.Five:
                    return CompareValue(-ySign, -xSign);
                case OctantDirection.Six:
                    return CompareValue(-ySign, xSign);
                case OctantDirection.Seven:
                    return CompareValue(xSign, -ySign);
            }
            throw new InvalidOctantException(octant.ToString());
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:42,代码来源:SegmentPointComparator.cs

示例2: Compare

        /// <summary>
        /// Compares two <see cref="Coordinate" />s for their relative position along a segment
        /// lying in the specified <see cref="Octant" />.
        /// </summary>
        /// <param name="octant"></param>
        /// <param name="p0"></param>
        /// <param name="p1"></param>
        /// <returns>
        /// -1 if node0 occurs first, or<br/>
        ///  0 if the two nodes are equal, or <br/>
        ///  1 if node1 occurs first.
        /// </returns>
        public static int Compare(Octants octant, Coordinate p0, Coordinate p1)
        {
            // nodes can only be equal if their coordinates are equal
            if (p0.Equals2D(p1))
                return 0;

            var xSign = RelativeSign(p0.X, p1.X);
            var ySign = RelativeSign(p0.Y, p1.Y);

            switch (octant)
            {
                case Octants.Zero:
                    return CompareValue(xSign, ySign);
                case Octants.One:
                    return CompareValue(ySign, xSign);
                case Octants.Two:
                    return CompareValue(ySign, -xSign);
                case Octants.Three:
                    return CompareValue(-xSign, ySign);
                case Octants.Four:
                    return CompareValue(-xSign, -ySign);
                case Octants.Five:
                    return CompareValue(-ySign, -xSign);
                case Octants.Six:
                    return CompareValue(-ySign, xSign);
                case Octants.Seven:
                    return CompareValue(xSign, -ySign);
            }

            Assert.ShouldNeverReachHere("invalid octant value: " + octant);
            return 0;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:44,代码来源:SegmentPointComparator.cs

示例3: SplitAt

 public void SplitAt(double length, Coordinate endPt)
 {
     double actualLen = GetConstrainedLength(length);
     double frac = actualLen/_segLen;
     if (endPt.Equals2D(_seg.P0))
         _splitPt = _seg.PointAlong(frac);
     else
         _splitPt = PointAlongReverse(_seg, frac);
 }
开发者ID:leoliusg,项目名称:NetTopologySuite,代码行数:9,代码来源:SplitSegment.cs

示例4: ComputeIntersect

        public override int ComputeIntersect(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
        {
            IsProper = false;

            // first try a fast test to see if the envelopes of the lines intersect
            if (!Envelope.Intersects(p1, p2, q1, q2))
                return NoIntersection;

            // for each endpoint, compute which side of the other segment it lies
            // if both endpoints lie on the same side of the other segment,
            // the segments do not intersect
            int Pq1 = CGAlgorithms.OrientationIndex(p1, p2, q1);
            int Pq2 = CGAlgorithms.OrientationIndex(p1, p2, q2);

            if ((Pq1 > 0 && Pq2 > 0) ||
                (Pq1 < 0 && Pq2 < 0))
                return NoIntersection;

            int Qp1 = CGAlgorithms.OrientationIndex(q1, q2, p1);
            int Qp2 = CGAlgorithms.OrientationIndex(q1, q2, p2);

            if ((Qp1 > 0 && Qp2 > 0) ||
                (Qp1 < 0 && Qp2 < 0))
                return NoIntersection;

            bool collinear = Pq1 == 0 && Pq2 == 0 && Qp1 == 0 && Qp2 == 0;
            if (collinear)
                return ComputeCollinearIntersection(p1, p2, q1, q2);

            /*
             * At this point we know that there is a single intersection point
             * (since the lines are not collinear).
             */

            /*
             *  Check if the intersection is an endpoint. If it is, copy the endpoint as
             *  the intersection point. Copying the point rather than computing it
             *  ensures the point has the exact value, which is important for
             *  robustness. It is sufficient to simply check for an endpoint which is on
             *  the other line, since at this point we know that the inputLines must
             *  intersect.
             */
            if (Pq1 == 0 || Pq2 == 0 || Qp1 == 0 || Qp2 == 0)
            {
                IsProper = false;

                /*
                 * Check for two equal endpoints.  
                 * This is done explicitly rather than by the orientation tests
                 * below in order to improve robustness.
                 * 
                 * [An example where the orientation tests fail to be consistent is
                 * the following (where the true intersection is at the shared endpoint
                 * POINT (19.850257749638203 46.29709338043669)
                 * 
                 * LINESTRING ( 19.850257749638203 46.29709338043669, 20.31970698357233 46.76654261437082 ) 
                 * and 
                 * LINESTRING ( -48.51001596420236 -22.063180333403878, 19.850257749638203 46.29709338043669 )
                 * 
                 * which used to produce the INCORRECT result: (20.31970698357233, 46.76654261437082, NaN)
                 * 
                 */
                if (p1.Equals2D(q1) || p1.Equals2D(q2))
                    IntersectionPoint[0] = p1;
                else if (p2.Equals2D(q1) || p2.Equals2D(q2))
                    IntersectionPoint[0] = p2;
                else if (Pq1 == 0)
                    IntersectionPoint[0] = new Coordinate(q1);
                else if (Pq2 == 0)
                    IntersectionPoint[0] = new Coordinate(q2);
                else if (Qp1 == 0)
                    IntersectionPoint[0] = new Coordinate(p1);
                else if (Qp2 == 0)
                    IntersectionPoint[0] = new Coordinate(p2);
            }
            else
            {
                IsProper = true;
                IntersectionPoint[0] = Intersection(p1, p2, q1, q2);
            }
            return PointIntersection;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:82,代码来源:RobustLineIntersector.cs


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