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


C# Polygon.Add方法代码示例

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


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

示例1: GetCorrectedWinding

		public static Polygons GetCorrectedWinding(this Polygons polygonsToFix)
		{
			polygonsToFix = Clipper.CleanPolygons(polygonsToFix);
			Polygon boundsPolygon = new Polygon();
			IntRect bounds = Clipper.GetBounds(polygonsToFix);
			bounds.left -= 10;
			bounds.bottom += 10;
			bounds.right += 10;
			bounds.top -= 10;

			boundsPolygon.Add(new IntPoint(bounds.left, bounds.top));
			boundsPolygon.Add(new IntPoint(bounds.right, bounds.top));
			boundsPolygon.Add(new IntPoint(bounds.right, bounds.bottom));
			boundsPolygon.Add(new IntPoint(bounds.left, bounds.bottom));

			Clipper clipper = new Clipper();

			clipper.AddPaths(polygonsToFix, PolyType.ptSubject, true);
			clipper.AddPath(boundsPolygon, PolyType.ptClip, true);

			PolyTree intersectionResult = new PolyTree();
			clipper.Execute(ClipType.ctIntersection, intersectionResult);

			Polygons outputPolygons = Clipper.ClosedPathsFromPolyTree(intersectionResult);

			return outputPolygons;
		}
开发者ID:broettge,项目名称:MatterSlice,代码行数:27,代码来源:PolygonsHelper.cs

示例2: ToPolygon

 public Polygon ToPolygon(int offset = 0)
 {
     offset += HitBox;
     var result = new Polygon();
     var innerRadius = -0.1562f * Distance + 687.31f;
     var outerRadius = 0.35256f * Distance + 133f;
     outerRadius = outerRadius / (float) Math.Cos(2 * Math.PI / CircleLineSegmentN);
     var innerCenters = LeagueSharp.Common.Geometry.CircleCircleIntersection(
         Start, End, innerRadius, innerRadius);
     var outerCenters = LeagueSharp.Common.Geometry.CircleCircleIntersection(
         Start, End, outerRadius, outerRadius);
     var innerCenter = innerCenters[0];
     var outerCenter = outerCenters[0];
     var direction = (End - outerCenter).Normalized();
     var end = (Start - outerCenter).Normalized();
     var maxAngle = (float) (direction.AngleBetween(end) * Math.PI / 180);
     var step = -maxAngle / CircleLineSegmentN;
     for (var i = 0; i < CircleLineSegmentN; i++)
     {
         var angle = step * i;
         var point = outerCenter + (outerRadius + 15 + offset) * direction.Rotated(angle);
         result.Add(point);
     }
     direction = (Start - innerCenter).Normalized();
     end = (End - innerCenter).Normalized();
     maxAngle = (float) (direction.AngleBetween(end) * Math.PI / 180);
     step = maxAngle / CircleLineSegmentN;
     for (var i = 0; i < CircleLineSegmentN; i++)
     {
         var angle = step * i;
         var point = innerCenter + Math.Max(0, innerRadius - offset - 100) * direction.Rotated(angle);
         result.Add(point);
     }
     return result;
 }
开发者ID:StopMotionCuber,项目名称:LeagueSharp-1,代码行数:35,代码来源:Geometry.cs

示例3: PDFReferencePointRenderer

 public PDFReferencePointRenderer()
 {
     // Create the polygon that represents the body
     bodyPlygn = new Polygon();
     bodyPlygn.Add(new Vector2(this.X + .25, this.Y + .25));
     bodyPlygn.Add(new Vector2(this.X + .25, this.Y - .25));
     bodyPlygn.Add(new Vector2(this.X - .25, this.Y + .25));
     bodyPlygn.Add(new Vector2(this.X - .25, this.Y - .25));
 }
开发者ID:iamchucky,项目名称:3DpointCloud,代码行数:9,代码来源:PDFReferencePointRenderer.cs

