public static Paths3D LoadPathFromFile(string fileName) { Paths3D path = new Paths3D(); using (StreamReader reader = new StreamReader(fileName)) { string input = input = reader.ReadToEnd(); string pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}"; Regex regex = new Regex(pattern); var matchs = regex.Matches(input); 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); Point3D point = new Point3D(x, y, z); path.AddPoint(point); } return(path); } }
static void Main() { //Point3D Test Point3D pointA = new Point3D(5, 5, 5); var startingPoint = Point3D.StartingPoint; Console.WriteLine("Starting {0}", startingPoint); Console.WriteLine("Current {0}", pointA); Console.WriteLine(); //Distance Calculator Test var pointB = new Point3D(2, 2, 2); Console.WriteLine("The distance between {0} and {1} = {2:F4}", pointA, pointB, DistanceCalculator.CalculateTheDistance(pointA, pointB)); Console.WriteLine(); //Paths3D Test var pointC = new Point3D(1, 3, 1); var points = new List <Point3D>() { pointA, pointB, pointC }; var path = new Paths3D(points); Console.WriteLine(path); }
public static void SavePathInFile(string fileName, Paths3D path) { using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(path); } }
public static Paths3D LoadPathFromFile(string fileName) { Paths3D path = new Paths3D(); using (StreamReader reader = new StreamReader(fileName)) { string input = input = reader.ReadToEnd(); string pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}"; Regex regex = new Regex(pattern); var matchs = regex.Matches(input); 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); Point3D point = new Point3D(x, y, z); path.AddPoint(point); } return path; } }
static void Main() { Point3D p1 = new Point3D(1, 2, 3); Point3D p2 = new Point3D(2, 3, 4); Point3D p3 = new Point3D(3, 4, 5); Paths3D myPath = new Paths3D(); myPath.AddPoint(p1); myPath.AddPoint(p2); myPath.AddPoint(p3); }
static void Main() { //Point3D Test Point3D pointA = new Point3D(5, 5, 5); var startingPoint = Point3D.StartingPoint; Console.WriteLine("Starting {0}",startingPoint); Console.WriteLine("Current {0}",pointA); Console.WriteLine(); //Distance Calculator Test var pointB = new Point3D(2,2,2); Console.WriteLine("The distance between {0} and {1} = {2:F4}", pointA, pointB, DistanceCalculator.CalculateTheDistance(pointA,pointB)); Console.WriteLine(); //Paths3D Test var pointC = new Point3D(1, 3, 1); var points = new List<Point3D>() {pointA, pointB, pointC }; var path = new Paths3D(points); Console.WriteLine(path); }