/************************************************************** * Cartographic Projections * Lab 1 * Mark Goadrich * CSC 204 - Spring 2008 **************************************************************/ public class Projection{ // main method to run the program public static void main(String[] args) { // get latitude phi and longitude lambda from the user double phi = Math.toRadians(Double.parseDouble(args[0])); double lambda = Math.toRadians(Double.parseDouble(args[1])); // Step 1: calculate equirectangular projection double x1 = lambda; double y1 = phi; System.out.println("EQUI: x = " + x1 + ", y = " + y1); // Step 2: calculate Mercator projection double x2 = lambda; double y2 = 0.5 * Math.log((1 + Math.sin(phi)) / (1 - Math.sin(phi))); System.out.println("MERC: x = " + x2 + ", y = " + y2); // Step 3: calculate Winkel Tripel projection double alpha = Math.acos( Math.cos(phi) * Math.cos(lambda / 2)); double x3 = (lambda * Math.cos( Math.acos( 2 / Math.PI)) + ((2 * Math.cos(phi) * Math.sin(lambda / 2)) / (Math.sin(alpha) / alpha))) / 2; double y3 = (phi + (Math.sin(phi) / (Math.sin(alpha) / alpha))) / 2; System.out.println("WT: x = " + x3 + ", y = " + y3); // Step 4: calculate distances between projections double em = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); double ew = Math.sqrt(Math.pow(x1 - x3, 2) + Math.pow(y1 - y3, 2)); double mw = Math.sqrt(Math.pow(x3 - x2, 2) + Math.pow(y3 - y2, 2)); System.out.println("EQUI vs MERC: " + em); System.out.println("EQUI vs WT: " + ew); System.out.println("MERC vs WT: " + mw); } }