public void ZeroDistanceTest() { Point3D firstPoint = new Point3D(2, 2, 2); Point3D secondPoint = new Point3D(2, 2, 2); Assert.AreEqual(0, Distance3D.Distance(firstPoint, secondPoint)); }
public void DistanceTest() { Point3D firstPoint = new Point3D(3, 4, 2); Point3D secondPoint = new Point3D(5, 2, 1); Assert.AreEqual(3, Distance3D.Distance(firstPoint, secondPoint)); }
// Method requiring two points as input to find the distance between them public static double Distance(Point3D firstPoint, Point3D secondPoint) { double xDistance = (firstPoint.XCoord - secondPoint.XCoord); double yDistance = (firstPoint.YCoord - secondPoint.YCoord); double zDistance = (firstPoint.ZCoord - secondPoint.ZCoord); double distance = Math.Sqrt(xDistance * xDistance + yDistance * yDistance + zDistance * zDistance); return distance; }
// Method for clearing the path public void Clear(Point3D point) { this.pathPoints.Clear(); }
// Method for adding a point to the path public void Add(Point3D point) { this.pathPoints.Add(point); }
// Method requiring one point as input to find the distance between it and point O (0, 0, 0) public static double Distance(Point3D point) { double distance = Math.Sqrt(point.XCoord * point.XCoord + point.YCoord * point.YCoord + point.ZCoord * point.ZCoord); return distance; }
public void TestPointZero() { Point3D point = new Point3D(0, 0, 0); Assert.AreEqual(point, Point3D.Zero); }
public void DistanceFromZeroTest() { Point3D point = new Point3D(1, 2, 2); Assert.AreEqual(3, Distance3D.Distance(point)); }