• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Point2d类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Point2d类属于命名空间,在下文中一共展示了Point2d类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: AddLinearDimension2

  public static Rhino.Commands.Result AddLinearDimension2(Rhino.RhinoDoc doc)
  {
    Point3d origin = new Point3d(1,1,0);
    Point3d offset = new Point3d(11,1,0);
    Point3d pt = new Point3d((offset.X-origin.X)/2,3,0);

    Plane plane = Plane.WorldXY;
    plane.Origin = origin;

    double u,v;
    plane.ClosestParameter(origin, out u, out v);
    Point2d ext1 = new Point2d(u, v);

    plane.ClosestParameter(offset, out u, out v);
    Point2d ext2 = new Point2d(u, v);

    plane.ClosestParameter(pt, out u, out v);
    Point2d linePt = new Point2d(u, v);

    LinearDimension dimension = new LinearDimension(plane, ext1, ext2, linePt);
    if (doc.Objects.AddLinearDimension(dimension) != Guid.Empty)
    {
      doc.Views.Redraw();
      return Rhino.Commands.Result.Success;
    }
    return Rhino.Commands.Result.Failure;
  }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:27,代码来源:ex_addlineardimension2.cs


示例3: 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


示例4: PolylineSegment

 /// <summary>
 /// Creates a new instance of PolylineSegment from two points, a bulge, a start width and an end width.
 /// </summary>
 /// <param name="startPoint">The start point of the segment.</param>
 /// <param name="endPoint">The end point of the segment.</param>
 /// <param name="bulge">The bulge of the segment.</param>
 /// <param name="startWidth">The start width of the segment.</param>
 /// <param name="endWidth">The end width of the segment.</param>
 public PolylineSegment(Point2d startPoint, Point2d endPoint, double bulge, double startWidth, double endWidth)
 {
     _startPoint = startPoint;
     _endPoint = endPoint;
     _bulge = bulge;
     _startWidth = startWidth;
     _endWidth = endWidth;
 }
开发者ID:vildar82,项目名称:AcadLib,代码行数:16,代码来源:PolylineSegment.cs


示例5: OnDynamicDraw

 protected override void OnDynamicDraw(GetPointDrawEventArgs e)
 {
     base.OnDynamicDraw(e);
     var xform = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen);
     var current_point = e.CurrentPoint;
     current_point.Transform(xform);
     var screen_point = new Point2d(current_point.X, current_point.Y);
     var msg = string.Format("screen {0:F}, {1:F}", current_point.X, current_point.Y);
     e.Display.Draw2dText(msg, System.Drawing.Color.Blue, screen_point, false);
 }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:10,代码来源:ex_drawstring.cs


