matlab - Solving non linear equations related to distance -


i want solve set of non linear equations in matlab. mean lets have 2 points defined (lat1,lon1) , (lat2,lon2). want find point lat3,lon3 such @ distance of 20km both of points. given intersection of circles radius 20km drawn points (lat1,lon1) , (lat2,lon2) center.

however, bit confused how solve equation.

i have function calculate distance between 2 points in matlab

function [ distance ] = calculatedistance( latitude1,longitude1,latitude2,longitude2 ) radius = 6371; dlat = degtorad(latitude2-latitude1); dlon = degtorad(longitude2-longitude1); = sin(dlat/2) * sin(dlat/2) + cos(degtorad(latitude1)) * cos(degtorad(latitude2)) * sin(dlon/2) * sin(dlon/2); c = 2 * atan2(sqrt(a), sqrt(1-a)); distance = radius * c; end 

and trying use solve function of matlab available @ http://www.mathworks.com/help/toolbox/symbolic/solve.html

however when define

syms lat3 lon3 

and try equations pass solve function throws error atan2 accepts arguments of type sym. how can on this?

if have solve particular question, not need equation solving functions of matlab. can use pythagoras' formula:

if points (0,0) , (1,0) , radius x, 2 points x away both (0,0) , (1,0) are

(0.5, sqrt (x^2 - 0.25) ) , (0.5, - sqrt (x^2 - 0.25)).

now if points (a,b) , (c,d), distance of 2 points is

dist = sqrt ( (c-a)^2 + (d-b)^2 ).

ok, take coordinate system origin (a,b) , unit dist , horizontal axis goes through (c,d). in coordinate system, points in question are

(0.5, +/- sqrt ( (r/dist)^2 - 0.25 ) ).

now, original coordinate system, have multiply dist, getting

(0.5 * dist, +/- sqrt ( r^2 - 0.25 * dist^2 ) ),

then rotate matrix rotating (dist, 0) (c-a, d-b), is

cos alpha   -sin alpha sin alpha   cos alpha 

where alpha = arccos ( (d-b) / dist), i.e. matrix

(d-b) / dist   -(c-a) / dist (c-a) / dist    (d-b) / dist 

which gives

(0.5 (d-b) -/+ (c-a) sqrt (r^2 / dist^2 - 0.25), 0.5 (c-a) +/- (d-b) sqrt (r^2 / dist^2 - 0.25)

and add (a,b), yielding

(a + 0.5 (d-b) -/+ (c-a) sqrt (r^2 /dist^2 - 0.25), b + 0.5 (c-a) +/- (d-b) sqrt (r^2 /dist^2 - 0.25) )

these points looking for. have made mistake somewhere, direction should clear, hope.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -