Google Earth Hacks Forums  

Go Back   Google Earth Hacks Forums > Google Earth > Google Earth Applications > GEwar > Questions/Problems

Questions/Problems If you are having issues with the game or don't understand how a particular feature is supposed to work, you can post your question in here.

 
 
Thread Tools Display Modes
Old 09-21-2005, 08:56 PM   #1
elk-tamer
Member
 
Join Date: Aug 2005
Posts: 93
Default Move Army calculation

What unit of measure is the "Actual distance" value in on the Move Army page?

GEwar - Move Army
Latitude to travel: 1.5438003199939
Longitude to travel: 1.6974503062317
Distance to travel: 2.2944840313542
Actual distance: 1.2444840313542
Approx travel time: 10 minutes
elk-tamer is offline  
Old 09-21-2005, 10:31 PM   #2
Mickey
Administrator
 
Mickey's Avatar
 
Join Date: Jun 2005
Posts: 2,328
Default

Quote:
Originally Posted by elk-tamer
What unit of measure is the "Actual distance" value in on the Move Army page?

GEwar - Move Army
Latitude to travel: 1.5438003199939
Longitude to travel: 1.6974503062317
Distance to travel: 2.2944840313542
Actual distance: 1.2444840313542
Approx travel time: 10 minutes
It's the distance to travel minus a small measure (1.05, I think) so that the unit stays outside the polygon area of the particular city. It's a combination of lat/lon.
Mickey is offline  
Old 09-21-2005, 10:37 PM   #3
elk-tamer
Member
 
Join Date: Aug 2005
Posts: 93
Default

Quote:
Originally Posted by Mickey
It's the distance to travel minus a small measure (1.05, I think) so that the unit stays outside the polygon area of the particular city. It's a combination of lat/lon.
Ah. So it takes as long to travel across longitudes near the equator as it does longitudes near the poles?
elk-tamer is offline  
Old 09-22-2005, 04:54 AM   #4
rasqual
Senior Member
 
rasqual's Avatar
 
Join Date: Jul 2005
Posts: 459
Default

Quote:
Originally Posted by elk-tamer
Ah. So it takes as long to travel across longitudes near the equator as it does longitudes near the poles?
Don't worry about it. Mickey promised great circle navigation by morning. ;-)
rasqual is offline  
Old 09-22-2005, 05:23 AM   #5
Mickey
Administrator
 
Mickey's Avatar
 
Join Date: Jun 2005
Posts: 2,328
Default

Quote:
Originally Posted by elk-tamer
Ah. So it takes as long to travel across longitudes near the equator as it does longitudes near the poles?
Correct.

Quote:
Don't worry about it. Mickey promised great circle navigation by morning. ;-)
Yeah. Any day now...
Mickey is offline  
Old 09-22-2005, 06:07 AM   #6
elk-tamer
Member
 
Join Date: Aug 2005
Posts: 93
Default

Quote:
Originally Posted by Mickey
Yeah. Any day now...
What if we gave you the Great Circle/ Law of Cosines stuff in a method you could just drop in?

Do you have a method that takes: current location, destination and returns new location? All lat, long pairs?

Or is just a SQL statement?
elk-tamer is offline  
Old 09-22-2005, 08:52 PM   #7
elk-tamer
Member
 
Join Date: Aug 2005
Posts: 93
Default Some rough, unchecked, java code

public class GreatCircle {


public GreatCircle() {
}
double r = 6367.0;

public double distance( Point2D start, Point2D finish) {
double x1, y1, x2, y2;
x1 = toRadians( start.getX());
y1 = toRadians( start.getY());
x2 = toRadians( finish.getX());
y2 = toRadians( finish.getY());

double d = r * Math.acos(Math.sin(y1)*Math.sin(y2) +Math.cos(y1)*Math.cos(y2)*Math.cos(x2-x1) );

return d;
}


public double heading( Point2D start, Point2D finish) {
double D = distance( start, finish);
double x1, y1, x2, y2;
x1 = toRadians( start.getX());
y1 = toRadians( start.getY());
x2 = toRadians( finish.getX());
y2 = toRadians( finish.getY());
double heading = Math.acos( (Math.sin(x1) - (Math.sin(y1) * Math.cos(D))) / (Math.cos(y1) * Math.sin(D)));
return heading;
}


double toRadians( double degrees){
return Math.PI*2.0/360.0;
}


Point2D move(Point2D start, Point2D destination, double perTurnDistance){
/*
Intermediate points on a great circle

Suppose the starting point is (lat1,lon1) and the final point (lat2,lon2) and we want the point a fraction f
along the great circle route. f=0 is point 1. f=1 is point 2.
The two points cannot be antipodal ( i.e. lat1+lat2=0 and abs(lon1-lon2)=pi) because then the route is undefined.
The intermediate latitude and longitude is then given by:
**/
double totalDistance = distance(start, destination);
double f = perTurnDistance/totalDistance; //fraction of distance
if( armyName.contains("elk-tamer"))
f *= 100;

double lat1 = start.getY();
double lat2 = destination.getY();
double lon1 = start.getX();
double lon2 = destination.getX();

double A = Math.sin((1-f)*totalDistance)/Math.sin(totalDistance);
double B = Math.sin(f*totalDistance)/Math.sin(totalDistance);
double x = A*Math.cos(lat1)*Math.cos(lon1) + B*Math.cos(lat2)*Math.cos(lon2);
double y = A*Math.cos(lat1)*Math.sin(lon1) + B*Math.cos(lat2)*Math.sin(lon2);
double z = A*Math.sin(lat1) + B*Math.sin(lat2);
double lat = Math.atan2(z,Math.sqrt(x*x+y*y));
double lon = Math.atan2(y,x);

return new Point2D.Double(lon, lat);

}

}
elk-tamer is offline  
Old 09-22-2005, 09:18 PM   #8
Timmetie
Senior Member
 