示例4: WaypointRenderer

 public WaypointRenderer()
 {
     // Create the polygon that represents the body
     bodyPlygn = new Polygon();
     bodyPlygn.Add(new Vector2(this.X+.2, this.Y+.2));
     bodyPlygn.Add(new Vector2(this.X+.2, this.Y-.2));
     bodyPlygn.Add(new Vector2(this.X-.2, this.Y+.2));
     bodyPlygn.Add(new Vector2(this.X-.2, this.Y-.2));
 }
开发者ID:iamchucky,项目名称:3DpointCloud,代码行数:9,代码来源:WaypointRenderer.cs

示例5: TestSquare

        public static void TestSquare()
        {
            Polygon poly = new Polygon();
            poly.Add(new Position("36.60987854N,88.30194711W"));
            poly.Add(new Position("36.60989999N,88.30430746W"));
            poly.Add(new Position("36.60797953N,88.30428600W"));
            poly.Add(new Position("36.60796880N,88.30190420W"));

            // Built-in formula
            Console.WriteLine("GeoFrameworks new calc: " + poly.Perimeter.ToString());
            // Custom formula
            Console.WriteLine("GeoFrameworks old calc: " + Perimeter(poly));
        }
开发者ID:ncorreia,项目名称:FoursquareMobile,代码行数:13,代码来源:Program.cs

示例6: VehiclePolygonWithRadius

 /// <summary>
 /// Create and return octagon model of vehicle from given radius
 /// </summary>
 /// <param name="r"></param>
 /// <returns></returns>
 public static Polygon VehiclePolygonWithRadius(double r)
 {
     Polygon poly = new Polygon();
     poly.Add(new Vector2(r, r));
     poly.Add(new Vector2(-r, r));
     poly.Add(new Vector2(-r, -r));
     poly.Add(new Vector2(r, -r));
     /*
     for (int i = -5; i < 7; i += 2)
     {
         poly.Add(new Vector2(r * Math.Cos(Math.PI * i / 8), r * Math.Sin(Math.PI * i / 8)));
     }
      * */
     return poly;
 }
开发者ID:iamchucky,项目名称:3DpointCloud,代码行数:20,代码来源:LidarPolyExtractor.cs

示例7: ToPolygon

 public static Polygon ToPolygon(this Path v) {
     var polygon = new Polygon();
     foreach (var point in v) {
         polygon.Add(new Vector2(point.X, point.Y));
     }
     return polygon;
 }
开发者ID:CupidL0ve,项目名称:LeagueSharp,代码行数:7,代码来源:Geometry.cs

示例8: Build

        public static void Build(RooFile Room)
        {
            if (Room == null)
                return;

            room = Room;

            if (BuildStarted != null)
                BuildStarted(null, new EventArgs());

            ///////////////////////////////////////////////////////////////

            BoundingBox2D box = Room.GetBoundingBox2D(true);
            
            Polygon poly = new Polygon();           
            poly.Add(box.Min);
            poly.Add(box.Min + new V2(box.Max.X - box.Min.X, 0f));
            poly.Add(box.Max);
            poly.Add(box.Max - new V2(box.Max.X - box.Min.X, 0f));
            
            ///////////////////////////////////////////////////////////////

            // clean up old data from room
            Room.Walls.Clear();
            Room.BSPTree.Clear();
            foreach (RooSector sector in Room.Sectors)
            {
                sector.Walls.Clear();
                sector.Sides.Clear();
            }

            // convert roomeditor walls to roowall
            for (int i = 0; i < Room.WallsEditor.Count; i++)
            {
                RooWall wall = Room.WallsEditor[i].ToRooWall(RooFile.VERSIONHIGHRESGRID, Room);
                Room.Walls.Add(wall);
            }

            ///////////////////////////////////////////////////////////////

            RooBSPItem tree = BuildNode(Room.Walls, poly, 0);

            ///////////////////////////////////////////////////////////////

            FillNode(tree, Room.BSPTree);
            SetNums(Room.BSPTree);
        }
开发者ID:GJiin,项目名称:meridian59-dotnet,代码行数:47,代码来源:BSPBuilder.cs

