I
I
ivandzemianchyk2015-06-13 15:06:26
Geometry
ivandzemianchyk, 2015-06-13 15:06:26

How to construct the problem of finding the optimal point?

There are 3 points with longitude and latitude coordinates. There is a circle radius around these points. It is necessary to build a model to find a point that can be found at the point where the three circles are covered.
%[longtitude, Latitude ]
A = [17 24 18; 53 50 58];
B = [17 27 21; 53 56 45];
C = [17 43 24; 53 52 40];
radius = [6.53; 9.51; 14.76];
I tried to solve it this way:

[x_opt fval exitflag output] = fminunc(@optFunction, [30; 30])

where optFunction.m is
function f = optFunction(x)

%[dlugosc/ longtitude, szerokosc/Latitude ]
A = [17 24 18; 53 50 58];
B = [17 27 21; 53 56 45];
C = [17 43 24; 53 52 40];
d = [6.53; 9.51; 14.76];

calcVec = [1 1/60 1/3600];

latlon1 = [ A(2,:)*calcVec' A(1,:)*calcVec'];
latlon2 = [ B(2,:)*calcVec' B(1,:)*calcVec'];
latlon3 = [ C(2,:)*calcVec' C(1,:)*calcVec'];

f = (r1(latlon1, x, d))^2 + (r2(latlon2, x, d))^2 + (r3(latlon3, x, d))^2;
end

    function r1x = r1(latlon1, latlonx, d)
        r1x = (lldistkm(latlon1, latlonx))^2 - (d(1))^2;
    end

    function r2x = r2(latlon2, latlonx, d)
        r2x = (lldistkm(latlon2, latlonx))^2 - (d(2))^2;
    end
    
    function r3x = r3(latlon3, latlonx, d)
        r3x = (lldistkm(latlon3, latlonx))^2 - (d(3))^2;
    end

and the file lldistkm.m is a downloaded file from www.mathworks.com/matlabcentral/fileexchange/38812...
and its code is:
function [d1km d2km]=lldistkm(latlon1,latlon2)
% format: [d1km d2km]=lldistkm(latlon1,latlon2)
% Distance:
% d1km: distance in km based on Haversine formula
% (Haversine: http://en.wikipedia.org/wiki/Haversine_formula)
% d2km: distance in km based on Pythagoras’ theorem
% (see: http://en.wikipedia.org/wiki/Pythagorean_theorem)
% After:
% http://www.movable-type.co.uk/scripts/latlong.html
%
% --Inputs:
%   latlon1: latlon of origin point [lat lon]
%   latlon2: latlon of destination point [lat lon]
%
% --Outputs:
%   d1km: distance calculated by Haversine formula
%   d2km: distance calculated based on Pythagoran theorem
%
% --Example 1, short distance:
%   latlon1=[-43 172];
%   latlon2=[-44  171];
%   [d1km d2km]=distance(latlon1,latlon2)
%   d1km =
%           137.365669065197 (km)
%   d2km =
%           137.368179013869 (km)
%   %d1km approximately equal to d2km
%
% --Example 2, longer distance:
%   latlon1=[-43 172];
%   latlon2=[20  -108];
%   [d1km d2km]=distance(latlon1,latlon2)
%   d1km =
%           10734.8931427602 (km)
%   d2km =
%           31303.4535270825 (km)
%   d1km is significantly different from d2km (d2km is not able to work
%   for longer distances).
%
% First version: 15 Jan 2012
% Updated: 17 June 2012
%--------------------------------------------------------------------------

radius=6371;
lat1=latlon1(1)*pi/180;
lat2=latlon2(1)*pi/180;
lon1=latlon1(2)*pi/180;
lon2=latlon2(2)*pi/180;
deltaLat=lat2-lat1;
deltaLon=lon2-lon1;
a=sin((deltaLat)/2)^2 + cos(lat1)*cos(lat2) * sin(deltaLon/2)^2;
c=2*atan2(sqrt(a),sqrt(1-a));
d1km=radius*c;    %Haversine distance

x=deltaLon*cos((lat1+lat2)/2);
y=deltaLat;
d2km=radius*sqrt(x*x + y*y); %Pythagoran distance

end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mrrl, 2015-06-16
@Mrl

I would solve it as a point of intersection of three spheres in space with subsequent projection onto the ABC plane, and then onto the Earth's surface:
Let the radii be RA, RB, RC, and the distances between the points be AB,AC,BC.
Calculate the values
​​u=((RA^2-RB^2)/AB^2+1)/2
v=((RA^2-RC^2)/AC^2+1)/2
These will be the projections of the intersection point of the spheres into segments AB and AC, expressed in the lengths of these segments.
Let a be the angle at the vertex A of the triangle ABC (we will find it using the cosine theorem).
If Q is the projection of the intersection point of the spheres onto the plane ABC, then
AQ=(AB*(uv*cos(a))+AC*(vu*cos(a)))/(sin(a)^2),
i.e. . Q=A*(1-(u+v)/(1+cos(a)))+B*((uv*cos(a))/sin(a)^2)+C*((vu*cos (a))/sin(a)^2),
where A,B,C - three-dimensional coordinates of points. Then Q*(R/|OQ|) is the desired point (|OQ| is the distance from Q to the center of the Earth, R is the radius of the Earth).
Formulas not checked :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question