Results 1 to 17 of 17
Thread: Need Help
 04232012, 08:27 AM #1Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Need Help
Im working on a homework assignment, looking for the great distance formula can someone help me? i try it but got the wrong answer
// GeoLocation.java
public class GeoLocation
{
private double latitude;
private double longitude;
// Construct a GeoLocation given the latitude and longitude.
public GeoLocation(double latitude, double longitude)
{
//
this.latitude = latitude;
this.longitude = longitude;
}
// Return the great circle distance between this location and b.
public double distanceTo(GeoLocation b)
{
// TBD
GeoLocation a = this;
double a1 = Math.sin(Math.toRadians(b.latitude  this.latitude) / 2 ) * Math.sin(Math.toRadians(b.latitude  this.latitude) / 2) +
Math.sin(Math.toRadians(b.longitude  this.longitude) / 2 ) * Math.sin(Math.toRadians(b.longitude  this.longitude) / 2) *
Math.cos(Math.toRadians(b.latitude)) * Math.cos(Math.toRadians(this.latitude));
return a1;
}
// Is this location the same as b?
public boolean equals(GeoLocation b)
{
// TBD
if(b==this)
return true;
if(b==null)
return false;
GeoLocation a = this;
GeoLocation c = this;
return (a.latitude == b.latitude) && (a.longitude == b.longitude) && (b.latitude == c.latitude) && (b.longitude == c.longitude);
}
// Return a String representation of this location.
public String toString()
{
// TBD
return " " + latitude + " " + longitude + " ";
}
// Test driver.
public static void main(String[] args)
{
GeoLocation a = new GeoLocation(48.87, 2.33);
GeoLocation b = new GeoLocation(37.8, 122.4);
GeoLocation c = new GeoLocation(37.8, 122.4);
System.out.println("Should print 48.87, 2.33: " + a);
System.out.println("Should print 5561.369177680733: " +
a.distanceTo(b));
System.out.println("Should print false: " + a.equals(b));
System.out.println("Should print true: " + b.equals(c));
}
}
 04232012, 10:04 AM #2
Re: Need Help
If you're forever cleaning cobwebs, it's time to get rid of the spiders.
 04232012, 07:33 PM #3Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
huh?
 04232012, 08:29 PM #4
Re: Need Help
Click the links. Read the pages.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 04232012, 08:45 PM #5
Re: Need Help
What is the correct equation for computing the great circle distance between two locations?
What does a negative degrees represent? 2.33If you don't understand my response, don't ignore it, ask a question.
 04232012, 09:20 PM #6Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
I dont remember how to do the great circle distance.
I think the equation is Math.acos(Math.sin(x1) * Math.sin(x2) + Math.cos(x1) * Math.cos(x2) * Math.cos(y1  y2));. Not sure if I am writing it right or not in my code. I'm not sure what you mean by negative degree? Are you talking about radians?
 04232012, 09:23 PM #7
Re: Need Help
what you mean by negative degree?
I dont remember how to do the great circle distance.If you don't understand my response, don't ignore it, ask a question.
 04232012, 09:25 PM #8Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
Oh, That's what the output supposed to look like. I got all of the output correct except for the great circle one , which I have no idea how to do and working on it right now. I forgot the great circle distance formula...
 04232012, 09:27 PM #9
Re: Need Help
What are negative degrees?
If you don't understand my response, don't ignore it, ask a question.
 04232012, 09:30 PM #10Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
for Trig functions? If so isn't it Reciprocal? Sin1 , Cos 1 , Tan 1

Re: Need Help
 04232012, 09:38 PM #12
Re: Need Help
If you do not know what negative degrees are, how can you use them correctly?
If you don't understand my response, don't ignore it, ask a question.
 04242012, 03:55 AM #13Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
i don't remember anything about negative degrees. That's the thing
 04242012, 03:58 AM #14
Re: Need Help
Degrees for positions are either: N, S, E or W
 must be one of those.If you don't understand my response, don't ignore it, ask a question.
 04242012, 04:22 AM #15Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Re: Need Help
So negative degrees would be the opposite  N,  S, E, W
 04242012, 04:26 AM #16
Re: Need Help
There are no such thing as negative degrees when designation a location on earth. You use the  to chose either E or W or N or S
What is the 2.33? Is that East or West longitude? Is that in Paris or Brest?Last edited by Norm; 04242012 at 04:29 AM.
If you don't understand my response, don't ignore it, ask a question.
 04242012, 04:31 AM #17Member
 Join Date
 Mar 2012
 Posts
 34
 Rep Power
 0
Bookmarks