For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > Mapping Toolbox









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Mapping Toolbox
jgoodell7

2005-04-21, 4:03 pm

Does anyone know how to convert a lat,lon,alt position on a given
map,maplegend scenario into absolute cartesian coordinates (X,Y,Z)?

I am ultimately trying to determine line of sight distances between
two points. The los2().dist calculation is calculated along a sphere
and has no elevation data.
Anton Donner

2005-04-22, 9:00 am

jgoodell7 wrote:
> Does anyone know how to convert a lat,lon,alt position on a given
> map,maplegend scenario into absolute cartesian coordinates (X,Y,Z)?
>
> I am ultimately trying to determine line of sight distances between
> two points. The los2().dist calculation is calculated along a sphere
> and has no elevation data.


function
distance=fct_distance(longitude1,latitud
e1,radius1,longitude2,latitude2,radius2)

%FCT_DISTANCE distance=fct_distance(longitude1,latitud
e1,radius1,
% longitude2,latitude2,radius2)
%
% Calculates distance between two points given in spherical coordinates.

% if abs(latitude1) > pi | abs(latitude2) > pi | ...
% abs(longitude1) > 2 * pi | abs(longitude2) > 2 * pi
% error('fct_distance.m: one of the arguments not in RAD');
% end;

if nargin ~= 6, error('fct_distance.m: wrong number of arguments'); end;

[x1,y1,z1] = sph2cart(longitude1,latitude1,radius1);
[x2,y2,z2] = sph2cart(longitude2,latitude2,radius2);

distance = sqrt((x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2);
Rob Comer

2005-04-25, 8:59 pm

jgoodell7 wrote:

> Does anyone know how to convert a lat,lon,alt position on a given
> map,maplegend scenario into absolute cartesian coordinates (X,Y,Z)?
>
> I am ultimately trying to determine line of sight distances between
> two points. The los2().dist calculation is calculated along a sphere
> and has no elevation data.


It sounds like you need the SLANTRANGE output from the ELEVATION
function. That is the direct, straight-line distance between two
points, given their latitudes, longitudes, and altitudes (elevations
above the sphere or reference ellipsoid).

Rob Comer
Development Project Lead, Mapping Toolbox
The Mathworks, Inc.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com