示例6: Imagen

 public Imagen(Point2d rect, Point3d centerImage, List<Color> colors, double sizePixels)
 {
     this.rect = rect;
     this.centerImage = centerImage;
     this.colors = colors;
     this.sizePixels = sizePixels;
     this.pixels = new List<Pixel>();
     this.ents = new List<Entity>();
     PixelsConfig();
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:10,代码来源:Imagen.cs


示例7: Sierpinski

 public Sierpinski(Point3d center, Double size = 100)
 {
     Triangle = new Polyline();
     this.Size = size;
     A = new Point2d(center.X - size / 2, center.Y);
     B = new Point2d(center.X, center.Y + size);
     C = new Point2d(center.X + size / 2, center.Y);
     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


示例8: Window

 public Window(
     string title,
     Point2d<int> position,
     Size2d<int> size,
     SDL.SDL_WindowFlags flags)
 {
     window = SDL.SDL_CreateWindow(
         title,
         position.X,
         position.Y,
         size.Width,
         size.Height,
         flags);
 }
开发者ID:Sl0vi,项目名称:cs2d,代码行数:14,代码来源:Window.cs


示例9: GetNextScanPoint

        private Point2d? GetNextScanPoint()
        {
            Gap nextGap = null;
            var delta = int.MaxValue;

            foreach (var gap in _scene.Gaps)
            {
                if (gap.Width() <= Config.RobotWidth * Config.UnitsInMeter)
                    continue;

                var tmpDelta = Math.Abs(gap.PositionIndex() - _robot.PositionIndex);
                if (tmpDelta >= delta)
                    continue;

                delta = tmpDelta;
                nextGap = gap;

                if (delta == 0)
                    break;
            }

            if (nextGap == null)
                return null;

            //TODO: Возможен баг, если угол Gap больше 180 градусов
            var gapWidth = nextGap.Width();
            //if (gapWidth <= Config.RobotWidth * Config.UnitsInMeter)
            //    continue;

            //var l1 = Logic.Distance(_robot.Position, nextGap.Item1.GetPoint2D());
            //var p1 = Logic.GetDividingPoint(_robot.Position, nextGap.Item1.GetPoint2D(), 1 / l1);

            //var l2 = Logic.Distance(_robot.Position, nextGap.Item2.GetPoint2D());
            //var p2 = Logic.GetDividingPoint(_robot.Position, nextGap.Item2.GetPoint2D(), 1 / l2);

            //var intersection = Logic.LineIntersection(p1, p2, nextGap.Item1.GetPoint2D(), nextGap.Item2.GetPoint2D());

            //var gapWidth = Logic.Distance(p1, p2);

            //TODO: подумать
            //var gapWidth = nextGap.Width();
            //if (gapWidth <= Config.RobotWidth * Config.UnitsInMeter)
            //    throw new Exception("Ширина пробела меньше ширины робота");

            var coef = Math.Min(Config.CameraMaxDistance * Config.UnitsInMeter / gapWidth, 0.5);
            var vector = new Point2d(nextGap.Item2.X - nextGap.Item1.X, nextGap.Item2.Y - nextGap.Item1.Y);

            return new Point2d(nextGap.Item1.X + coef * vector.X, nextGap.Item1.Y + coef * vector.Y);
        }
开发者ID:mmcs-robotics,项目名称:mapping_2015,代码行数:49,代码来源:Engine.cs


示例10: TileContour

        public static void TileContour()
        {
            AcadLib.CommandStart.Start((doc) =>
            {
                Database db = doc.Database;
                Editor ed = doc.Editor;

                // Jig отрисовки полилинии по задаваемым точкам.
                TileLineJig jigTest = new TileLineJig();
                PromptResult jigRes;
                bool status = true;
                do
                {
                    jigRes = ed.Drag(jigTest);
                    if (jigRes.Status == PromptStatus.OK)
                    {
                        // Добавление указанной точки
                        jigTest.AddNewPromptPoint();
                    }
                    else if (jigRes.Status == PromptStatus.Cancel || jigRes.Status == PromptStatus.Error)
                    {
                        return;
                    }
                    else if (jigRes.Status == PromptStatus.Other)
                    {
                        status = false;
                    }
                } while (status);

                // Добавление полилинии в чертеж.
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                    Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                    pl.SetDatabaseDefaults();
                    for (int i = 0; i < jigTest.AllVertex.Count; i++)
                    {
                        Point3d pt3d = jigTest.AllVertex[i];
                        Point2d pt2d = new Point2d(pt3d.X, pt3d.Y);
                        pl.AddVertexAt(i, pt2d, 0, db.Plinewid, db.Plinewid);
                    }
                    pl.TransformBy(jigTest.UCS);
                    btr.AppendEntity(pl);
                    tr.AddNewlyCreatedDBObject(pl, true);
                    tr.Commit();
                }
            });
        }
开发者ID:vildar82,项目名称:TileContour,代码行数:48,代码来源:Commands.cs


示例11: LineIntersection

        public static Point2d? LineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4)
        {
            var dx12 = p2.X - p1.X;
            var dy12 = p2.Y - p1.Y;
            var dx34 = p4.X - p3.X;
            var dy34 = p4.Y - p3.Y;

            var denominator = (dy12 * dx34 - dx12 * dy34);

            var t1 = ((p1.X - p3.X) * dy34 + (p3.Y - p1.Y) * dx34) / denominator;

            if (double.IsInfinity(t1))
                return null;

            return new Point2d(p1.X + dx12 * t1, p1.Y + dy12 * t1);
        }
开发者ID:mmcs-robotics,项目名称:mapping_2015,代码行数:16,代码来源:Logic.cs


示例12: Create

        public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t)
        {
            var cellWidth = ColorBookHelper.CellWidth;
            var cellHeight = ColorBookHelper.CellHeight;
            var margin = ColorBookHelper.Margin;
            var marginHalf = margin * 0.5;

            Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0);

            Polyline pl = new Polyline(4);
            pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0);
            pl.Closed = true;
            pl.SetDatabaseDefaults();
            pl.Color = Color;

            cs.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            Hatch h = new Hatch();
            h.SetDatabaseDefaults();
            h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
            h.Annotative = AnnotativeStates.False;

            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);

            h.Associative = true;
            h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
            h.Color = Color;
            h.EvaluateHatch(true);

            DBText text = new DBText();
            text.SetDatabaseDefaults();
            text.HorizontalMode = TextHorizontalMode.TextCenter;
            text.Annotative = AnnotativeStates.False;
            text.Height = ColorBookHelper.TextHeight;
            text.AlignmentPoint = ptText;
            text.AdjustAlignment(cs.Database);
            text.TextStyleId = ColorBookHelper.IdTextStylePik;
            text.TextString = Name;

            cs.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);
        }
开发者ID:vildar82,项目名称:AcadLib,代码行数:47,代码来源:ColorItem.cs