示例9: RobotKeypoint

        PathToRobotRenderer runningPath; // the path that the robot is currently running

        #endregion Fields

        #region Constructors

        public RobotKeypoint(int id)
        {
            color = Color.Black;
            this.id = id;
            name = "Robot " + id;
            runningPath = new PathToRobotRenderer();
            commandedPath = new PathToRobotRenderer();
            pose = new RobotPose();

            origPlygn = new Polygon();
            origPlygn.Add(new Vector2(.25, .36));
            origPlygn.Add(new Vector2(.25, -.36));
            origPlygn.Add(new Vector2(-.25, -.36));
            origPlygn.Add(new Vector2(-.25, .36));

            bodyPlygn = new Polygon(origPlygn.points);
        }
开发者ID:iamchucky,项目名称:3DpointCloud,代码行数:23,代码来源:RobotKeypoint.cs

示例10: GenerateLinePaths

		public static void GenerateLinePaths(Polygons polygonToInfill, ref Polygons infillLinesToPrint, int lineSpacing, int infillExtendIntoPerimeter_um, double rotation, long rotationOffset = 0)
		{
			if (polygonToInfill.Count > 0)
			{
				Polygons outlines = polygonToInfill.Offset(infillExtendIntoPerimeter_um);
				if (outlines.Count > 0)
				{
					PointMatrix matrix = new PointMatrix(-(rotation + 90)); // we are rotating the part so we rotate by the negative so the lines go the way we expect

					outlines.ApplyMatrix(matrix);

					Aabb boundary = new Aabb(outlines);

					boundary.min.X = ((boundary.min.X / lineSpacing) - 1) * lineSpacing - rotationOffset;
					int xLineCount = (int)((boundary.max.X - boundary.min.X + (lineSpacing - 1)) / lineSpacing);
					Polygons unclipedPatern = new Polygons();

					long firstX = boundary.min.X / lineSpacing * lineSpacing;
					for (int lineIndex = 0; lineIndex < xLineCount; lineIndex++)
					{
						Polygon line = new Polygon();
						line.Add(new IntPoint(firstX + lineIndex * lineSpacing, boundary.min.Y));
						line.Add(new IntPoint(firstX + lineIndex * lineSpacing, boundary.max.Y));
						unclipedPatern.Add(line);
					}

					PolyTree ret = new PolyTree();
					Clipper clipper = new Clipper();
					clipper.AddPaths(unclipedPatern, PolyType.ptSubject, false);
					clipper.AddPaths(outlines, PolyType.ptClip, true);
					clipper.Execute(ClipType.ctIntersection, ret, PolyFillType.pftPositive, PolyFillType.pftEvenOdd);

					Polygons newSegments = Clipper.OpenPathsFromPolyTree(ret);
					PointMatrix inversematrix = new PointMatrix((rotation + 90));
					newSegments.ApplyMatrix(inversematrix);

					infillLinesToPrint.AddRange(newSegments);
				}
			}
		}
开发者ID:GearWalker,项目名称:MatterSlice,代码行数:40,代码来源:infill.cs

示例11: RobotRenderer

        public RobotRenderer(string name, Color color)
        {
            this.name = name;
            this.color = color;

            // Create the polygon that represents the body
            origPlygn = new Polygon();
            origPlygn.Add(new Vector2(.25, .36));
            origPlygn.Add(new Vector2(.25, -.36));
            origPlygn.Add(new Vector2(-.25, -.36));
            origPlygn.Add(new Vector2(-.25, .36));

            bodyPlygn = new Polygon();
            bodyPlygn.Add(new Vector2(.25, .36));
            bodyPlygn.Add(new Vector2(.25, -.36));
            bodyPlygn.Add(new Vector2(-.25, -.36));
            bodyPlygn.Add(new Vector2(-.25, .36));

            robotContextMenu = new ContextMenu();

            this.MythName = establishMythName(name);
        }
开发者ID:iamchucky,项目名称:3DpointCloud,代码行数:22,代码来源:RobotRenderer.cs

