class Country { int rank; String name; float birthRate; String lat; String lon; public float x1,x2; public float y1,y2; public float z1,z2; Country(String country_rank, String country_name, String country_birthRate, String country_lat, String country_lon) { rank = Integer.parseInt(country_rank); name = country_name; birthRate = Float.parseFloat(country_birthRate); lat = country_lat; lon = country_lon; } void getRank() { println(this.rank); } void getName() { println(this.name); } float getBirthRate() { //println(this.birthRate); return this.birthRate; } float getLat() { float lat_f = 0f; if(this.lat.endsWith("-N")) { lat_f = Float.parseFloat(this.lat.substring(0,this.lat.length()-2)); } if(this.lat.endsWith("-S")) { lat_f = Float.parseFloat("-"+this.lat.substring(0,this.lat.length()-2)); } //println(lat_f); return lat_f; } float getLon() { float lon_f = 0f; if(this.lon.endsWith("-E")) { lon_f = Float.parseFloat(this.lon.substring(0,this.lon.length()-2)); } if(this.lon.endsWith("-W")) { lon_f = Float.parseFloat("-"+this.lon.substring(0,this.lon.length()-2)); } //println(lon_f); return lon_f; } // Draw lines through lon,lat coordinates void drawLocation() { int line_color = #AAEEAA; float lat = this.getLat(); float lon = this.getLon(); float births = this.getBirthRate(); float corr = 0.12; pushMatrix(); rotateX(radians(90)); rotateZ(radians(181)); if(lat==0) { x1 = r*cos(radians(-lon)); y1 = r*sin(radians(-lon)); z1 = 0; x2 = corr*births*r*cos(radians(-lon)); y2 = corr*births*r*sin(radians(-lon)); z2 = 0; } if(lon==0) { x1 = r*sin(radians(90-lat)); y1 = 0; z1 = r*cos(radians(90-lat)); x2 = corr*births*r*sin(radians(90-lat)); y2 = 0; z2 = corr*births*r*cos(radians(90-lat)); } else { x1 = r*sin(radians(90-lat))*cos(radians(-lon)); y1 = r*sin(radians(90-lat))*sin(radians(-lon)); z1 = r*cos(radians(90-lat)); x2 = corr*births*r*sin(radians(90-lat))*cos(radians(-lon)); y2 = corr*births*r*sin(radians(90-lat))*sin(radians(-lon)); z2 = corr*births*r*cos(radians(90-lat)); } //stroke(line_color); //line(x1,y1,z1,x2,y2,z2); noStroke(); popMatrix(); /* this.getName(); println("x1: "+x1); println("x2: "+x2); println("y1: "+y1); println("y2: "+y2); println("z1: "+z1); println("z2: "+z2); */ } public Vector3D getV_XYZ_forAcceleration() { this.drawLocation(); float factor = 0.0002; Vector3D v = new Vector3D(x1*factor,y1*factor,z1*factor); //println("getV1: " +x1+ ", " +y1+ ", " +z1); return v; } public Vector3D getV_XYZ1() { this.drawLocation(); Vector3D v = new Vector3D(x1,y1,z1); //println("getV1: " +x1+ ", " +y1+ ", " +z1); return v; } public Vector3D getV_XYZ2() { this.drawLocation(); Vector3D v = new Vector3D(x2,y2,z2); //println("getV2: " +x2+ ", " +y2+ ", " +z2); return v; } public Vector3D getV_velocity() { this.drawLocation(); float _x = -x2/100; float _y = -y2/100; float _z = -z2/100; Vector3D v = new Vector3D(_x,_y,_z); //println("getV2: " +x2+ ", " +y2+ ", " +z2); return v; } }