本文整理汇总了C#中Polygon类的典型用法代码示例。如果您正苦于以下问题:C# Polygon类的具体用法?C# Polygon怎么用?C# Polygon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Polygon类属于命名空间,在下文中一共展示了Polygon类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: mergePartialBuffers
private static Polygon mergePartialBuffers(List<Polygon> buffers)
{
Polygon temp = new Polygon();
ICollection<IGeometry> gc;
while (buffers.Count > 1)
{
List<Polygon> tempBuffers = new List<Polygon>();
for (int i = 0; i < buffers.Count; i += 2)
{
if (i + 1 == buffers.Count)
tempBuffers.Add(buffers[i]);
else
{
gc = buffers[i].Union(buffers[i + 1]);
if (gc.Count > 0)
temp = (Polygon)((GeometryCollection)gc)[0];
tempBuffers.Add(temp);
}
}
buffers = tempBuffers;
}
if (buffers.Count == 0)
return null;
return buffers[0];
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:28,代码来源:GeoBuffer.cs
示例2: MillionSquare
public void MillionSquare()
{
Polygon P = new Polygon(MillionSquarePoints);
Detector D = new Detector(P);
Assert.AreEqual(D.Result, 3999996000001);
}
开发者ID:micrak,项目名称:rakomeister-attic,代码行数:7,代码来源:DetectorTests.cs
示例3: DrawPolygon
// Draw the unsimplified polygon
private void DrawPolygon()
{
// Get current viewpoints extent from the MapView
var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
MapPoint center = viewpointExtent.GetCenter();
double lat = center.Y;
double lon = center.X + 300;
double latOffset = 300;
double lonOffset = 300;
var points = new PointCollection()
{
new MapPoint(lon - lonOffset, lat),
new MapPoint(lon, lat + latOffset),
new MapPoint(lon + lonOffset, lat),
new MapPoint(lon, lat - latOffset),
new MapPoint(lon - lonOffset, lat),
new MapPoint(lon - 2 * lonOffset, lat + latOffset),
new MapPoint(lon - 3 * lonOffset, lat),
new MapPoint(lon - 2 * lonOffset, lat - latOffset),
new MapPoint(lon - 1.5 * lonOffset, lat + latOffset),
new MapPoint(lon - lonOffset, lat)
};
_unsimplifiedPolygon = new Polygon(points, MyMapView.SpatialReference);
_polygonOverlay.Graphics.Clear();
_polygonOverlay.Graphics.Add(new Graphic(_unsimplifiedPolygon));
}
开发者ID:MagicWang,项目名称:arcgis-runtime-samples-dotnet,代码行数:31,代码来源:Simplify.xaml.cs
示例4: Plane
private Plane(IPlaneEntity entity, double size, bool display = false)
: base(entity, false)
{
InitializeGuaranteedProperties();
if (display && size>1)
mDisplayPolygon = CreatePlaneVisuals(size,true);
}
开发者ID:samuto,项目名称:designscript,代码行数:7,代码来源:Plane.cs
示例5: AreaOfInterestButton_Click
// Gets the users digitized area of interest polygon
private async void AreaOfInterestButton_Click(object sender, RoutedEventArgs e)
{
try
{
_graphicsOverlay.Graphics.Clear();
Polygon aoi = null;
if (chkFreehand.IsChecked == true)
{
var boundary = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand) as Polyline;
if (boundary.Parts.First().Count <= 1)
return;
aoi = new Polygon(boundary.Parts, MyMapView.SpatialReference);
aoi = GeometryEngine.Simplify(aoi) as Polygon;
}
else
{
aoi = await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon) as Polygon;
}
_graphicsOverlay.Graphics.Add(new Graphic(aoi));
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
开发者ID:jmiller121,项目名称:arcgis-runtime-samples-dotnet,代码行数:29,代码来源:ExtractData.xaml.cs
示例6: CreateSegmentListFromString
public static List<SlicePerimeterSegment> CreateSegmentListFromString(string segmentListData)
{
List<SlicePerimeterSegment> output = new List<SlicePerimeterSegment>();
string[] segmentData = segmentListData.Split('|');
foreach (string segment in segmentData)
{
if (segment != "")
{
List<IntPoint> outPoints = new Polygon();
string[] points = segment.Split('&');
foreach (string point in points)
{
string[] coordinates = point.Split(',');
string elementX = coordinates[0];
string elementY = coordinates[1];
int xIndex = elementX.IndexOf("x:");
int yIndex = elementY.IndexOf("y:");
outPoints.Add(new IntPoint(int.Parse(elementX.Substring(xIndex+2)), int.Parse(elementY.Substring(yIndex+2))));
}
output.Add(new SlicePerimeterSegment(outPoints[0], outPoints[1]));
}
}
return output;
}
开发者ID:broettge,项目名称:MatterSlice,代码行数:25,代码来源:SlicerLayer.cs
示例7: HotSpot
public HotSpot(Vector2[] vertices, Texture2D texture)
{
shape = new Polygon(vertices);
this.texture = texture;
this.MouseEnabled = true;
this.Name = "HotSpot" + counter++;
}
开发者ID:vkrajacic89,项目名称:MagiciansEscape-TVZ,代码行数:7,代码来源:HotSpot.cs
示例8: StartButton_Click
private async void StartButton_Click(object sender, RoutedEventArgs e)
{
outputGraphicsLayer.Graphics.Clear();
InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
StartButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
ResetButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
//Get the user's input geometry and add it to the map
inputDifferencePolygonGeometry = (await mapView1.Editor.RequestShapeAsync(DrawShape.Polygon)) as Polygon;
drawGraphicsLayer.Graphics.Clear();
drawGraphicsLayer.Graphics.Add(new Graphic { Geometry = inputDifferencePolygonGeometry });
//Simplify the input geometry
var simplifyGeometry = GeometryEngine.Simplify(inputDifferencePolygonGeometry);
//Generate the difference geometries
var inputGeometries1 = inputGraphicsLayer.Graphics.Select(x => x.Geometry).ToList();
var inputGeometries2 = new List<Geometry> { simplifyGeometry };
var differenceOutputGeometries = GeometryEngine.Difference(inputGeometries1, inputGeometries2);
//Add the difference geometries to the amp
foreach (var geom in differenceOutputGeometries)
{
outputGraphicsLayer.Graphics.Add(new Graphic { Geometry = geom });
}
ResetButton.IsEnabled = true;
}
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:32,代码来源:Difference.xaml.cs
示例9: SideWalkExtruder
public SideWalkExtruder(Polygon polygon, Mesh mesh, float quantity, float outlineOffset)
{
_polygon = polygon;
_mesh = mesh;
_quantity = quantity;
_outlineOffset = outlineOffset;
}
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:7,代码来源:SideWalkExtruder.cs
示例10: ExtensionsPolygonAddWaysAcceptsCollectionOfOSMWays
public void ExtensionsPolygonAddWaysAcceptsCollectionOfOSMWays()
{
OSMDB db = new OSMDB();
OSMNode p1 = new OSMNode(1, 10, 15);
OSMNode p2 = new OSMNode(2, 0, 15);
OSMNode p3 = new OSMNode(3, 0, 0);
OSMWay way1 = new OSMWay(10);
OSMWay way2 = new OSMWay(11);
db.Nodes.Add(p1);
db.Nodes.Add(p2);
db.Nodes.Add(p3);
way1.Nodes.Add(p1.ID);
way1.Nodes.Add(p2.ID);
way1.Nodes.Add(p3.ID);
way2.Nodes.Add(p3.ID);
way2.Nodes.Add(p1.ID);
Polygon<OSMNode> target = new Polygon<OSMNode>();
target.AddWays(new OSMWay[] {way1, way2}, db);
Assert.Equal(3, target.VerticesCount);
CompareVerticesLists(new IPointGeo[] { p3, p2, p1 }, target.Vertices);
}
开发者ID:guifa,项目名称:traveltimeanalysis,代码行数:28,代码来源:ExtensionsTest.cs
示例11: MultiPolygonWktToPolygon
private static Polygon MultiPolygonWktToPolygon(string wkt)
{
var polygon = new Polygon();
var pointCollection = new PointCollection();
var removed = wkt.Replace("MULTIPOLYGON (", "");
var preSplit = removed.Replace(")), ((", "|");
var rings = preSplit.Split('|');
foreach (var r in rings)
{
PointCollection pc = new PointCollection();
var r1 = r.Replace("(", "");
var r2 = r1.Replace(")", "");
var r3 = r2.Trim();
var coords = r3.Split(',');
foreach(var coord in coords)
{
coord.Trim();
var xy = coord.Trim().Split(' ');
if (xy.Length != 2)
continue;
pc.Add(new MapPoint(double.Parse(xy[0], CultureInfo.InvariantCulture), double.Parse(xy[1], CultureInfo.InvariantCulture)));
}
polygon.Rings.Add(pc);
}
return polygon;
}
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:33,代码来源:WktConverter.cs
示例12: Multipg
public void Multipg()
{
var rnd = new Random();
var pg = new Polygon[50];
var pgcheck = new GeoAPI.Geometries.IPolygon[50];
var gf = new NetTopologySuite.Geometries.GeometryFactory();
for (var i = 0; i < 50; i++)
{
var center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
var coord = new Coordinate[36];
var coordscheck = new GeoAPI.Geometries.Coordinate[36];
for (var ii = 0; ii < 36; ii++)
{
coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
var x = coord[ii].X;
var y = coord[ii].Y;
var c = new GeoAPI.Geometries.Coordinate(x, y);
coordscheck[ii] = c;
}
coord[35] = new Coordinate(coord[0].X, coord[0].Y);
coordscheck[35] = new GeoAPI.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y);
var ring = gf.CreateLinearRing(coordscheck);
pgcheck[i] = gf.CreatePolygon(ring, null);
pg[i] = new Polygon(coord);
}
var mpg = new MultiPolygon(pg);
var mpgcheck = gf.CreateMultiPolygon(pgcheck);
for (var ii = 0; ii < mpg.Coordinates.Count; ii++)
{
Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X);
Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y);
}
}
开发者ID:hanchao,项目名称:DotSpatial,代码行数:34,代码来源:MultiShape.cs
示例13: AddBooleanPolygon
public void AddBooleanPolygon(Polygon polygon)
{
if(!booleanPolygons.Contains(polygon)) {
booleanPolygons.Add(polygon);
UpdateMesh();
}
}
开发者ID:JakeCataford,项目名称:unity-tinkerbox,代码行数:7,代码来源:DestructibleLevel.cs
示例14: 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
示例15: Tile
public Tile( Polygon boundary, Polygon drawn, Geometry geometry )
: this()
{
Boundary = boundary;
Drawn = drawn;
Geometry = geometry;
// Make the vertex circle.
VertexCircle = boundary.CircumCircle;
// ZZZ - we shouldn't do this here (I did it for the slicing study page).
//VertexCircle.Radius = 1.0;
//
// Below are experimentations with different vertex circle sizes.
//
//VertexCircle.Radius *= (1+1.0/9);
// cuts adjacent cells at midpoint
// Math.Sqrt(63)/6 for {3,6}
// (1 + 1.0/5) for {3,7}
// (1 + 1.0/9) for {3,8}
// (1 + 1.0/20) for {3,9}
// cuts at 1/3rd
// 2/Math.Sqrt(3) for {3,6}
}
开发者ID:roice3,项目名称:Honeycombs,代码行数:28,代码来源:Tile.cs
示例16: MergedInnerAndOuter
// fusion de la forme de base (liner, margelle) et rectangle exterieur
// pour la triangulation
// voir http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
protected void MergedInnerAndOuter()
{
Bounds polyBounds = _polygon.bounds;
Vector3 extents = polyBounds.extents;
Vector3 center = polyBounds.center;
// Pythagore
float translation = _outlineOffset * 1.41421356f; // sqrt (2)
Vector2 upRightDir = new Vector2 (1, 1).normalized * translation;
Vector2 upRight = new Vector2 (center.x + extents.x, center.z + extents.z) + upRightDir;
Vector2 downRightDir = new Vector2 (1, -1).normalized * translation;
Vector2 downRight = new Vector2 (center.x + extents.x, center.z - extents.z) + downRightDir;
Vector2 downLeftDir = new Vector2 (-1, -1).normalized * translation;
Vector2 downLeft = new Vector2 (center.x - extents.x, center.z - extents.z) + downLeftDir;
Vector2 upLeftDir = new Vector2 (-1, 1).normalized * translation;
Vector2 upLeft = new Vector2 (center.x - extents.x, center.z + extents.z) + upLeftDir;
PolygonRawData outerRawPoly = new PolygonRawData ();
outerRawPoly.Add (upRight);
outerRawPoly.Add (downRight);
outerRawPoly.Add (downLeft);
outerRawPoly.Add (upLeft);
Polygon outerPolygon = new Polygon (outerRawPoly);
_mergedPolygon = PolygonOperation.MergeInnerAndOuter (_polygon, outerPolygon);
}
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:33,代码来源:SideWalkExtruder.cs
示例17: CreateGeometries
/// <summary>
/// XAML creation of polygon and polyline geometries are currently not supported, so
/// here they are created in code. Points are generated in the XAML for this sample.
/// </summary>
private void CreateGeometries()
{
var layer = mapView1.Map.Layers.OfType<GraphicsLayer>().First();
int i = 0;
foreach (var g in layer.Graphics)
g.Attributes["Label"] = "Label #" + (++i).ToString();
Polyline line = new Polyline(FromArray(-100,-30, -80,0, -60,-30, -40,0), SpatialReferences.Wgs84);
var graphic = new Graphic(line, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["OutlinedAndDashedSymbol"]);
graphic.Attributes["Label"] = "OutlinedAndDashedSymbol";
layer.Graphics.Add(graphic);
Polygon polygon = new Polygon(FromArray(-30,-30, 0,-30, 0,0, -15,-10, -30,0, -30,-30), SpatialReferences.Wgs84);
graphic = new Graphic(polygon, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["VertexFillSymbol"]);
graphic.Attributes["Label"] = "VertexFillSymbol";
layer.Graphics.Add(graphic);
//CIM symbols can only be created from JSON. The JSON is currently only constructed by publishing services to ArcGIS Server with advanced symbology
string CIMSymbolJson = "{\"type\":\"CIMSymbolReference\",\"symbol\":{\"type\":\"CIMLineSymbol\",\"symbolLayers\":[{\"type\":\"CIMFilledStroke\",\"enable\":true,\"effects\":[{\"type\":\"CIMGeometricEffectArrow\",\"geometricEffectArrowType\":\"Block\",\"primitiveName\":null,\"width\":35}],\"capStyle\":\"Round\",\"pattern\":{\"type\":\"CIMSolidPattern\",\"color\":[0,0,0,255]},\"width\":2,\"lineStyle3D\":\"Strip\",\"alignment\":\"Center\",\"joinStyle\":\"Miter\",\"miterLimit\":10,\"patternFollowsStroke\":true}]},\"symbolName\":null}";
var cimsymbol = Esri.ArcGISRuntime.Symbology.Symbol.FromJson(CIMSymbolJson);
Polyline line2 = new Polyline(FromArray(20, -30, 30, 0, 50, -30, 70, 0), SpatialReferences.Wgs84);
graphic = new Graphic(line2, cimsymbol);
graphic.Attributes["Label"] = "CIM Symbol";
layer.Graphics.Add(graphic);
i = 0;
foreach (var g in layer.Graphics)
{
g.Attributes["SymbolType"] = g.Symbol.GetType().Name;
g.Attributes["ID"] = ++i;
}
}
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:36,代码来源:SymbolsAndLabels.xaml.cs
示例18: SpriteGridBorder
public SpriteGridBorder(Cursor cursor, Camera camera)
{
this.cursor = cursor;
this.camera = camera;
mMainRectangle = Polygon.CreateRectangle(1,1);
ShapeManager.AddPolygon(mMainRectangle);
mCornerHandles = new Polygon[4];
mSideHandles = new Polygon[4];
for (int i = 0; i < 4; i++)
{
mCornerHandles[i] = Polygon.CreateRectangle(.5f, .5f);
mCornerHandles[i].Color = System.Drawing.Color.Yellow;
ShapeManager.AddPolygon(mCornerHandles[i]);
mSideHandles[i] = Polygon.CreateRectangle(.5f, .5f);
mSideHandles[i].Color = System.Drawing.Color.Yellow;
ShapeManager.AddPolygon(mSideHandles[i]);
}
Visible = false;
}
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:25,代码来源:SpriteGridBorder.cs
示例19: PolygonExtruder
protected bool _upCap = false; // bouche t'on le haut de l'extrusion
#endregion Fields
#region Constructors
public PolygonExtruder(Polygon polygon,
Mesh mesh,
float quantity,
bool upCap,
bool bottomCap,
bool inverseNormal)
{
_polygon = polygon;
_mesh = mesh;
_quantity = quantity;
_upCap = upCap;
_bottomCap = bottomCap;
_inverseNormal = inverseNormal;
if (_quantity > 0)
{
_inverseUpAndDown = true;
}
// foreach (Vector3 v in _mesh.vertices)
// {
// Debug.Log (v);
// }
//
// foreach (int i in _mesh.triangles)
// {
// Debug.Log (i);
// }
}
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:35,代码来源:PolygonExtruder.cs
示例20: ReactiveHud
public ReactiveHud()
{
mObjectOverMarker = Polygon.CreateRectangle(1, 1);
mObjectOverMarker.Color = System.Drawing.Color.Red;
#region Create mModelOver
mModelOverHighlight.Visible = false;
ModelManager.AddModel(mModelOverHighlight);
ModelManager.AddToLayer(mModelOverHighlight, SpriteManager.Camera.Layer);
mModelOverHighlight.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Add;
mModelOverHighlight.Red = 90f;
mModelOverHighlight.Green = 90f;
mModelOverHighlight.Blue = 90f;
mSelectedModelHighlight.Visible = false;
ModelManager.AddModel(mSelectedModelHighlight);
ModelManager.AddToLayer(mSelectedModelHighlight, SpriteManager.Camera.Layer);
mSelectedModelHighlight.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Add;
mSelectedModelHighlight.Red = 160;
mSelectedModelHighlight.Green = 160;
mSelectedModelHighlight.Blue = 160;
#endregion
mSpriteFrameIndividualSpriteOutline = new SpriteFrameIndividualSpriteOutline();
mTextWidthHandles = new TextWidthHandles();
ShapeManager.AddPolygon(mObjectOverMarker);
}
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:30,代码来源:ReactiveHud.cs
注:本文中的Polygon类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论