reset password
Author Message
sidguttula
Posts: 16
Posted 01:12 Apr 22, 2016 |

I try breaking the polygon up into triangles and then use the distance formula to calculate the distance and the perimeter and area of a triangle formulas which adds up all the numbers but I get 172,214.929 as an answer. No matter which method I use I still end up with this result. Can you guys help me on this one?

kknaur
Posts: 540
Posted 09:17 Apr 22, 2016 |

Make sure your values are in the correct unit of measurement...

sidguttula
Posts: 16
Posted 13:05 Apr 23, 2016 |

I used the distance formula and made sure that all those values are changed to radians using the (Math.toRadians(x)) formula. Then i used

the triangle formulas to input my values and to get a final answer. I changed some of my equations and changed units of measurements but I get an answer of

117,796.414 instead of 117,863.342.

304374842
Posts: 56
Posted 13:26 Apr 23, 2016 |

I am also having a lot of problems with this problem.  I thinking I am logically conceptualizing it wrong.  I understand about breaking it into triangles but I am having problem using the GPS coordinates correctly I think.  Any advice about how to look at this logically?

sidguttula
Posts: 16
Posted 13:39 Apr 23, 2016 |

What i did for this problem was that I declared a variable radius to be 6371.01 and asked for user input for the (latitude, longitude) coordinates. Then I made the equation for "side1" which was from city1 to city2, then "side2" which was from city2 to city3, then "side3" which was from city3 to city4, and lastly "side4" which was from city4 back to city1. Then I created another equation which finds the distance from city1 to city3, I declared this variable to be called "sidemiddle", this then cuts the polygon into 2 triangles. Then I used Heron's formula to add up side1, side2 , sidemiddle and divide by 2. Then I did the same thing for side3, side4 , sidemiddle and divide by 2. Then I used the triangle formula to find the areas of the two triangles, then finally I added the two areas and got 117,796.414, not 117,863.342. I don't know what I did wrong here.

Keenan can you help us?

304374842
Posts: 56
Posted 13:57 Apr 23, 2016 |

You used the toRadians formula on the GPS coordinates and plugged those into the distance formula for the sides?

304374842
Posts: 56
Posted 14:13 Apr 23, 2016 |

All right.  I just got it to work.  Make sure you are entering your GPS coordinates exactly as they are in the example.  You are doing it right though.

sidguttula
Posts: 16
Posted 14:24 Apr 23, 2016 |

How did you get it to work?

sidguttula
Posts: 16
Posted 14:25 Apr 23, 2016 |

When I enter the GPS coordinates, I enter them exactly as they are in the example, but I still get a different output. Was there something missing in my program? How did you do it?

304374842
Posts: 56
Posted 14:29 Apr 23, 2016 |

I literally did exactly what you wrote out.  My area formula was initially entered wrong so that was screwing me up but I checked my work off of what you described and it is exactly the same.  Are you entering each GPS as two separate values? Double check that you have the formulas in there correctly and what not (parenthesis, correct x and y values).  Also, the first city as in the example is Charlotte - I was starting with Atlanta.  Not sure if that would mess up the calculations but it could have.

sidguttula
Posts: 16
Posted 14:35 Apr 23, 2016 |

So what i did was that i made a statement which asks for the user input for coordinates of city1 and I made two separate variables, which was x1 then y2 .

Followed by another statement for the coordinates for city2 and then the two variables, x2 and y2, so on and so forth.

Is this method wrong? Are we supposed to put them in one variable instead of two separate ones?

304374842
Posts: 56
Posted 14:37 Apr 23, 2016 |

No it is two.  I am honestly not sure where you are going wrong because my method exactly matched how you described doing it.  Double check that your formulas are in there correctly.  That's the only thing that I can think of that it could be. Hopefully Keenan can give some other suggestions, too. 

 

kknaur
Posts: 540
Posted 16:47 Apr 23, 2016 |

Make extra sure that the coordinates are entered in the correct order. Also make sure your formula is correct. Check for missing sets of ( ).