[osg-users] convert GPS coordinates to local terrain coordinates
Stephane DUGUET
sduguet at eurilogic.fr
Mon Dec 3 06:59:08 PST 2007
Hello,
I'm new on OSG scene.
Here is my issue:
I have a TXP terrain on which I know the local origin coordinates. This
coordinates are:
Longitude : -117.642222
Latitude : 33.094444
I now whant to know the local coordinates (within my TXP terrain) of a
know location (GPS cocordinate):
Longitude: -117.3636264412
Latitude: 33.2940335740
I use ElModel->convertLatLongHeightToXYZ to transform the goedesic
coordinates in caretsian ones. What I need now if to transform the
resulting coordinates according to the origin's location in order to
take care of my offset.
Any idea of how to perform this?
I tried the following:
OriLongitude=-117.642222/*origin*/;
OriLatitude=33.094444/*origin*/;
OriAltitude=0;
ElModel->convertLatLongHeightToXYZ (osg::DegreesToRadians(OriLatitude),
osg::DegreesToRadians(OriLongitude),
OriAltitude,
oriX,
oriY,
oriZ );
ElModel->convertLatLongHeightToXYZ
(osg::DegreesToRadians(33.2940335740),
osg::DegreesToRadians(-117.3636264412),
0,
x,
y,
z );
xl=-sin(OriLongitude)*(x-oriX)+ cos(OriLongitude)*(y-oriY);
yl=-sin(OriLatitude)*cos(OriLongitude)*(x-oriX)
-sin(OriLatitude)*sin(OriLongitude)*(y-oriY)
+cos(OriLatitude)*(z-oriZ);
zl=cos(OriLatitude)*cos(OriLongitude)*(x-oriX)
+cos(OriLatitude)*sin(OriLongitude)*(y-oriY)
+sin(OriLatitude)*(z-oriZ);
But I still cannot have good results.
I have some doubts about the "-" sign applied to the longitude for a
West direction.
Thanks for your help,
Best regards,
Stephane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071203/192e4e11/attachment.html
More information about the osg-users
mailing list