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


C# Point.Distance方法代码示例

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


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

示例1: IsDoubleClick

        /// <summary>
        /// Determines whether the last click is a double click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="position">The position.</param>
        /// <returns>True if the click was a double click.</returns>
        internal static bool IsDoubleClick(object sender, Point position)
        {
            long clickTicks = DateTime.Now.Ticks;
            long elapsedTicks = clickTicks - lastClickTicks;
            long elapsedTime = elapsedTicks / TimeSpan.TicksPerMillisecond;
            bool quickClick = elapsedTime <= DoubleClickSpeed;
            bool senderMatch = lastSender != null && sender.Equals(lastSender.Target);

            if (senderMatch && quickClick && position.Distance(lastPosition) <= MaxMoveDistance)
            {
                // Double click!
                lastClickTicks = 0;
                lastSender = null;
                return true;
            }

            // Not a double click
            lastClickTicks = clickTicks;
            lastPosition = position;
            if (!quickClick)
            {
                lastSender = new WeakReference(sender);
            }

            return false;
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:32,代码来源:MouseButtonHelper.cs

示例2: ClosestPoint

 /// <summary> 
 /// Computes the closest point on this line segment to another point.
 /// </summary>
 /// <param name="p">The point to find the closest point to.</param>
 /// <returns>
 /// A Coordinate which is the closest point on the line segment to the point p.
 /// </returns>
 public static Point ClosestPoint(Point p, Point LineSegFrom, Point LineSegTo)
 {
     var factor = ProjectionFactor(p, LineSegFrom, LineSegTo);
     if (factor > 0 && factor < 1)
         return Project(p, LineSegFrom, LineSegTo);
     var dist0 = LineSegFrom.Distance(p);
     var dist1 = LineSegTo.Distance(p);
     return dist0 < dist1 ? LineSegFrom : LineSegTo;
 }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:16,代码来源:CGAlgoritm.cs

示例3: GetCentreToBoundaryDistance

        public double GetCentreToBoundaryDistance(ILinearEquation line)
        {
            var relativeOrigin = new Point(0, 0);
            var relativeBoundaryIntersection = GetRelativeIntersectionPoint(line);

            double distanceToBoundary = relativeOrigin.Distance(relativeBoundaryIntersection);

            return distanceToBoundary;
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:9,代码来源:RectEquation.cs

示例4: FromTwoPointsAndTwoLengths

 public static Triangle FromTwoPointsAndTwoLengths(Point point1, Point point2, double l1, double l2)
 {
     double l3 = point1.Distance(point2);
     double area = Triangle.AreaByLenghts(l1, l2, l3);
     double angle = Math.Asin(2 * area / (l1 * l3));
     Vector horizontal = point1.VectorTo(point1.AddX(1));
     double angle0 = horizontal.AngleWith(point1.VectorTo(point2));
     double x = l1 * Math.Cos(angle0 - angle);
     double y = l1 * Math.Sin(angle0 - angle);
     Point point3 = point1.AddX(x).AddY(y);
     return new Triangle(point1, point2, point3);
 }
开发者ID:fabien-vavrand,项目名称:excel-charting-toolbox,代码行数:12,代码来源:Triangle.cs

示例5: func

    private static int func(Point p1, Point p2, Point p3)
    {
        int h, t;

        h = p1.Distance();

        t = p2.x + h;
        h += p2.Distance();

        if (p3.y == t)
        {
            h += p3.Distance();
        }

        return h;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:16,代码来源:NullCheckAssertion3.cs

示例6: IsClosingALoop

 private bool IsClosingALoop(LineString gpxLine, int currentIndex, double closestPointTolerance)
 {
     int indexOfLinePrefix = currentIndex - 1;
     var currentCoordinatePoint = new Point(gpxLine[currentIndex]);
     while (indexOfLinePrefix >= 0)
     {
         if (currentCoordinatePoint.Distance(new Point(gpxLine.Coordinates[indexOfLinePrefix])) >
             closestPointTolerance)
         {
             break;
         }
         indexOfLinePrefix--;
     }
     if (indexOfLinePrefix < 0)
     {
         return false;
     }
     var distance = indexOfLinePrefix > 0
             ? currentCoordinatePoint.Distance(new LineString(gpxLine.Coordinates.Take(indexOfLinePrefix + 1).ToArray()))
             : currentCoordinatePoint.Distance(new Point(gpxLine.Coordinates[indexOfLinePrefix]));
     return distance < closestPointTolerance;
 }
开发者ID:IsraelHikingMap,项目名称:Site,代码行数:22,代码来源:GpxSplitterService.cs

示例7: WithinDistance

        /// <summary>
        /// Determines if the polygon is within the specified distance from the point.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="point"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static bool WithinDistance(this Polygon polygon, Point point, double distance)
        {
            if (Null(polygon, point))
                return false;

            return point.Distance(polygon) < distance;
        }
开发者ID:jshirota,项目名称:PreStorm,代码行数:14,代码来源:GeometryFunctions.cs

示例8: Distance

        /// <summary>
        /// Calculates the shortest distance to the point.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public static double Distance(this Polygon polygon, Point point)
        {
            AssertNotNull(polygon, point);

            return point.Distance(polygon);
        }
开发者ID:jshirota,项目名称:PreStorm,代码行数:12,代码来源:GeometryFunctions.cs

示例9: ElementNearestToPoint

        Element ElementNearestToPoint(Point position, Element caller, out double minDistance, out ThumbPosition nearestThumbPosition)
        {
            minDistance = double.PositiveInfinity;
            Element hitElement = null;
            nearestThumbPosition = ThumbPosition.NotSet;

            foreach (Element element in UnconnectedElements)
            {
                if(element == caller) continue;

                foreach (ThumbPosition thumbPosition in element.AvailableIncomingConnectors)
                {
                    Point elementLocation = element.GetCanvasThumbPosition(thumbPosition);
                    double distance = position.Distance(elementLocation);
                    if(distance < minDistance)
                    {
                        minDistance = distance;
                        hitElement = element;
                        nearestThumbPosition = thumbPosition;
                    }
                }
            }

            return hitElement;
        }
开发者ID:lokswin,项目名称:ivu-cher,代码行数:25,代码来源:GridCanvas.cs

示例10: GetFeaturesInRange

        public static IEnumerable<IFeature> GetFeaturesInRange(ICoordinate coordinate, IEnumerable<IFeature> features, double tolerance)
        {
            var minDistance = tolerance;
            var point = new Point(coordinate);

            return (from feature in features
                    where feature.Geometry != null // Distance method requires a defined Geometry
                    let distance = point.Distance(feature.Geometry)
                    where distance <= minDistance
                    select feature).ToList();
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:11,代码来源:GeometryHelper.cs

示例11: GetEndPoint

    Point GetEndPoint(Point startPoint, int minSteps, int maxSteps, int maxSize)
    {
        Point endPoint = null;
        var maxTryes = maxSteps * maxSteps;
        var distance = 0;

        do {
            endPoint = new Point(random.Next(0, maxSize), random.Next(0, maxSize));
            maxTryes--;
            distance = startPoint.Distance(endPoint);
        } while (maxTryes > 0 && (distance < minSteps || distance >= maxSteps));

        if (maxTryes == 0) {
            return null;
        }

        return endPoint;
    }
开发者ID:tditada,项目名称:Dungeon-Crawler,代码行数:18,代码来源:MapGenerator.cs

示例12: GetNearestFeature

        public static IFeature GetNearestFeature(ICoordinate coordinate, IEnumerable<IFeature> features, double tolerance)
        {
            var minDistance = tolerance;
            IFeature minDistanceFeature = null;

            var point = new Point(coordinate);

            foreach (var feature in features)
            {
                if(feature.Geometry == null) continue;

                var distance = point.Distance(feature.Geometry);
                if (distance <= minDistance)
                {
                    minDistance = distance;
                    minDistanceFeature = feature;
                }
            }

            return minDistanceFeature;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:GeometryHelper.cs

示例13: Distance

 public static double Distance(Point a, Point b)
 {
     return a.Distance(b);
 }
开发者ID:ondrej11,项目名称:o106,代码行数:4,代码来源:Functions.cs

示例14: Node

 public Node(Point pos_, float G_, Point fromPos, Point toPos)
 {
     pos = pos_;
     G = G_ + pos.Distance(fromPos);
     H = pos.Distance(toPos);
     F = G + H;
 }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:7,代码来源:AStar.cs

示例15: 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(Point p, Point A, Point 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:sridhar19091986,项目名称:sharpmapx,代码行数:49,代码来源:CGAlgoritm.cs


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