mirror of
https://github.com/csharpee/Map-Projections.git
synced 2025-12-11 00:00:15 -05:00
I Deleted a Squiggly Java File
People were complaining.
This commit is contained in:
parent
8d0543cb4a
commit
e52bcdd465
Binary file not shown.
BIN
output/myMap.jpg
BIN
output/myMap.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 43 KiB |
@ -44,91 +44,123 @@ public class MapProjections {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) {
|
||||||
Scanner in = new Scanner(System.in);
|
Scanner in = new Scanner(System.in);
|
||||||
String response;
|
String response;
|
||||||
System.out.println("Welcome to the map configurer. You will be asked for a seiries of values. Leaving the field blank at any time will set values to default.");
|
System.out.println("Welcome to the map configurer. You will be asked for a seiries of values. Leaving the field blank at any time will set values to default.");
|
||||||
|
|
||||||
BufferedImage input;
|
BufferedImage input, output;
|
||||||
int w;
|
int w;
|
||||||
double x2y;
|
double x2y;
|
||||||
double latD, lonD, thtD;
|
double latD, lonD, thtD;
|
||||||
int projection;
|
int projection;
|
||||||
|
|
||||||
System.out.println("First, enter a file name, or choose a preset map style:");
|
while (true) {
|
||||||
for (int i = 0; i < FILE.length; i ++)
|
try {
|
||||||
System.out.println(MAP_TYPES.charAt(i)+" --- "+FILE[i]);
|
System.out.println("First, enter a file name, or choose a preset map style:");
|
||||||
response = in.nextLine();
|
for (int i = 0; i < FILE.length; i ++)
|
||||||
if (response.length() == 0)
|
System.out.println(MAP_TYPES.charAt(i)+" --- "+FILE[i]);
|
||||||
response = "s";
|
response = in.nextLine();
|
||||||
final int index = MAP_TYPES.indexOf(response); // checks for presets
|
if (response.length() == 0)
|
||||||
if (index >= 0) // reads equirectangular from file
|
response = "s";
|
||||||
input = ImageIO.read(new File("input/"+FILE[index]+".jpg"));
|
final int index = MAP_TYPES.indexOf(response); // checks for presets
|
||||||
else if (response.indexOf(".") >= 0)
|
if (index >= 0) // reads equirectangular from file
|
||||||
input = ImageIO.read(new File("input/"+response));
|
input = ImageIO.read(new File("input/"+FILE[index]+".jpg"));
|
||||||
else
|
else if (response.indexOf(".") >= 0)
|
||||||
input = ImageIO.read(new File("input/"+response+".jpg"));
|
input = ImageIO.read(new File("input/"+response));
|
||||||
|
else
|
||||||
System.out.println("And what aspect ratio would you like? (Please enter as a decimal)");
|
input = ImageIO.read(new File("input/"+response+".jpg"));
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
break;
|
||||||
response = "1";
|
} catch (IOException e) {
|
||||||
x2y = Double.parseDouble(response);
|
System.out.println("I don't like that response. Enter something else.");
|
||||||
System.out.println("Pixel width?");
|
}
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
|
||||||
response = "800";
|
|
||||||
w = Integer.parseInt(response);
|
|
||||||
BufferedImage output = new BufferedImage(w,(int)(w/x2y),BufferedImage.TYPE_INT_RGB);
|
|
||||||
|
|
||||||
System.out.println("Would you like to use a preset axis, or custom?");
|
|
||||||
for (int i = 0; i < AXIS_NAMES.length; i ++)
|
|
||||||
System.out.println(AXES.charAt(i)+" --- "+AXIS_NAMES[i]);
|
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
|
||||||
response = "s";
|
|
||||||
int i = AXES.indexOf(response);
|
|
||||||
if (i > 0) { // if it is a preset
|
|
||||||
latD = lats[i-1];
|
|
||||||
lonD = lons[i-1];
|
|
||||||
thtD = thts[i-1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
System.out.println("What is the latitude of your desired axis? [-90, 90]");
|
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
|
||||||
response = "90";
|
|
||||||
latD = Double.parseDouble(response);
|
|
||||||
System.out.println("Longitude? [-180, 180]");
|
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
|
||||||
response = "0";
|
|
||||||
lonD = Double.parseDouble(response);
|
|
||||||
System.out.println("What about your orientation? [-180, 180]");
|
|
||||||
response = in.nextLine();
|
|
||||||
if (response.length() == 0)
|
|
||||||
response = "0";
|
|
||||||
thtD = Double.parseDouble(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Finally, pick a projection:");
|
while (true) {
|
||||||
System.out.println(EQUIRECTANGULAR+" --- Equirectangular");
|
try {
|
||||||
System.out.println(MERCATOR +" --- Mercator");
|
System.out.println("And what aspect ratio would you like? (Please enter as a decimal)");
|
||||||
System.out.println(GALL +" --- Gall Stereographic");
|
response = in.nextLine();
|
||||||
System.out.println(EA_CYLINDER +" --- Cylindrical Equal-Area");
|
if (response.length() == 0)
|
||||||
System.out.println(POLAR +" --- Polar");
|
response = "1";
|
||||||
System.out.println(STEREOGRAPHIC +" --- Stereographic");
|
x2y = Double.parseDouble(response);
|
||||||
System.out.println(EA_AZIMUTH +" --- Azimuthal Equal-Area");
|
System.out.println("Pixel width? I strongly recommend at least 400.");
|
||||||
System.out.println(ORTHOGONAL +" --- Orthogonal");
|
response = in.nextLine();
|
||||||
System.out.println(CONICAL +" --- Lambert Conic");
|
if (response.length() == 0)
|
||||||
System.out.println(QUINCUNCIAL +" --- Peirce Quincuncial");
|
response = "800";
|
||||||
System.out.println(SINUSOIDAL +" --- Sinusoidal");
|
w = Integer.parseInt(response);
|
||||||
System.out.println(LEMONS +" --- BURN LIFE'S HOUSE DOWN");
|
output = new BufferedImage(w,(int)(w/x2y),BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (Error e) {
|
||||||
|
System.out.println("I don't like that response. Enter something else.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response = in.nextLine();
|
while (true) {
|
||||||
if (response.length() == 0)
|
try {
|
||||||
response = Integer.toString(QUINCUNCIAL);
|
System.out.println("Would you like to use a preset axis, or custom?");
|
||||||
projection = Integer.parseInt(response);
|
for (int i = 0; i < AXIS_NAMES.length; i ++)
|
||||||
|
System.out.println(AXES.charAt(i)+" --- "+AXIS_NAMES[i]);
|
||||||
|
response = in.nextLine();
|
||||||
|
if (response.length() == 0)
|
||||||
|
response = "s";
|
||||||
|
int i = AXES.indexOf(response);
|
||||||
|
if (i > 0) { // if it is a preset
|
||||||
|
latD = lats[i-1];
|
||||||
|
lonD = lons[i-1];
|
||||||
|
thtD = thts[i-1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("What is the latitude of your desired axis? [-90, 90]");
|
||||||
|
response = in.nextLine();
|
||||||
|
if (response.length() == 0)
|
||||||
|
response = "90";
|
||||||
|
latD = Double.parseDouble(response);
|
||||||
|
System.out.println("Longitude? [-180, 180]");
|
||||||
|
response = in.nextLine();
|
||||||
|
if (response.length() == 0)
|
||||||
|
response = "0";
|
||||||
|
lonD = Double.parseDouble(response);
|
||||||
|
System.out.println("What about your orientation? [-180, 180]");
|
||||||
|
response = in.nextLine();
|
||||||
|
if (response.length() == 0)
|
||||||
|
response = "0";
|
||||||
|
thtD = Double.parseDouble(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (Error e) {
|
||||||
|
System.out.println("I don't like that. Enter something else.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
System.out.println("Finally, pick a projection:");
|
||||||
|
System.out.println(EQUIRECTANGULAR+" --- Equirectangular");
|
||||||
|
System.out.println(MERCATOR +" --- Mercator");
|
||||||
|
System.out.println(GALL +" --- Gall Stereographic");
|
||||||
|
System.out.println(EA_CYLINDER +" --- Cylindrical Equal-Area");
|
||||||
|
System.out.println(POLAR +" --- Polar");
|
||||||
|
System.out.println(STEREOGRAPHIC +" --- Stereographic");
|
||||||
|
System.out.println(EA_AZIMUTH +" --- Azimuthal Equal-Area");
|
||||||
|
System.out.println(ORTHOGONAL +" --- Orthogonal");
|
||||||
|
System.out.println(CONICAL +" --- Lambert Conic");
|
||||||
|
System.out.println(QUINCUNCIAL +" --- Peirce Quincuncial");
|
||||||
|
System.out.println(SINUSOIDAL +" --- Sinusoidal");
|
||||||
|
System.out.println(LEMONS +" --- BURN LIFE'S HOUSE DOWN");
|
||||||
|
|
||||||
|
response = in.nextLine();
|
||||||
|
if (response.length() == 0)
|
||||||
|
response = Integer.toString(QUINCUNCIAL);
|
||||||
|
projection = Integer.parseInt(response);
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (Error e) {
|
||||||
|
System.out.println("I don't like that response. Enter something else.");
|
||||||
|
}
|
||||||
|
}
|
||||||
System.out.println("Wait...");
|
System.out.println("Wait...");
|
||||||
map(input,output,projection,latD,lonD,thtD);
|
map(input,output,projection,latD,lonD,thtD);
|
||||||
|
|
||||||
@ -228,7 +260,9 @@ public class MapProjections {
|
|||||||
|
|
||||||
public static int lemons(final double lat0, final double lon0, final double orientation,
|
public static int lemons(final double lat0, final double lon0, final double orientation,
|
||||||
final int width, final int height, int x, int y, BufferedImage ref) { // a simple map that is shaped like lemons
|
final int width, final int height, int x, int y, BufferedImage ref) { // a simple map that is shaped like lemons
|
||||||
int lemWdt = width/12; // the pixel width of each lemon
|
int lemWdt;
|
||||||
|
if (width > 12) lemWdt= width/12; // the pixel width of each lemon
|
||||||
|
else lemWdt = width;
|
||||||
|
|
||||||
if (Math.abs(x%lemWdt-lemWdt/2.0) < Math.sin(Math.PI*y/height)*lemWdt/2.0) // if it is inside a sin curve
|
if (Math.abs(x%lemWdt-lemWdt/2.0) < Math.sin(Math.PI*y/height)*lemWdt/2.0) // if it is inside a sin curve
|
||||||
return getColor(lat0,lon0,orientation, y*Math.PI/height - Math.PI/2,
|
return getColor(lat0,lon0,orientation, y*Math.PI/height - Math.PI/2,
|
||||||
|
|||||||
153
src/Vector.java~
153
src/Vector.java~
@ -1,153 +0,0 @@
|
|||||||
public final class Vector {
|
|
||||||
public static final Vector I = new Vector(1,0,0,true);
|
|
||||||
public static final Vector J = new Vector(0,1,0,true);
|
|
||||||
public static final Vector K = new Vector(0,0,1,true);
|
|
||||||
|
|
||||||
|
|
||||||
private double r; // magnitude
|
|
||||||
private double a; // altitude from horizontal
|
|
||||||
private double b; // bearing
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Vector(double newX, double newY, double newZ, boolean cartesian) { // constructs a new vector given horizontal, vertical, and depthual lengths
|
|
||||||
r = Math.sqrt(newX*newX + newY*newY + newZ*newZ);
|
|
||||||
a = Math.asin(newZ/r); // Z is the positive direction
|
|
||||||
b = Math.atan2(newY,newX);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Vector(double newR, double newAlpha, double newBeta) { // constructs a new vector given magnitude, altitude, and bearing
|
|
||||||
r = newR;
|
|
||||||
a = newAlpha;
|
|
||||||
b = newBeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final void setR(double newR) {
|
|
||||||
r = newR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void setA(double newAlpha) {
|
|
||||||
a = newAlpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void setB(double newBeta) {
|
|
||||||
b = newBeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getX() { // magnitude of the width component
|
|
||||||
return r*Math.cos(a)*Math.cos(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getY() { // magnitude of the depth component
|
|
||||||
return r*Math.cos(a)*Math.sin(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getZ() { // magnitude of the height component
|
|
||||||
return r*Math.sin(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getR() { // magnitude
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getA() { // altitude
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double getB() { // bearing
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector negative() { // computes the opposite
|
|
||||||
return new Vector(r, -a, (2*Math.PI+b)%(2*Math.PI));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector plus(Vector that) { // computes sum with that
|
|
||||||
return new Vector(this.getX()+that.getX(), this.getY()+that.getY(), this.getZ()+that.getZ(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector minus(Vector that) { // computes difference with that
|
|
||||||
return new Vector(this.getX()-that.getX(), this.getY()-that.getY(), this.getZ()-that.getZ(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector times(double c) { // computes product with c
|
|
||||||
return new Vector(c*r, a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final double dot(Vector that) { // computes dot product with that
|
|
||||||
return this.getX()*that.getX() + this.getY()*that.getY() + this.getZ()*that.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector cross(Vector that) { // computes cross product with that
|
|
||||||
return new Vector(this.getY()*that.getZ() - this.getZ()*that.getY(),
|
|
||||||
this.getZ()*that.getX() - this.getX()*that.getZ(),
|
|
||||||
this.getX()*that.getY() - this.getY()*that.getX(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final Vector hat() { // makes the magnitude 1
|
|
||||||
return new Vector(1, getA(), getB());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void negate() { // negates
|
|
||||||
a = -a;
|
|
||||||
b = (2*Math.PI+b)%(2*Math.PI);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void plusEquals(Vector that) { // adds that
|
|
||||||
Vector sum = this.plus(that);
|
|
||||||
r = sum.getR();
|
|
||||||
a = sum.getA();
|
|
||||||
b = sum.getB();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void minusEquals(Vector that) { // subtracts that
|
|
||||||
Vector dif = this.minus(that);
|
|
||||||
r = dif.getR();
|
|
||||||
a = dif.getA();
|
|
||||||
b = dif.getB();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void timesEquals(double c) { // multiplies by c
|
|
||||||
r *= c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final void crossEquals(Vector that) { // becomes cross product with that
|
|
||||||
Vector txt = this.cross(that);
|
|
||||||
r = txt.getR();
|
|
||||||
a = txt.getA();
|
|
||||||
b = txt.getB();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final String toString() {
|
|
||||||
return "<"+getX()+", "+getY()+", "+getZ()+">";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final String toStringPolar() {
|
|
||||||
return "("+getR()+", "+getA()+", "+getB()+")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user