I am creating an application based on geolocation, and I am trying to understand how to implement my application when the user is faced with the direction of a given location (specific long / lat coordinate). I have a mathematical figure, I have a triangle to build.
// UPDATE
So, I realized that this is ...
Below is a method that takes a long / lat value and tries to calculate a triangle that finds a point 700 meters away, and one - left + right. Then he used them to build a triangle. It calculates the correct longitude, but the latitude ends somewhere off the coast of East Africa. (I'm in Ireland!).
public void drawtri(double currlng,double currlat, double bearing){
bearing = (bearing < 0 ? -bearing : bearing);
System.out.println("RUNNING THE DRAW TRIANGLE METHOD!!!!!");
System.out.println("CURRENT LNG" + currlng);
System.out.println("CURRENT LAT" + currlat);
System.out.println("CURRENT BEARING" + bearing);
double distance = 0.7;
double R = 6371.0;
Math.toRadians(currlng);
Math.toRadians(currlat);
Math.toRadians(bearing);
distance = distance/R;
Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+
Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing));
System.out.println("CURRENT ALAT!!: " + Global.Alat);
Global.Alng = currlng + Math.atan2(Math.sin(bearing)*Math.sin(distance)
*Math.cos(currlat), Math.cos(distance)-Math.sin(currlat)*Math.sin(Global.Alat));
Math.toDegrees(Global.Alat);
Math.toDegrees(Global.Alng);
Global.Blat = Global.Alat+ 00.007931;
Global.Blng = Global.Alng;
Global.Clat = Global.Alat - 00.007931;
Global.Clng = Global.Alng;
}
From debugging, I decided the problem was calculating the latitude made here.
Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+
Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing));
, , , . ..
http://www.movable-type.co.uk/scripts/latlong.html
, ...
Radians, .. ..
- , , 700 , ?
,