本文整理汇总了C#中Path.AddPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Path.AddPoints方法的具体用法?C# Path.AddPoints怎么用?C# Path.AddPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.AddPoints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Create a new point
var pointA = new Point3D() { X = 1, Y = 2, Z = 3 };
// Call static override ToString()
Console.WriteLine("Base point O:");
Console.WriteLine(Point3D.BasePoint);
Console.WriteLine("---------");
// Calculate distance bw point and basePoint(X=0, Y=0, Z=0)
var distance = Distance.CalculateDistance(pointA, Point3D.BasePoint);
Console.WriteLine("Distance between pointA {0} and pointB {1} \nis {2}", pointA, Point3D.BasePoint, distance);
// Add some points
Path storage = new Path();
for (int i = 1; i < 8; i++)
{
storage.AddPoints(new Point3D() { X = i, Y = i + 3, Z = i * 2 });
}
PathStorage.SavePath(storage, "..//..//Common/sample.txt"); // saving points to file "sample.txt"
Console.WriteLine("Stored points:");
PathStorage.LoadPath("..//..//Common/sample.txt"); // read the points
}
示例2: Main
static void Main()
{
Point3D p = Point3D.StartPoint;
Point3D q = new Point3D(1, 2, 3);
System.Console.WriteLine("Distance: {0:F4}", DistanceCalculator.Calculate(p, q));
Path path = new Path();
path.AddPoints(p, q);
System.Console.WriteLine(path);
PathStorage.Save(path, "firstPath");
System.Console.WriteLine(PathStorage.Load("firstPath"));
System.Console.WriteLine(PathStorage.Load("somePath"));
}
示例3: LoadPath
public static Path LoadPath()
{
StreamReader fileReader = new StreamReader("input.txt");
string path = null;
using (fileReader)
{
path = fileReader.ReadToEnd();
}
if (path != null)
{
Path newPath = new Path();
newPath.AddPoints(path);
return newPath;
}
else
{
throw new NullReferenceException("The file is empty");
}
}
示例4: LoadPath
public static List<Path> LoadPath()
{
List<Path> paths = new List<Path>();
try
{
StreamReader reader = new StreamReader("Storage.txt");
using (reader)
{
string line = reader.ReadLine();
while (line!=null)
{
string[] arr = line.Split(' ');
Path pa = new Path();
foreach (string st in arr)
{
if (st!=string.Empty)
{
int x = (int)(st[0] - 48);
int y = (int)(st[2] - 48);
int z = (int)(st[4] - 48);
pa.AddPoints(new Point3D(x, y, z));
}
}
paths.Add(pa);
line = reader.ReadLine();
}
}
}
catch (IOException io)
{
Console.WriteLine("Error!" + io.Message);
}
catch
{
Console.WriteLine("Unknown error!");
}
return paths;
}
示例5: Main
static void Main()
{
Path newPath = new Path();
string path = "(1 2 3), (3 4 5), (8 9 10)";
newPath.AddPoints(path);
point3D newPoint = new point3D(13, 22, 4);
newPath.AddPoint(newPoint);
PointsStorage.SavePath(newPath);
Path loadedPath = PointsStorage.LoadPath();
foreach (var item in loadedPath.Points)
{
Console.WriteLine(item);
}
}