本文整理汇总了C#中Path.AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Path.AddPoint方法的具体用法?C# Path.AddPoint怎么用?C# Path.AddPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.AddPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Point3D firstPoint = new Point3D(1, 2, 3);
Point3D secondPoint = new Point3D(10, 20, 30);
Point3D thirdPoint = new Point3D(40, 50, 60);
double distanceBetweenPoints = Distance3D.CalcDistance(firstPoint, secondPoint);
Console.WriteLine(distanceBetweenPoints);
Path pathOne = new Path();
pathOne.AddPoint(firstPoint);
pathOne.AddPoint(secondPoint);
pathOne.AddPoint(thirdPoint);
Path pathTwo = new Path();
pathTwo.AddPoint(thirdPoint);
pathTwo.AddPoint(firstPoint);
pathTwo.AddPoint(secondPoint);
PathStorage.SavePath(pathOne);
PathStorage.SavePath(pathTwo);
List<Path> pathList = PathStorage.LoadPath();
foreach (var point in pathList)
{
Console.WriteLine("Path loaded!");
}
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("# Testing distance");
Console.WriteLine("Distance: {0}", Distance.Calc(new Point3D(1, 2, 13), Point3D.Zero));
Console.WriteLine("# Testing path");
Point3D firstPoint = new Point3D(1,2,3);
Point3D secondPoint = new Point3D(2,4,2);
Point3D thirdPoint = new Point3D(3,4,5);
Path firstPath = new Path();
firstPath.AddPoint(firstPoint);
firstPath.AddPoint(secondPoint);
firstPath.AddPoint(thirdPoint);
PathStorage.Write(firstPath);
List<Path> pathList = PathStorage.Read();
foreach (var path in pathList)
{
Console.WriteLine("-----Path Start-------");
foreach (var pointers in path.Points)
{
Console.WriteLine("{0}", pointers);
}
Console.WriteLine("-----Path End-------");
}
//Point3D point = new Point3D(1,2,3);
//Console.WriteLine("The coordinates of the point are: ({0},{1},{2})", point.X, point.Y, point.Z);
}
示例3: Main
static void Main(string[] args)
{
Point3D firstPoint = new Point3D(3, 4, 5);
// Testing ToString
Console.WriteLine(firstPoint);
Point3D secondPoint = new Point3D(2, 3, 4);
Point3D thirdPoint = new Point3D(6, 7, 8);
Path firstPath = new Path();
firstPath.AddPoint(firstPoint);
firstPath.AddPoint(secondPoint);
firstPath.AddPoint(thirdPoint);
Path secondPath = new Path();
Point3D fourthPoint = new Point3D(20, 21, 22);
Point3D fifthPoint = new Point3D(23, 24, 25);
Point3D sixthPoint = new Point3D(26, 27, 28);
Point3D seventhPoint = new Point3D(29, 30, 31);
secondPath.AddPoint(fourthPoint);
secondPath.AddPoint(fifthPoint);
secondPath.AddPoint(sixthPoint);
secondPath.AddPoint(seventhPoint);
//double distance = Distance.CalculateDistance(firstPoint, secondPoint);
//Console.WriteLine(distance);
//PathStorage.SaveToFile(firstPath);
//PathStorage.SaveToFile(secondPath);
//PathStorage.LoadFromFile();
}
示例4: Main
static void Main()
{
Point3D point = new Point3D(1, 2, 3);
Point3D pointTwo = new Point3D(3, 4, 5);
//Console.WriteLine(Distance3D.DistanceCalc(point, pointTwo));
//Console.WriteLine(point);
//Console.WriteLine(Point3D.Zero);
Console.WriteLine(Point3D.zero);
Path firstPath = new Path();
firstPath.AddPoint(pointTwo);
firstPath.AddPoint(point);
firstPath.AddPoint(pointTwo);
PathStorage.SavePath(firstPath);
List<Path> pathList = PathStorage.LoadPath();
foreach (var path in pathList)
{
Console.WriteLine("-----Path Start-------");
foreach (var pointers in path.Paths)
{
Console.WriteLine(pointers);
}
Console.WriteLine("-----Path End-------");
}
//foreach (var item in firstPath.Paths)
//{
// Console.WriteLine(item);
//}
}
示例5: Main
static void Main()
{
//Task 1 test
Console.WriteLine("Task 1 test:");
Point3D justPoint = new Point3D();
Console.WriteLine(justPoint.ToString());
justPoint = new Point3D(1, 2, 3);
Console.WriteLine(justPoint.ToString());
Console.WriteLine();
Console.WriteLine("Task 2 test:");
//Task 2 test
justPoint = Point3D.Point0;
Console.WriteLine(justPoint.ToString());
Console.WriteLine();
Console.WriteLine("Task 3 test:");
//Task 3 test
Point3D otherPoint = new Point3D(1, 2, 3);
Console.WriteLine(Space3D.CalculateDistance(justPoint, otherPoint));
Console.WriteLine();
Console.WriteLine("Task 4 test:");
//Task 4 test
Path firstPath = new Path();
firstPath.AddPoint(justPoint);
firstPath.AddPoint(otherPoint);
Path secondPath = new Path();
secondPath.AddPoint(11, 22, 33);
secondPath.AddPoint(77, 88, 99);
secondPath.AddPoint(55, 31, 73);
PathStorage.AddPath(firstPath);
PathStorage.AddPath(secondPath);
Console.WriteLine(PathStorage.PrintAllPaths());
PathStorage.LoadFromFile("3Dpaths.txt");
//PathStorage.SaveToFile("result.txt");
Console.WriteLine(PathStorage.PrintAllPaths());
}
示例6: Main
private static void Main()
{
Point3D point = new Point3D(2, 4, 6);
Point3D pointTwo = new Point3D(8, 5, 3);
Console.WriteLine("First point:");
Console.WriteLine(point.ToString());
Console.WriteLine();
Console.WriteLine("Second point:");
Console.WriteLine(pointTwo.ToString());
Console.WriteLine();
Console.WriteLine("Distance:");
Console.WriteLine(DistanceTwo3DPoints.CalcDistance(point, pointTwo));
Console.WriteLine();
Console.WriteLine("Center of coordinate system:");
Console.WriteLine(Point3D.zero.ToString());
Console.WriteLine();
Console.WriteLine("Writing in file \"Paths.txt\" first point, second point, first point again!");
Path firstPath = new Path();
firstPath.AddPoint(pointTwo);
firstPath.AddPoint(point);
firstPath.AddPoint(pointTwo);
PathStorage.SavePath(firstPath);
Console.WriteLine("File is saved");
Console.WriteLine();
Console.WriteLine("Loading points from file \"Paths.txt\"");
List<Path> pathList = PathStorage.LoadPath();
foreach (var path in pathList)
{
foreach (var pointers in path.Paths)
{
Console.WriteLine(pointers);
}
}
}
示例7: PathStoreTest
public void PathStoreTest()
{
Path pathTest = new Path();
pathTest.AddPoint(new Point3D(1, 1, 1));
pathTest.AddPoint(new Point3D(2, 2, 2));
Assert.AreEqual(2, pathTest.AllPoints.Count);
}
示例8: Main
static void Main()
{
Path path = new Path();
path.AddPoint(new Point3D(1, 2, 4));
path.AddPoint(new Point3D(3, 8, 12));
path.AddPoint(new Point3D(0, -1, 3));
path.AddPoint(new Point3D(-3, 2, 0));
PathStorage.SavePath(path);
PathStorage.LoadPath();
path.PrintPathList();
}
示例9: Main
static void Main()
{
Path path = new Path();
path.AddPoint(new Point(1, 2, 3));
path.AddPoint(Point.CoordStart);
path.AddPoint(new Point(4, 5, 6));
path.AddPoint(new Point(7, 8, 9));
path.AddPoint(new Point(11, 12, 13));
Console.WriteLine(path.ToString());
string filePath = @"..\..\save.txt";
PathStorage.SavePath(filePath, path);
Path pathLoad = PathStorage.LoadPath(filePath);
Console.WriteLine(pathLoad.ToString());
}
示例10: Main
static void Main()
{
Point3D point = new Point3D(1, 2, 3);
Console.WriteLine(point);
Console.WriteLine(Point3D.PointZero);
Console.WriteLine();
var distance = CalculateDistanceBetweenTwoPoints.CalculateDistance(point, Point3D.PointZero);
var path = new Path();
for (int i = 0; i < 10; i++)
{
path.AddPoint(new Point3D() { X = i, Y = i * 2, Z = i + 3 });
}
string filePath = @"../../path.txt";
PathStorage.SavePath(path, filePath);
var fromFile = PathStorage.LoadPath(filePath);
foreach (var p in fromFile)
{
Console.WriteLine(point);
}
}
示例11: Load
// load file
public static Path Load()
{
Path currentPath = new Path();
using(reader)
{
string line = reader.ReadLine();
while (line != null)
{
string[] num = line.Split(' ');
Point3D currentPoint = new Point3D()
{
X = double.Parse(num[0]),
Y = double.Parse(num[1]),
Z = double.Parse(num[2])
};
currentPath.AddPoint();
line = reader.ReadLine();
}
}
return currentPath;
}
示例12: LoadPoint
// Loading the points from file
public static void LoadPoint()
{
StreamReader loadPath = new StreamReader(savedPaths);
Path loadedPath = new Path();
using (loadPath)
{
string line = loadPath.ReadLine();
while (line != null)
{
string[] currentLine = line.Split(new char[] { ' ', ',', '=' }, StringSplitOptions.RemoveEmptyEntries);
Point3D currentPath = new Point3D(int.Parse(currentLine[1]),
int.Parse(currentLine[3]),
int.Parse(currentLine[5]));
loadedPath.AddPoint(currentPath);
line = loadPath.ReadLine();
}
}
// Printing
foreach (var path in loadedPath.PathList)
{
Console.WriteLine(path);
}
}
示例13: LoadPath
public static List<Path> LoadPath()
{
Path loadedPath = new Path();
List<Path> allPaths = new List<Path>();
StreamReader reader = new StreamReader("SavedPaths.txt");
using (reader)
{
string line = reader.ReadLine();
while (line != null)
{
if (line != "-")
{
Point3D point = new Point3D();
string[] pointCoords = line.Split(',');
point.X = int.Parse(pointCoords[0]);
point.Y = int.Parse(pointCoords[1]);
point.Z = int.Parse(pointCoords[2]);
loadedPath.AddPoint(point);
line = reader.ReadLine();
}
else
{
loadedPath.ClearPath();
}
allPaths.Add(loadedPath);
}
}
return allPaths;
}
示例14: LoadPathOfFile
public static Path LoadPathOfFile(string fileName)
{
Path path = new Path();
using (StreamReader sr = new StreamReader(fileName))
{
string input = sr.ReadToEnd();
string pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}";
var reg = new Regex(pattern);
var matchs = reg.Matches(input);
if (matchs.Count <= 0)
{
throw new ApplicationException("Invalid data in file " + fileName);
}
foreach (Match match in matchs)
{
double x = double.Parse(match.Groups[1].Value);
double y = double.Parse(match.Groups[2].Value);
double z = double.Parse(match.Groups[3].Value);
Point p = new Point(x, y, z);
path.AddPoint(p);
}
}
return path;
}
示例15: LoadPath
public static List<Path> LoadPath()
{
Path loadPath = new Path();
List<Path> pathsLoaded = new List<Path>();
using (StreamReader reader = new StreamReader(@"../../PathLoads.txt"))
{
string line = reader.ReadLine();
while (line != null)
{
if (line != "-")
{
Point3D point = new Point3D();
string[] points = line.Split(',');
point.pointX = int.Parse(points[0]);
point.pointY = int.Parse(points[1]);
point.pointZ = int.Parse(points[2]);
loadPath.AddPoint(point);
}
else
{
pathsLoaded.Add(loadPath);
loadPath = new Path();
}
line = reader.ReadLine();
}
}
return pathsLoaded;
}