Geodetic to cartesian coordinates
Afficher commentaires plus anciens
Hi,
I work with GPS units for footballers and I want to convert geodetic coordinates to cartesian coordinates. I have tried using Matlab's geodetic2enu function but the coordinates come out funny. As an example, here are the latitude and longitude values of each corner of a football pitch, converted using Matlab's " geodetic2enu" function.
Pitch_dimensions=[50.707025 4.206677;50.70665 4.205923;50.706062 4.207913;50.705676 4.207147];
[xEast, yNorth, zUp] = geodetic2enu(Pitch_dimensions(:,1),Pitch_dimensions(:,2),0,50.70665,4.205923, 0,wgs84Ellipsoid);
Pitch_dimensions=[xEast yNorth];
scatter(Pitch_dimensions(:, 1), Pitch_dimensions(:, 2));
The scatter plot should turn out to be a basic rectangle, but it shows a slanted pitch instead

.
I just want to display a simple football field with a left-to-right direction of play, and the origin (0,0) to be the bottom-left corner flag of the pitch. Is there a rotation matrix that I need to use? Any help is appreciated.
Thank you.
Best regards,
Ben
Réponse acceptée
Plus de réponses (1)
Meysam Mahooti
le 1 Nov 2019
1 vote
%--------------------------------------------------------------------------
%
% Position: Position vector (r [m]) from geodetic coordinates
% (Longitude [rad], latitude [rad], altitude [m])
%
% Last modified: 2018/01/27 M. Mahooti
%
%--------------------------------------------------------------------------
function r = Position(lon, lat, h)
R_equ = 6378.137e3; % Earth's radius [m]; WGS-84
f = 1/298.257223563; % Flattening; WGS-84
e2 = f*(2-f); % Square of eccentricity
CosLat = cos(lat); % (Co)sine of geodetic latitude
SinLat = sin(lat);
% Position vector
N = R_equ/sqrt(1-e2*SinLat*SinLat);
r(1) = (N+h)*CosLat*cos(lon);
r(2) = (N+h)*CosLat*sin(lon);
r(3) = ((1-e2)*N+h)*SinLat;
1 commentaire
Benedict Low
le 1 Nov 2019
Catégories
En savoir plus sur Lengths and Angles dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

