本文整理汇总了C#中Path.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Clear方法的具体用法?C# Path.Clear怎么用?C# Path.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Point3D a = new Point3D(1, 2, 3);
Console.WriteLine("Point({0})", a); // point A
Point3D b = Point3D.Center;
Console.WriteLine("Point({0}, {1}, {2})", b.X, b.Y, b.Z); // point O
Console.WriteLine("Distance: {0}", Distance.Calculate(a, b)); // Calculate distance
// Path of points
Path path = new Path(new Point3D(1, 1, 1), new Point3D(2, 2, 2));
path.Add(new Point3D(3, 3, 3));
path.Remove(new Point3D(1, 1, 1));
Console.WriteLine("\nPoints in path (total: {0})\n{1}", path.Count, path);
path.Clear();
// Loads new points from the file
path = PathStorage.Load("../../input.txt");
Console.WriteLine("\nPoints in path (total: {0})\n{1}", path.Count, path);
// Saves the points in output file
PathStorage.Save(path, "../../output.txt");
}
示例2: Main
static void Main(string[] args)
{
Point3d pointOne = new Point3d();
pointOne.PointX = 0.5;
pointOne.PointY = 0.5;
pointOne.PointZ = 0.5;
Console.WriteLine(pointOne);
Console.WriteLine(Point3d.ZeroPosition);
Point3d pointTwo = new Point3d(1.5, 1.5, 1.5);
Console.WriteLine(pointTwo);
Console.WriteLine("Distance between");
Console.WriteLine(Distance.DistanceBetween(pointOne, pointTwo));
Path path = new Path();
path.Add(pointOne);
path.Add(pointTwo);
PathStorage.SavePath(path, @"../../Points3d.txt");
path.Clear();
Console.WriteLine();
Console.WriteLine("Path is saved and then cleared");
path = PathStorage.LoadPath(@"../../Points3d.txt");
Console.WriteLine();
Console.WriteLine("After reloading again from file");
Console.WriteLine();
foreach (var item in path.Paths)
{
Console.WriteLine(item);
}
}
示例3: CleanPolygon
//------------------------------------------------------------------------------
public static Path CleanPolygon(Path path,
double distance = 1.415)
{
//distance = proximity in units/pixels below which vertices
//will be stripped. Default ~= sqrt(2) so when adjacent
//vertices have both x & y coords within 1 unit, then
//the second vertex will be stripped.
double distSqrd = (distance * distance);
int highI = path.Count -1;
Path result = new Path(highI + 1);
while (highI > 0 && PointsAreClose(path[highI], path[0], distSqrd)) highI--;
if (highI < 2) return result;
IntPoint pt = path[highI];
int i = 0;
for (;;)
{
while (i < highI && PointsAreClose(pt, path[i], distSqrd)) i+=2;
int i2 = i;
while (i < highI && (PointsAreClose(path[i], path[i + 1], distSqrd) ||
SlopesNearCollinear(pt, path[i], path[i + 1], distSqrd))) i++;
if (i >= highI) break;
else if (i != i2) continue;
pt = path[i++];
result.Add(pt);
}
if (i <= highI) result.Add(path[i]);
i = result.Count;
if (i > 2 && SlopesNearCollinear(result[i - 2], result[i - 1], result[0], distSqrd))
result.RemoveAt(i -1);
if (result.Count < 3) result.Clear();
return result;
}