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


C# Point2d.DistanceTo方法代码示例

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


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

示例1: Leader

    public static Result Leader(RhinoDoc doc)
    {
        var points = new Point3d[]
        {
          new Point3d(1, 1, 0),
          new Point3d(5, 1, 0),
          new Point3d(5, 5, 0),
          new Point3d(9, 5, 0)
        };

        var xy_plane = Plane.WorldXY;

        var points2d = new List<Point2d>();
        foreach (var point3d in points)
        {
          double x, y;
          if (xy_plane.ClosestParameter(point3d, out x, out y))
          {
        var point2d = new Point2d(x, y);
        if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
          points2d.Add(point2d);
          }
        }

        doc.Objects.AddLeader(xy_plane, points2d);
        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:28,代码来源:ex_leader.cs

示例2: convCurve

        internal static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, IfcCartesianPoint optStrt, bool twoD, out IfcCartesianPoint end)
        {
            double tol = db.Tolerance;
            end = null;
            Curve c = crv.DuplicateCurve();
            if (c.IsLinear(tol))
            {
                if (twoD)
                    end = new IfcCartesianPoint(db, new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                else
                    end = new IfcCartesianPoint(db, c.PointAtEnd);
                if (optStrt == null)
                {
                    if (twoD)
                        optStrt = new IfcCartesianPoint(db, new Point2d(c.PointAtStart.X, c.PointAtStart.Y));
                    else
                        optStrt = new IfcCartesianPoint(db, c.PointAtStart);
                }
                return new IfcPolyline(optStrt, end);
            }
            ArcCurve ac = c as ArcCurve;
            if (ac != null)
                return new IfcTrimmedCurve(db, ac.Arc, twoD, optStrt, out end);
            Arc arc = Arc.Unset;
            if (c.TryGetArc(out arc, tol))
                return new IfcTrimmedCurve(db, arc, twoD, optStrt, out end);

            Polyline pl = new Polyline();
            if (c.TryGetPolyline(out pl))
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    if (twoD)
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, pl.ConvertAll(x => new Point2d(x.X, x.Y))));
                    else
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, pl));
                }
                List<IfcCartesianPoint> cps = new List<IfcCartesianPoint>();
                if (twoD)
                {
                    Point2d p = new Point2d(pl[0].X, pl[0].Y), n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count - 1; icounter++)
                    {
                        n = new Point2d(pl[icounter].X, pl[icounter].Y);
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                    n = new Point2d(pl[pl.Count - 1].X, pl[pl.Count - 1].Y);
                    if (n.DistanceTo(p) > tol)
                    {
                        if (pl.IsClosed)
                            cps.Add(cps[0]);
                        else
                            cps.Add(new IfcCartesianPoint(db, n));
                    }
                }
                else
                {
                    Point3d p = pl[0], n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count; icounter++)
                    {
                        n = pl[icounter];
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                }
                return new IfcPolyline(cps);
            }
            PolyCurve plc = c as PolyCurve;
            if (plc != null)
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    IfcIndexedPolyCurve ipc = IfcIndexedPolyCurve.Convert(db, plc, twoD);
                    if (ipc != null)
                        return ipc;
                }
                return new IfcCompositeCurve(db, plc, twoD);
            }
            if (db.mRelease != ReleaseVersion.IFC2x3)
            {
                NurbsCurve nc = c as NurbsCurve;
                if (nc != null)
                {
                    if (nc.IsRational)
                        return new IfcRationalBSplineCurveWithKnots(db, nc, twoD);
                    return new IfcBSplineCurveWithKnots(db, nc, twoD);
                }
            }

            return null;
        }
开发者ID:jmirtsch,项目名称:GeometryGymIFC,代码行数:100,代码来源:IFC+B+RhinoCommon.cs


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