-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEuclideanTest_MiS.java
More file actions
23 lines (23 loc) · 1006 Bytes
/
EuclideanTest_MiS.java
File metadata and controls
23 lines (23 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class EuclideanTest_MiS{
public static void main(String [] args){
//two dimensional points, hard coded for the purpose of testing
double[] coordinatesp = new double[] {1.0, 2.0};
double[] coordinatesq = new double[] {2.0, 5.0};
EuclideanPoint_MiS pointp = new EuclideanPoint_MiS(coordinatesp);
EuclideanPoint_MiS pointq = new EuclideanPoint_MiS(coordinatesq);
System.out.println(pointp.distanceTo(pointq));
double[] midpoint = pointp.midPoint(pointq);
for(int i = 0; i < midpoint.length; i++){
System.out.print(midpoint[i] + " ");
}
}
}
//Output
//$ java EuclideanTest_MiS
//3.1622776601683795
//1.5 3.5
//Output (when dimensions are not equal)
//$ java EuclideanTest_MiS
//Exception in thread "main" java.lang.RuntimeException: The two points are not in the same dimension
// at EuclideanPoint_MiS.distanceTo(EuclideanPoint_MiS.java:17)
// at EuclideanTest_MiS.main(EuclideanTest_MiS.java:8)