phishman3579/java-algorithms-implementation

XYZpoint from latitude/longitude

hoerup opened this issue · 2 comments

It would be most helpfull if the KdTree.XYZPoint included the math for mapping a latitude/longitude pair into the 3 dimensional XYZpoint.

I think it is something along the line of

point[0] = cos(toRadians(latitude)) * cos(toRadians(longitude));
point[1] = cos(toRadians(latitude)) * sin(toRadians(longitude));
point[2] = sin(toRadians(latitude));

Sorry but it gets a bit more complicated to get true XYZ from lat/lon. see:
http://stackoverflow.com/questions/1185408/converting-from-longitude-latitude-to-cartesian-coordinates

@hoerup I added a new XYZPoint(double lat, double lon) constructor with clarification that it doesn't take curvature of the earth into consideration.