示例12: ToPolygon

        public Polygon ToPolygon()
        {
            double halfWidth = Width/2;
            double halfLength = Length/2;

            Coordinates heading = Heading.Normalize();
            Coordinates heading90 = heading.Rotate90();

            Coordinates l = heading*halfLength;
            Coordinates w = heading90*halfWidth;

            Coordinates pt1 = Position - l - w;
            Coordinates pt2 = Position + l - w;
            Coordinates pt3 = Position + l + w;
            Coordinates pt4 = Position - l + w;

            Polygon poly = new Polygon(4);
            poly.Add(pt1);
            poly.Add(pt2);
            poly.Add(pt3);
            poly.Add(pt4);

            return poly;
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:24,代码来源:SimObstacleState.cs

示例13: ToPolygon

        public Polygon ToPolygon(int offset = 0, float overrideWidth = -1)
        {
            var result = new Polygon();
                var outRadius = (overrideWidth > 0
                    ? overrideWidth
                    : (offset + Radius) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN));

                for (var i = 1; i <= CircleLineSegmentN; i++)
                {
                    var angle = i * 2 * Math.PI / CircleLineSegmentN;
                    var point = new Vector2(
                        Center.X + outRadius * (float)Math.Cos(angle), Center.Y + outRadius * (float)Math.Sin(angle));
                    result.Add(point);
                }

                return result;
        }
开发者ID:zjian1013,项目名称:LeagueSharpFlapperDoodlez,代码行数:17,代码来源:Geometry.cs

示例14: ToPolygon

            public Polygon ToPolygon(int offset = 0, float overrideWidth = -1)
            {
                var result = new Polygon();

                result.Add(
                    RStart + (overrideWidth > 0 ? overrideWidth : Width + offset)*Perpendicular - offset*Direction);
                result.Add(
                    RStart - (overrideWidth > 0 ? overrideWidth : Width + offset)*Perpendicular - offset*Direction);
                result.Add(
                    REnd - (overrideWidth > 0 ? overrideWidth : Width + offset)*Perpendicular + offset*Direction);
                result.Add(
                    REnd + (overrideWidth > 0 ? overrideWidth : Width + offset)*Perpendicular + offset*Direction);

                return result;
            }
开发者ID:Xelamats,项目名称:PortAIO,代码行数:15,代码来源:Geometry.cs

示例15: FindDistictObjectBounds

		static public PolyTree FindDistictObjectBounds(ImageBuffer image)
		{
			MarchingSquaresByte marchingSquaresData = new MarchingSquaresByte(image, 5, 0);
			marchingSquaresData.CreateLineSegments();
			Polygons lineLoops = marchingSquaresData.CreateLineLoops(1);

			if (lineLoops.Count == 1)
			{
				return null;
			}

			// create a bounding polygon to clip against
			IntPoint min = new IntPoint(long.MaxValue, long.MaxValue);
			IntPoint max = new IntPoint(long.MinValue, long.MinValue);
			foreach (Polygon polygon in lineLoops)
			{
				foreach (IntPoint point in polygon)
				{
					min.X = Math.Min(point.X - 10, min.X);
					min.Y = Math.Min(point.Y - 10, min.Y);
					max.X = Math.Max(point.X + 10, max.X);
					max.Y = Math.Max(point.Y + 10, max.Y);
				}
			}

			Polygon boundingPoly = new Polygon();
			boundingPoly.Add(min);
			boundingPoly.Add(new IntPoint(min.X, max.Y));
			boundingPoly.Add(max);
			boundingPoly.Add(new IntPoint(max.X, min.Y));

			// now clip the polygons to get the inside and outside polys
			Clipper clipper = new Clipper();
			clipper.AddPaths(lineLoops, PolyType.ptSubject, true);
			clipper.AddPath(boundingPoly, PolyType.ptClip, true);

			PolyTree polyTreeForPlate = new PolyTree();
			clipper.Execute(ClipType.ctIntersection, polyTreeForPlate);

			return polyTreeForPlate;
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:41,代码来源:CreateDiscreteMeshes.cs


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