示例13: closestPointOnSurf

        public static DPoint3d closestPointOnSurf(DPoint3d point, ISurface surf, double tol, out double Dist, out Point2d UV, out DVector3d normal)
        {
            Bentley.Interop.MicroStationDGN.Point3d cpRef = new Bentley.Interop.MicroStationDGN.Point3d();
            cpRef.X = point.X;
            cpRef.Y = point.Y;
            cpRef.Z = point.Z;

            Bentley.Interop.MicroStationDGN.Point3d cp = new Bentley.Interop.MicroStationDGN.Point3d();
            Bentley.Interop.MicroStationDGN.Point2d cp2d = new Bentley.Interop.MicroStationDGN.Point2d();

            Dist = GeometryTools.BSplineSurfaceComputeMinimumDistance(ref cp, ref cp2d, ref cpRef, tol, surf.com_bsplineSurface);
            UV = new Point2d();
            UV.X = cp2d.X;
            UV.Y = cp2d.Y;

            normal = NormalAtUVParameterOnSurface(surf.com_bsplineSurface, UV.X, UV.Y);

            return new DPoint3d(cp.X, cp.Y, cp.Z);
        }
开发者ID:cerver,项目名称:CERVERFunctions,代码行数:19,代码来源:CerverFunctions.cs


示例14: Rectangle

        /// <summary>
        /// Initializes a new instance of the <see cref="Rectangle"/> class.
        /// </summary>
        public Rectangle(Point2d bottomLeftCorner, Point2d topRightCorner)
        {
            if (bottomLeftCorner == null)
                throw new ArgumentNullException(nameof(bottomLeftCorner));

            if (topRightCorner == null)
                throw new ArgumentNullException(nameof(topRightCorner));

            BottomLeftCorner = bottomLeftCorner;
            TopRightCorner = topRightCorner;

            Width = topRightCorner.X - bottomLeftCorner.X;
            Height = topRightCorner.Y - bottomLeftCorner.Y;

            CenterPoint =
                AddIn.CreatePoint2D(
                    bottomLeftCorner.X + Width / 2,
                    bottomLeftCorner.Y + Height / 2
                );
        }
开发者ID:stevenvolckaert,项目名称:autodesk-inventor-powertools,代码行数:23,代码来源:Rectangle.cs


示例15: addOutsides

        private void addOutsides(BlockTableRecord btrPanel, Transaction t)
        {
            if (panelBase.Panel.outsides?.outside?.Count()>0)
             {
            foreach (var outside in panelBase.Panel.outsides.outside)
            {
               Polyline plOut = new Polyline();
               Point2d pt;// =new Point2d(outside.posi.X, outside.posi.Y);
               double width = Math.Abs(outside.width)+70;
               // Если это левое примыкание Outside
               if (Math.Abs(outside.posi.X)<10)
               {
                  pt = new Point2d(outside.posi.X, outside.posi.Y);
                  panelBase.XMinContour = width;
                  panelBase.XStartTile = width+11;
                  //panelBase.XMinPanel = pt.X;
                  panelBase.IsOutsideLeft = true;
               }
               else
               {
                  pt = new Point2d(outside.posi.X-70, outside.posi.Y);
                  panelBase.XMaxContour += -70;
                  panelBase.XMaxPanel = pt.X + width;
                  panelBase.IsOutsideRight = true;
               }

               plOut.AddVertexAt(0, pt, 0, 0, 0);
               pt = new Point2d(pt.X+ width, pt.Y);
               plOut.AddVertexAt(1, pt, 0, 0, 0);
               pt = new Point2d(pt.X, pt.Y+outside.height);
               plOut.AddVertexAt(2, pt, 0, 0, 0);
               pt = new Point2d(pt.X- width, pt.Y);
               plOut.AddVertexAt(3, pt, 0, 0, 0);
               plOut.Closed = true;

               plOut.Layer = "0";
               btrPanel.AppendEntity(plOut);
               t.AddNewlyCreatedDBObject(plOut, true);
            }
             }
        }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:41,代码来源:Contour.cs


示例16: 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


示例17: select_OnPreSelect

        void select_OnPreSelect(ref object PreSelectEntity, out bool DoHighlight, ref ObjectCollection MorePreSelectEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
        {
            DoHighlight = true;

            //���õ������ѡ�Ķ�������ã�����ǰ�涨��Ĺ�����������֪���ö���һ����һ����
            Edge edge;
            edge = (Edge)PreSelectEntity;

            //ȷ���Ƿ�����ñ����в����ӵı�
            EdgeCollection edges;
            edges = edge.TangentiallyConnectedEdges;
            if (edges.Count > 1)
            {
                //�������������ߵĶ�� 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Point2f类代码示例发布时间:2022-05-24
下一篇:
C# Point2D类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap