reset password
Author Message
jzunig20
Posts: 38
Posted 16:39 Feb 25, 2017 |

Must we have the exact distances and exact area provided on distances and sample output ?

the sample output  is 117863.3417

i'm getting an output of 117835.5166 

 

kknaur
Posts: 540
Posted 16:41 Feb 25, 2017 |

It should be as close as possible.

jgarc629
Posts: 76
Posted 17:45 Feb 25, 2017 |

Coordinates 

I was confused with the website provided to find the GPS coordinates, so I used this website: http://www.gps-coordinates.net . Is that a problem? Because I'm getting weird distances such as 17930.159975983333 for Atlanta to Charlotte 

kknaur
Posts: 540
Posted 18:05 Feb 25, 2017 |

Double check your math and be sure you are using the correct units for the coordinates.

KA1997
Posts: 31
Posted 19:34 Feb 25, 2017 |
jgarc629 wrote:

Coordinates 

I was confused with the website provided to find the GPS coordinates, so I used this website: http://www.gps-coordinates.net . Is that a problem? Because I'm getting weird distances such as 17930.159975983333 for Atlanta to Charlotte 

Me too. I'm also getting distances that are way off

kknaur
Posts: 540
Posted 20:00 Feb 25, 2017 |

Common Errors: Using the wrong units with the trig functions, x should be latitude, y should be longitude, make sure order of operations is correct, make sure coordinates are correct.

KA1997
Posts: 31
Posted 20:45 Feb 25, 2017 |

oh. I thought it was the other way around because Latitude is up-down and Longitude is left-right.

jgarc629
Posts: 76
Posted 21:43 Feb 25, 2017 |

I double checked that the latitude is x and longitude is y and made sure I put acos, sin and cos right but am still getting those off answers. Any more suggestions? 

jzunig20
Posts: 38
Posted 00:39 Feb 26, 2017 |

the way i understood it is like this: since we're only looking for coordinates in the U.S all the negative coordinates will be Longitude and all the positive numbers are latitude that's how the website listed on the homework lists the points

(longitude, latitude) . so i took that as (x , y)  and when i compute everything i get the answer 117865.9834 

But if i switched it around like this (latitude, longitude)  understand it as (x, y) again i get a completely different answer 21518.0286

Reading cos and sin as (cos, sin) (x, y) like in trig was how i labeled my points accordingly 

 

sdo8
Posts: 54
Posted 01:05 Feb 26, 2017 |

Make sure your coordinates are 100% correct. x is latitude, y is longitude. 

Compute Math.cos(100);

Now Compute Math.cos(Math.toRadians(100));

Print them both out and look at the results.

I got the exact answer and did exactly what the professor asked without any errors, so if you guys are getting anything wrong you should probably recheck all of your code

Last edited by sdo8 at 01:08 Feb 26, 2017.
jgarc629
Posts: 76
Posted 01:11 Feb 26, 2017 |
jzunig20 wrote:

the way i understood it is like this: since we're only looking for coordinates in the U.S all the negative coordinates will be Longitude and all the positive numbers are latitude that's how the website listed on the homework lists the points

(longitude, latitude) . so i took that as (x , y)  and when i compute everything i get the answer 117865.9834 

But if i switched it around like this (latitude, longitude)  understand it as (x, y) again i get a completely different answer 21518.0286

Reading cos and sin as (cos, sin) (x, y) like in trig was how i labeled my points accordingly 

 

My positive coordinates are my x values and my negatives are my y values but I am getting 17930.159975983333 for the distance between Atlanta to Charlotte when I apply the formula. Are my x and y values (negative, positive) similar to the way you did it? If so, then maybe the problem is the way I wrote down the formula?

jgarc629
Posts: 76
Posted 01:14 Feb 26, 2017 |
sdo8 wrote:

Make sure your coordinates are 100% correct. x is latitude, y is longitude. 

Compute Math.cos(100);

Now Compute Math.cos(Math.toRadians(100));

Print them both out and look at the results.

I got the exact answer and did exactly what the professor asked without any errors, so if you guys are getting anything wrong you should probably recheck all of your code

Wait are we supposed to covert to radians in the code? I did Math.sin(latitude) but am I supposed to do Math.sin(Math.to.Radians(Latitude)) instead? 

jzunig20
Posts: 38
Posted 01:19 Feb 26, 2017 |

yes because the coordinates you get are in degrees and java only takes radian input

my points for atlanta are (longitude(-84.decimals), latitude(33.decimals))

that how i got them in the website, so i said since they're cordinates, (x, y), then (cos, sin) must also be true.

jgarc629
Posts: 76
Posted 01:29 Feb 26, 2017 |

Okay the distances match now, thanks guys that fixed my problem!

bliu14
Posts: 10
Posted 14:34 Feb 26, 2017 |
kknaur wrote:

Common Errors: Using the wrong units with the trig functions, x should be latitude, y should be longitude, make sure order of operations is correct, make sure coordinates are correct.

Quick question: I thought x was longitude and y was latitude due to conventional notation and how longitude is horizontal shift.

Using x as latitude and y as longitude, I get the distance between Atlanta and Charlotte to be 365km, which is very close to what was provided in the question to be correct.

However, swapping them and using x as longitude and y was latitude, I get the distance to 394km, which is the correct anwer by a simple Google search.

Which should I be using? Thanks in advance!

sdo8
Posts: 54
Posted 16:55 Feb 26, 2017 |
bliu14 wrote:
kknaur wrote:

Common Errors: Using the wrong units with the trig functions, x should be latitude, y should be longitude, make sure order of operations is correct, make sure coordinates are correct.

Quick question: I thought x was longitude and y was latitude due to conventional notation and how longitude is horizontal shift.

Using x as latitude and y as longitude, I get the distance between Atlanta and Charlotte to be 365km, which is very close to what was provided in the question to be correct.

However, swapping them and using x as longitude and y was latitude, I get the distance to 394km, which is the correct anwer by a simple Google search.

Which should I be using? Thanks in advance!

line distance, not driving distance. The line distance between Atlanta and Charlotte is 226.47 miles, which is roughly equal to 365 km. HERE

The driving distance(which is what you linked) is equal to 394~ km. When you use x as longitude and y as latitude, it must be a coincidence that they're similar.
If you found the driving distance between Atlanta and Orlando then compare it to the (longitude x, latitude y) calculation, I'm sure you'd get something weird and off.