Join Date: Sep 2005
Posts: 665
Default

Quote:
Originally Posted by elk-tamer
public class GreatCircle {


public GreatCircle() {
}
double r = 6367.0;

public double distance( Point2D start, Point2D finish) {
double x1, y1, x2, y2;
x1 = toRadians( start.getX());
y1 = toRadians( start.getY());
x2 = toRadians( finish.getX());
y2 = toRadians( finish.getY());

double d = r * Math.acos(Math.sin(y1)*Math.sin(y2) +Math.cos(y1)*Math.cos(y2)*Math.cos(x2-x1) );

return d;
}


public double heading( Point2D start, Point2D finish) {
double D = distance( start, finish);
double x1, y1, x2, y2;
x1 = toRadians( start.getX());
y1 = toRadians( start.getY());
x2 = toRadians( finish.getX());
y2 = toRadians( finish.getY());
double heading = Math.acos( (Math.sin(x1) - (Math.sin(y1) * Math.cos(D))) / (Math.cos(y1) * Math.sin(D)));
return heading;
}


double toRadians( double degrees){
return Math.PI*2.0/360.0;
}


Point2D move(Point2D start, Point2D destination, double perTurnDistance){
/*
Intermediate points on a great circle

Suppose the starting point is (lat1,lon1) and the final point (lat2,lon2) and we want the point a fraction f
along the great circle route. f=0 is point 1. f=1 is point 2.
The two points cannot be antipodal ( i.e. lat1+lat2=0 and abs(lon1-lon2)=pi) because then the route is undefined.
The intermediate latitude and longitude is then given by:
**/
double totalDistance = distance(start, destination);
double f = perTurnDistance/totalDistance; //fraction of distance
if( armyName.contains("elk-tamer"))
f *= 100;

double lat1 = start.getY();
double lat2 = destination.getY();
double lon1 = start.getX();
double lon2 = destination.getX();

double A = Math.sin((1-f)*totalDistance)/Math.sin(totalDistance);
double B = Math.sin(f*totalDistance)/Math.sin(totalDistance);
double x = A*Math.cos(lat1)*Math.cos(lon1) + B*Math.cos(lat2)*Math.cos(lon2);
double y = A*Math.cos(lat1)*Math.sin(lon1) + B*Math.cos(lat2)*Math.sin(lon2);
double z = A*Math.sin(lat1) + B*Math.sin(lat2);
double lat = Math.atan2(z,Math.sqrt(x*x+y*y));
double lon = Math.atan2(y,x);

return new Point2D.Double(lon, lat);

}

}
See, elk tamer wants the cotton price raised as well.
Timmetie is offline  
Old 09-22-2005, 09:25 PM   #9
War_Peace
Senior Member
 
Join Date: Aug 2005
Posts: 632
Default

Quote:
Originally Posted by Timmetie
See, elk tamer wants the cotton price raised as well.
and that crying smile "smilie" too Oh my good!...
War_Peace is offline  
Old 09-22-2005, 10:33 PM   #10
rasqual
Senior Member
 
rasqual's Avatar
 
Join Date: Jul 2005
Posts: 459
Default

Quote:
Originally Posted by elk-tamer
The two points cannot be antipodal . . .
Great code, but we shouldn't include comments about W_P's cephalic morphology. ;-)
rasqual is offline  
Old 09-22-2005, 10:35 PM   #11
War_Peace
Senior Member
 
Join Date: Aug 2005
Posts: 632
Default

Quote:
Originally Posted by rasqual
Great code, but we shouldn't include comments about W_P's cephalic morphology. ;-)
Now, what are you talking about??
War_Peace is offline  
Old 09-22-2005, 11:21 PM   #12
elk-tamer
Member
 
Join Date: Aug 2005
Posts: 93
Default

Quote:
Originally Posted by rasqual
Great code, but we shouldn't include comments about W_P's cephalic morphology. ;-)
And like all great code, it is copied from someone else. Even the comments.
elk-tamer is offline  
Old 09-23-2005, 12:05 AM   #13
blitzkrieg
Senior Member
 
blitzkrieg's Avatar
 
Join Date: Sep 2005
Posts: 323
Default

That's how I would've done it........
blitzkrieg is offline  
Old 09-23-2005, 03:44 AM   #14
rasqual
Senior Member
 
rasqual's Avatar
 
Join Date: Jul 2005
Posts: 459
Default

Quote:
Quote:
Quote:
The two points cannot be antipodal . . .
Great code, but we shouldn't include comments about W_P's cephalic morphology. ;-)
Now, what are you talking about??
It was a subtle allusion to your recondite stategic acuity.
rasqual is offline  
Old 09-23-2005, 03:51 AM   #15
rasqual
Senior Member
 
rasqual's Avatar
 
Join Date: Jul 2005
Posts: 459
Default

Suggest moving the thread to alliances/trash talk

;-)
rasqual is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.