static double CalcPoints(Point3D pointOne, Point3D pointTwo) { double distance = 0; distance = Math.Sqrt(Math.Pow(pointOne.X - pointTwo.X, 2) + Math.Pow(pointOne.Y - pointTwo.Y, 2) + Math.Pow(pointOne.Z - pointTwo.Z, 2)); return distance; }
public void AddPoint(Point3D point) { Points.Add(point); }
//calculate distance using the pythagorean dependencies public static double CalculateDistance(Point3D point1, Point3D point2) { return Math.Sqrt((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y) + (point1.z - point2.z) * (point1.z - point2.z)); }
static double CalculateDistance(Point3D firstPoint, Point3D secondPoint) { // Here we are using direct calculation instead of Math.Pow because it computes faster. return Math.Sqrt((firstPoint.X-secondPoint.X)*(firstPoint.X-secondPoint.X)+(firstPoint.Y-secondPoint.Y)*(firstPoint.Y-secondPoint.Y)+(firstPoint.Z-secondPoint.Z)*(firstPoint.Z-secondPoint.Z)); }