//method to print a path public void PrintPath(Path path) { foreach (Point3D point3D in path.PointSequence) { Console.WriteLine(point3D.ToString()); } }
public void TestPath() { Path points = new Path(); Point3D point = new Point3D(2, -5, 7); points.Add(point); Assert.AreEqual(2, point.X); Assert.AreEqual(-5, point.Y); Assert.AreEqual(7, point.Z); }
static void Main(string[] args) { Point3D pointA = new Point3D(21,10,15); Point3D pointB = new Point3D(); Console.WriteLine(CalcDistance.CalculateDistanceBetweenTwoPoints(pointA, pointB)); Point3D pointC = Point3D.PointO; Path shortPath = new Path(); shortPath.AddPoint(pointA); shortPath.AddPoint(pointC); PathStorage.PathSave(shortPath); PathStorage.PathLoad(@"../../path.txt"); }
public void TestCalcDistance() { Path points = new Path(); Point3D point1 = new Point3D(0, 0, 0); points.Add(point1); Point3D point2 = new Point3D(1, 1, 0); points.Add(point2); double distance = DistanceFinder.CalcDistance(points[1], points[0]); Assert.AreEqual(1.41, Math.Round(distance, 2)); }
static void Main() { Point3D point1 = new Point3D(0.4, 1.5, 2.34); //creates some new points Point3D point2 = new Point3D(1.6, 2.5, 3.67); Point3D point3 = new Point3D(-2.56, -5, -1.4); Point3D point4 = new Point3D(2.3, 6, -4.2); Console.WriteLine(point1.ToString()); //prints one of the points to test overridden ToString() method //prints the calculated distance between two points Console.WriteLine("The distance between point1 and point4 is: {0:0.00}", Points3DDistance.GetDistance3DPoints(point1, point4)); Path path = new Path(); //creates a new instance path of type (class) Path path.AddPoint(point1); //adds points to the path path.AddPoint(point2); path.AddPoint(point3); path.AddPoint(point4); PathStorage.WritePathToFile(path); //writes the path to a file using the method path.PrintPath(PathStorage.ReadPathFromFile()); //prints the read path from a file, so we can test what had been read }
static void Main() { var p1 = new Point3D(2, 1, 4); Console.WriteLine("Point 1: {0}", p1); Console.WriteLine("Point O: {0}", Point3D.O); Console.WriteLine(); Console.WriteLine("Distance between points 1 and O: {0}", Distance.GetDistance(p1, Point3D.O)); var path1 = new Path(p1, Point3D.O); Console.WriteLine(); Console.WriteLine("Path to save: {0}", path1); PathStorage.Save(path1, "MyPath"); Console.WriteLine(); Console.WriteLine("Loaded path: {0}", PathStorage.Load("MyPath")); }