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


C# Point2d.GetDistanceTo方法代码示例

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


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

示例1: Get

        public static double Get(bool IsLeftComp, double r, Polyline line, Point2d TheIntersectPoint, int Index, Point2d StartPoint)
        {
            double oldBulge = line.GetBulgeAt(Index - 1);
            if (oldBulge == 0)
                return 0;//这里可能不对,可能有两个交点,而默认为一个交点
            else
            {
                double delta = System.Math.Atan(System.Math.Abs(oldBulge)) * 2;

                //这里计算新的半径时,要考虑方向因素,可能新半径会更小,也可能会更大
                //取决于路径的偏移方向,以及圆心的位置
                double newRadius = line.GetPoint2dAt(Index - 1).GetDistanceTo(line.GetPoint2dAt(Index)) / 2 / System.Math.Sin(delta);//新弧的半径
                if (IsLeftComp)
                {
                    if (oldBulge < 0)
                        newRadius += r;
                    else newRadius -= r;
                }
                else
                {
                    if (oldBulge > 0)
                        newRadius += r;
                    else newRadius -= r;
                }

                double newChord = StartPoint.GetDistanceTo(TheIntersectPoint);
                double newBulge = System.Math.Tan(
                    System.Math.Asin(newChord / 2 / newRadius) / 2
                    )
                    * line.GetBulgeAt(Index - 1) / System.Math.Abs(line.GetBulgeAt(Index - 1));
                return -newBulge;
            }
        }
开发者ID:komelio,项目名称:Dimeng.LinkToMicrocad,代码行数:33,代码来源:GetOffsetCurveBulge.cs

示例2: Sierpinski

 public Sierpinski(Point2d a, Point2d b, Point2d c)
 {
     Triangle = new Polyline();
     A = a;
     B = b;
     C = c;
     this.Size = B.GetDistanceTo(A);
     Triangle.AddVertexAt(0, A, 0, 0, 0);
     Triangle.AddVertexAt(1, B, 0, 0, 0);
     Triangle.AddVertexAt(2, C, 0, 0, 0);
     Triangle.Closed = true;
     depth = 0;
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:13,代码来源:Sierpinski.cs

示例3: GetTangentsTo

        /// <summary>
        /// Returns the tangents between the active CircularArc2d instance complete circle and a point.
        /// </summary>
        /// <remarks>
        /// Tangents start points are on the object to which this method applies, end points on the point passed as argument.
        /// Tangents are always returned in the same order: the tangent on the left side of the line from the circular arc center
        /// to the point before the other one. 
        /// </remarks>
        /// <param name="arc">The instance to which this method applies.</param>
        /// <param name="pt">The Point2d to which tangents are searched</param>
        /// <returns>An array of LineSegement2d representing the tangents (2) or null if there is none.</returns>
        public static LineSegment2d[] GetTangentsTo(this CircularArc2d arc, Point2d pt)
        {
            // check if the point is inside the circle
            Point2d center = arc.Center;
            if (pt.GetDistanceTo(center) <= arc.Radius)
                return null;

            Vector2d vec = center.GetVectorTo(pt) / 2.0;
            CircularArc2d tmp = new CircularArc2d(center + vec, vec.Length);
            Point2d[] inters = arc.IntersectWith(tmp);
            if (inters == null)
                return null;
            LineSegment2d[] result = new LineSegment2d[2];
            Vector2d v1 = inters[0] - center;
            Vector2d v2 = inters[1] - center;
            int i = vec.X * v1.Y - vec.Y - v1.X > 0 ? 0 : 1;
            int j = i ^ 1;
            result[i] = new LineSegment2d(inters[0], pt);
            result[j] = new LineSegment2d(inters[1], pt);
            return result;
        }
开发者ID:vildar82,项目名称:AcadLib,代码行数:32,代码来源:CircularArc2dExtensions.cs


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