File tree 1 file changed +27
-0
lines changed
src/com/jwetherell/algorithms/data_structures
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .jwetherell .algorithms .data_structures ;
2
2
3
+ import static java .lang .Math .cos ;
4
+ import static java .lang .Math .sin ;
5
+
3
6
import java .util .ArrayList ;
4
7
import java .util .Collection ;
5
8
import java .util .Collections ;
@@ -560,18 +563,42 @@ public static class XYZPoint implements Comparable<XYZPoint> {
560
563
protected final double y ;
561
564
protected final double z ;
562
565
566
+ /**
567
+ * z is defaulted to zero.
568
+ *
569
+ * @param x
570
+ * @param y
571
+ */
563
572
public XYZPoint (double x , double y ) {
564
573
this .x = x ;
565
574
this .y = y ;
566
575
this .z = 0 ;
567
576
}
568
577
578
+ /**
579
+ * Default constructor
580
+ *
581
+ * @param x
582
+ * @param y
583
+ * @param z
584
+ */
569
585
public XYZPoint (double x , double y , double z ) {
570
586
this .x = x ;
571
587
this .y = y ;
572
588
this .z = z ;
573
589
}
574
590
591
+ /**
592
+ * Does not use R to calculate x, y, and z. Where R is the approximate radius of earth (e.g. 6371KM).
593
+ * @param latitude
594
+ * @param longitude
595
+ */
596
+ public XYZPoint (Double latitude , Double longitude ) {
597
+ x = cos (Math .toRadians (latitude )) * cos (Math .toRadians (longitude ));
598
+ y = cos (Math .toRadians (latitude )) * sin (Math .toRadians (longitude ));
599
+ z = sin (Math .toRadians (latitude ));
600
+ }
601
+
575
602
public double getX () {
576
603
return x ;
577
604
}
You can’t perform that action at this time.
0 commit comments