Calculate position of a point by give position and distance? [duplicate] - google-maps

This question already has answers here:
Calculate second point knowing the starting point and distance
(4 answers)
Closed 9 years ago.
I have to move from a point A( lat, lng ) to point B( lat, lng1 ).
The latitude of the both points is a constant.
I know the distance between them ( in meters ), so i need the formula to find the longitude of point B.
How to find the longitude of point B ?

You have to add (or subtract, depending which point is on West side) the following:
distance_in_meters/Earth_radius_in_meters/cos(lat)*360degree/2/pi
or, alternatively:
distance_in_meters/Earth_equator_length_in_meters/cos(lat)*360degree
This works because the radius of circle of 'slice of Earth' (more precisely, intersection of Earth and plane perpendicular to Earth's axis, passing through point A), is equal to radius of Earth * cos(lat) - simple trigonometry. Then you just use the proportions:
360 degrees - 2pi R cos(lat)
x degree - d meters
x=360d/2/pi/R/cos(lat)
This is all assuming you use degrees.

Related

how do i create a circle Geometry with a radius and co-ordinates of center, using MySQL Spatial Extensions?

I am trying to create a Circle Geometry in MySQL using the co-ordinates of the center and a radius. I searched everywhere...all i could find in the MySQL doc on the site were for polygons. May be i am looking in the wrong place. can anybody help me with an appropriate SQL that can help me create a table that stores this Circle geometry as one of the columns in the table?
Also, i am not even sure if there is a way to do so in MySQL?..The version i am using is MySQL 5.6.
Thanks in advance.
As of MySQL v5.6.1, you can use Buffer(g, d):
Returns a geometry that represents all points whose distance from the geometry value g is less than or equal to a distance of d.
Obviously, in your case g should be the point at the centre of the circle and d should be its radius.
There are two Parts:
A.For given tested points you have to check their relation with given circle.
B.You want to generate points on circumference of given circle.
A.Yes, First of all take the distance between your given point(test Point) and the centre of circle point. Both of these points are defined in Latitude and longitude. Distance formula between two points(x1,y1) and (x2,y2) is distance d= sqrt[ (x2-x1)^2 + (y2-y1)^2 ].
Now,
If this distance is less than radius of circle then your tested point is inside your circle.
If this distance is Greater than radius then tested point is outside the circle.
If this calculated distance is equal to radius of circle then this tested point is on your circle i.e. on the circumference of your circle.
B. In a circle the total angle theta is 360 degree or 2*Pi in radians.
For given Circle whose centre is (x1, y1) and radius is r.
x = x1 + r * cos(theta)
y = y1 + r * sin(theta)
where, theta is running from Zero to 2*Pi and Pi is 3.1415.
Depending upon how you do it. Example: if you wants 10 points on circle, then increment=(2*Pi-Zero)/10.
fist theta is zero, then theta is Zero+increment, then theta is Zero +increment+increment i.e. 2* increment and then zero + 3*increment and then so on. unless you get theta equal to 2*Pi.
For all above thetas calculate x and y. These all x and y coordinate points are on the circumference of the circle.

Given a lat/lng coordinate, calculate the min and max lat/lng values for a 10 km area

Lets say I have a lat lng coordinate and I want to place that at the center of a square that is 10km wide and then get the minimum lat/lng and maximum lat/lng.
Is there an easy way to do this that already exists?
If it doesn't need to be exact, it is pretty easy:
For the latitude, 1 km is 0.009 degrees (follows from the original definition of meter). Since your square is 5 km around the center, you just need to add and subtract 0.045 degrees from the center point.
For the longitude, it is slightly more complicated: Divide the above value with the cosine of the latitude.
In code:
lat_min = lat_center - 0.045;
lat_max = lat_center + 0.045;
long_min = long_center - (0.045 / Math.cos(lat_center*Math.PI/180);
long_max = long_center + (0.045 / Math.cos(lat_center*Math.PI/180);
(Math.PI/180 is needed to convert from degrees to radians).
Beware: Does not work around the poles.
How is the square oriented? Parallel to the equator? If so, then just do a bearing of 45 deg, 5km * sqrt(2) distance from your lat/lon to get the upper right corner. Similar for the bottom left, use a bearing of 225 deg.
See Destination point given distance and bearing from start point at http://www.movable-type.co.uk/scripts/latlong.html

Probability of intersection of two users with horizontal accuracy and vision area

I'm receiving data from GPS and store them in MySQL database. I have following columns:
User ID (int)
Latitude (double)
Longitude (double)
Horizontal Accuracy (double)
Horizontal accuracy is radius around Lat/Long, so my user with equivalent probability can be in any point of this area.
I need to find out probability that two users was intersecting. But I also have vision area, which is 30 meters. If horizontal accuracy would be 0 I could just measure area of intersection of two circles that have radius of 30 meters around lat/long. But in my case that's not possible because horizontal accuracy could be in range from 5 to 3000. Usually it's more than my vision area.
I think I can measure area of intersection of two cones where inner circle of this cone will have radius of horizontal accuracy + 30 meters and outer circle will have radius of horizontal accuracy. But this solution seems to be little bit complicated.
I want to hear some thoughts about that and other possible solution.
I've checked MySQL Spatial extension and as far I can see it can't do such calculations for me.
Thanks.
I worked on just such a problem as you are describing. How I approached it was to convert the Lat/Long (world coordinates) into X/Y (Cartesian coordinates) then I applied the Pythagorean Theorem a^2 + b^2 = c^2 to solve the problem.
First you need to convert the Lat/Long Coordinates.
To get X you Multiply the Radius by the cosine (cos) of the angle (NOTE: this angle has to be expressed as radians).
To get Y you do the same as above but use the sine function (sin).
To convert degrees to radials Multiply the angle by the quantity of PI (Approx. 3.14159...) / 180.
Radians = Angle * (PI / 180);
To solve for the c^2 "C Squared" c = SQRT (a*a + b*b);
For more information on Degrees to Radians: http://www.mathwarehouse.com/trigonometry/radians/convert-degee-to-radians.php
For more information on: Converting Lat/Long to X/Y coordinates: http://www.mathsisfun.com/polar-cartesian-coordinates.html
I usually find the information that I need for this kind of problem by asking a question on ask.com.
All the best.
Allan

how to put two marker at a distance of 500m in google map [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to put two marker at a distance of 500m in google map
I was wondering if anyone know how we can put two markers at a distance of 500 meter, lets say I put first marker at london(50,0) and second marker at some location 500 meter away from london(50,0). how would it happen. I have been looking a lot for it but couldnt find any answer.
Any suggestion would be appreciated
θ is the bearing (in radians, clockwise from north);
d/R is the angular distance (in radians), where d is the distance travelled and R is the earth’s radius
src: http://www.movable-type.co.uk/scripts/latlong.html
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),
Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
Alternative:
The way I do it in OpenLayers is reproject my coordinate to epsg:900913 which is meters, do my calculations, and then convert back to the original projection. This can be accomplished with the pro4.j library: http://trac.osgeo.org/proj/

How do I find the angle between the center of the earth and two latitude-longitude coordinates

I've got two LatLon (latitude-longitude) objects which represent two locations on the surface of the globe. I want to find the angle (in radians) between the center of the earth and these two LatLon objects.
I'm going to use this angle and the radius of the earth to calculate the arc length between the two locations (I figure this will give better precision than using simple Pythagoras, and be faster than computing the great circle distance).
I already have code to give me the Pythagorean distance and the great circle distance.
Using something like this - how to calculate the angle between two vectors
I thought this at first (after some calc on paper) is this Pythagorean thing?
angle_between_radian = sqrt(deltaLA^2 + deltaLO^2)*PI /180
edit: delta = delta>180?360-delta:delta
We working on sphere then above must wrong ^^. But this link may help:Calculate distance, bearing and more between Latitude/Longitude points.