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,17 +44,19 @@ public class MapProjections {
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
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.");
|
||||
|
||||
BufferedImage input;
|
||||
BufferedImage input, output;
|
||||
int w;
|
||||
double x2y;
|
||||
double latD, lonD, thtD;
|
||||
int projection;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
System.out.println("First, enter a file name, or choose a preset map style:");
|
||||
for (int i = 0; i < FILE.length; i ++)
|
||||
System.out.println(MAP_TYPES.charAt(i)+" --- "+FILE[i]);
|
||||
@ -69,18 +71,34 @@ public class MapProjections {
|
||||
else
|
||||
input = ImageIO.read(new File("input/"+response+".jpg"));
|
||||
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
System.out.println("I don't like that response. Enter something else.");
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
System.out.println("And what aspect ratio would you like? (Please enter as a decimal)");
|
||||
response = in.nextLine();
|
||||
if (response.length() == 0)
|
||||
response = "1";
|
||||
x2y = Double.parseDouble(response);
|
||||
System.out.println("Pixel width?");
|
||||
System.out.println("Pixel width? I strongly recommend at least 400.");
|
||||
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);
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
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]);
|
||||
@ -111,6 +129,14 @@ public class MapProjections {
|
||||
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");
|
||||
@ -129,6 +155,12 @@ public class MapProjections {
|
||||
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...");
|
||||
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,
|
||||
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
|
||||
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