Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2015-06-20 Thread Elias Tarasov
Hello, Christian!
Yes, it helped me very much!
The code you posted works, and i also managed to add external FDM engine to 
calculate and getting data for cessna. Also, i added camera that moved behind 
cessna and now get a nice view of moving aeroplane, which position and 
orientation are defined by external physic engine and attached to geocentric 
coordinates.

Though i still have a problems of how to define the up vector (it seems like 
eye and center are with respect to ECEF, but the up is somehow with respect to 
my screen? ). 

But anyway, now thanks to you help i have a room for experiments.

Thank you!

Cheers,
Elias

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64135#64135





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2015-06-19 Thread Christian Schulte

Hello Elias,

underneath you will find your corrected and commented example (sorry, I 
had to change the lat,lon and models :-) ).


#include 
#include 
#include 
#include 

int main( int argc, char** argv ) {

 osg::ref_ptr traits;
if(!(traits = new osg::GraphicsContext::Traits()).valid()) {
// print
osg::notify(osg::WARN)
<< " - traits = new osg::GraphicsContext::Traits() -> 
invalid : abandon" << std::endl;

// error
return NULL;
}

// set traits properties
traits->screenNum= 0;
traits->x = 40;
traits->y = 40;
traits->width = 1024;
traits->height = 768;
traits->doubleBuffer = true;
traits->windowDecoration = true;
traits->vsync= true;

osg::ref_ptr gc = 
osg::GraphicsContext::createGraphicsContext(traits);


osg::ref_ptr root = new osg::Group;
osg::ref_ptr cessna = osgDB::readNodeFile("EC225.ive");
osg::ref_ptr map = 
osgDB::readNodeFile("y:/Bdt/Marseille/marseillemipmaphard09dds.ive");

osg::ref_ptr camera = new osg::Camera;
osg::Vec3d center, eye, up;

//Getting XYZ position for cessna
osg::Matrix cessnaLocation;
osg::EllipsoidModel ellipsoid;
double x,y,z;
ellipsoid.convertLatLongHeightToXYZ(osg::DegreesToRadians(43.449310), 
osg::DegreesToRadians(5.197525), 200.0, x, y, z);

osg::Vec3 positionForCessna = osg::Vec3d(x,y,z);

//Placing cessna
osg::ref_ptr moveCessna = new 
osg::PositionAttitudeTransform;

moveCessna->setPosition(positionForCessna);
// Calculating attitude (heading north)
double phi = 0.0;
double psi = 0.0;
double theta = 0.0;
osg::Matrixd localToWorld;
osg::Matrixd attitude;
ellipsoid.computeLocalToWorldTransformFromXYZ(osg::DegreesToRadians(43.449310), 
osg::DegreesToRadians(5.197525), 200.0,localToWorld);

attitude.makeRotate(
osg::DegreesToRadians(phi), osg::Y_AXIS,
osg::DegreesToRadians(theta), osg::X_AXIS,
osg::DegreesToRadians(-psi), osg::Z_AXIS);
attitude *= localToWorld;
osg::Quat quat = attitude.getRotate();
moveCessna->setAttitude(quat);

moveCessna->addChild(cessna.get());

osg::ref_ptr viewer = new osgViewer::Viewer();

// Create camera as shallow copy of theo ne of the view
camera = 
dynamic_cast(viewer->getCamera()->clone(osg::CopyOp::SHALLOW_COPY));

camera->setGraphicsContext(gc);
camera->setProjectionMatrixAsPerspective(40.0,1.33,0.1,1.0);
camera->setViewport(new osg::Viewport(0, 0, gc->getTraits()->width, 
gc->getTraits()->height));

camera->setClearColor(osg::Vec4f(0.5f,0.5f,0.0f,0.0f));
camera->setCullingActive(false);

//Getting XYZ position for camera
//Lat Lon are the same, height is 500.0
// The eye : position of the camera
ellipsoid.convertLatLongHeightToXYZ(osg::DegreesToRadians(43.449310), 
osg::DegreesToRadians(5.197525), 500.0, x, y, z);

eye = osg::Vec3d(x,y,z);
// The center : position where you look at (same position a little 
bit underneath...
ellipsoid.convertLatLongHeightToXYZ(osg::DegreesToRadians(43.449310), 
osg::DegreesToRadians(5.197525), 499.9, x, y, z);

center = osg::Vec3d(x,y,z);
// The up : a little more tricky...
// It is the up vector of your screen (ie what is the bottom top 
axis of your screen)

// If you want it to be north up
up = osg::Vec3d( -std::cos(osg::DegreesToRadians(43.449310)) * 
std::sin( osg::DegreesToRadians(5.197525)),
-std::sin(osg::DegreesToRadians(43.449310)) * std::sin( 
osg::DegreesToRadians(5.197525)),

std::cos(osg::DegreesToRadians(5.197525)));
// If you want it to be east up
up = osg::Vec3d( -std::cos(osg::DegreesToRadians(43.449310)),
std::cos(osg::DegreesToRadians(43.449310)),
0.0);
// Now you can set your view matrix
camera->setViewMatrixAsLookAt(eye,center,up);

// Some light for the scene...
osg::ref_ptr light = new osg::Light();
light->setLightNum(0);
light->setDataVariance(osg::Object::DYNAMIC);
osg::ref_ptr lightSource = new osg::LightSource;
lightSource->setLight(light);
lightSource->setLocalStateSetModes(osg::StateAttribute::ON);

// Adding the elements
root->addChild( map.get() );
root->addChild( moveCessna.get() );
root->addChild( lightSource.get());

// Setting up the view
viewer->setCamera( camera.get() );
viewer->setSceneData( root.get() );

osg::ref_ptr stats = new 
osgViewer::StatsHandler();

viewer->addEventHandler(stats.get());

while (!viewer->done())
{
viewer->frame();
}

return 1;
}


Hope it helps out !

Cheers,

Christian

Le 18/06/2015 20:23, Elias Tarasov a écrit :

Hello, Christian!

Again, your comments helped me:)
And again, i can't understand it from the first time.

The root of the problem here is how to move and rotate camera.
And

Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2015-06-18 Thread Elias Tarasov
Hello, Christian!

Again, your comments helped me:)
And again, i can't understand it from the first time.

The root of the problem here is how to move and rotate camera.
And the root of it is how to calculate needed matrices.

So, i looked for it:

1. Looked into general OSG forum.
2. Looked into vpb forum.
3. Stackoverflow.

There are a lot of info but to indicate what kind of problem i have, here is 
the pattern of what i found:

Vec3d eye( 1000.0, 1000.0, 0.0 );
Vec3d center( 0.0, 0.0, 0.0 );
Vec3d up( 0.0, 0.0, 1.0 );
viewer.getCamera()->setViewMatrixAsLookAt( eye, center, up );

Assumption: 
Vectors must be defined with respect to some choosen coordinate frame. 
So, with respect to what frame eye, center, up are defined? 
How can i calculate them?
I presume, that without knowing in what frame vectors are expressed, and how to 
move to that frame from already defined frame (for instance from ECEF), 
variables like Vec3d eye( 1000.0, 1000.0, 0.0 ) are useless. 

Here is the code i changed according to your recomendations.
In the comments, there are at least three issues:
1. How to correctly define rotation?
2. How to define Up vector.
3. How to correctly add moved camera.

int main( int argc, char** argv ) {

osg::ref_ptr root = new osg::Group;
osg::ref_ptr cessna = 
osgDB::readNodeFile("c:/OpenSceneGraph/data/cessnafire.osg");
osg::ref_ptr map = 
osgDB::readNodeFile("c:/Terrain/FromUSGS/output/out.osgb");
osg::ref_ptr camera = new osg::Camera;

//Getting XYZ position for cessna
//-85.4877762 is terrain's center lat
//30.5292506 is terrain's center lon
//100 m - height above terrain we want to place the cessna.
osg::Matrix cessnaLocation;
osg::EllipsoidModel ellipsoid;

ellipsoid.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(-85.4877762),
 osg::DegreesToRadians(30.5292506), 100, cessnaLocation);
osg::Vec3 positionForCessna = cessnaLocation.getTrans(); 

//Placing cessna
osg::ref_ptr moveCessna = new 
osg::PositionAttitudeTransform;
moveCessna->setPosition(positionForCessna);
moveCessna->addChild(cessna.get());

//Getting XYZ position for camera
//Lat Lon are the same, height is 150
osg::Matrix cameraLocation;

ellipsoid.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(-85.4877762),
 osg::DegreesToRadians(30.5292506), 150, cameraLocation);
osg::Vec3 positionForCamera = cameraLocation.getTrans(); 

//Placing camera
osg::ref_ptr moveCamera = new 
osg::PositionAttitudeTransform;
moveCamera->setPosition(positionForCamera);
moveCamera->addChild(camera.get());

//rotation and Y up
//How to setup rotation matrix? with respect to what coordinate frame? 
I presume View frame with respect to ECEF?
osg::Matrix rotation;
rotation.makeRotate(osg::PI_2, osg::Vec3f(1.0, 0.0, 0.0)); //Here we 
rotate around X on the angle pi/2. But rotate around what?

//How to define that matrix and why does it need?
osg::Matrix ToYUP;  //Maybe here we can define a direction around of 
which we make our rotation?

//View = translation * YUP * rotation;
osg::Matrix viewMatrix;
viewMatrix = cameraLocation * ToYUP * rotation;
camera->setViewMatrix(viewMatrix);
 
//How to add moved camera?
root->addChild(camera.get() );
//Or maybe even camera->addChild( root.get() ); ?
root->addChild( moveCessna.get() );
root->addChild( map.get() );

osg::ref_ptr viewer = new osgViewer::Viewer;
viewer->setCamera( camera.get() );
viewer->setSceneData( root.get() );

return viewer->run();
}


Thank you!

Cheers,
Elias

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64123#64123





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2015-06-18 Thread Christian Schulte

Hello Elias,

since you have created your terrain using --geocentric in osgdem the 
terrain is indeed in ECEF coordinates, but there is no reason that your 
cessna model is. Looking at your code, the cessna is at the earth centre 
(0.0,0.0,0.0). If you want to have your cessna on your terrain you 
should load your cessna on a PositionAttitudeTransform and move it 
correctly onto earth surface, using the ellipsoid xyzFromLatLonEle. You 
should try to place your camera also using this and decomposing your 
matrix in order to find where is the problem( 
cam->setViewMatrix(translation * toYup * rotation);)
Also you should use as much as possible the osg functionalities in order 
to use the same math constants (osg::PI_2 instead of _M_PI_2).


Regards,

Christian

Le 17/06/2015 10:39, Elias Tarasov a écrit :

Hello!
It seems i have a problem Deniz had faced previously.
My generated terrain viewed from osgviewer is here:
https://drive.google.com/file/d/0ByDDImhSolf6Szh5YW81MDdqV2M/view?usp=sharing

My gdalinfo for dem file used to generate terrain is here:

Driver: GTiff/GeoTIFF
Files: n30_w086_1arc_v3_conv.tif
n30_w086_1arc_v3_conv.tif.aux.xml
Size is 58, 50
Coordinate System is:
GEOGCS["WGS 84",
 DATUM["WGS_1984",
 SPHEROID["WGS 84",6378137,298.257223563,
 AUTHORITY["EPSG","7030"]],
 AUTHORITY["EPSG","6326"]],
 PRIMEM["Greenwich",0],
 UNIT["degree",0.0174532925199433],
 AUTHORITY["EPSG","4326"]]
Origin = (-85.4959721,30.5362503)
Pixel Size = (0.0002778,-0.0002778)
Metadata:
   AREA_OR_POINT=Point
   DTED_CompilationDate=0002
   DTED_DataEdition=02
   DTED_DigitizingSystem=SRTM
   DTED_HorizontalAccuracy=0013
   DTED_HorizontalDatum=WGS84
   DTED_MaintenanceDate=
   DTED_MaintenanceDescription=
   DTED_MatchMergeDate=
   DTED_MatchMergeVersion=A
   DTED_NimaDesignator=DTED2
   DTED_OriginLatitude=030N
   DTED_OriginLongitude=086W
   DTED_Producer=USCNIMA
   DTED_RelHorizontalAccuracy=NA
   DTED_RelVerticalAccuracy=0004
   DTED_SecurityCode_DSI=U
   DTED_SecurityCode_UHL=U
   DTED_UniqueRef_DSI=H24 084
   DTED_UniqueRef_UHL=H24 084
   DTED_VerticalAccuracy_ACC=0005
   DTED_VerticalAccuracy_UHL=0005
   DTED_VerticalDatum=E96
Image Structure Metadata:
   INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -85.4959722,  30.5362500) ( 85d29'45.50"W, 30d32'10.50"N)
Lower Left  ( -85.4959722,  30.5223611) ( 85d29'45.50"W, 30d31'20.50"N)
Upper Right ( -85.4798611,  30.5362500) ( 85d28'47.50"W, 30d32'10.50"N)
Lower Right ( -85.4798611,  30.5223611) ( 85d28'47.50"W, 30d31'20.50"N)
Center  ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)
Band 1 Block=58x50 Type=Int16, ColorInterp=Gray
   Min=31.000 Max=61.000
   Minimum=31.000, Maximum=61.000, Mean=49.202, StdDev=6.253
   NoData Value=0
   Unit Type: m
   Metadata:
 STATISTICS_MAXIMUM=61
 STATISTICS_MEAN=49.202413793103
 STATISTICS_MINIMUM=31
 STATISTICS_STDDEV=6.2528388891449

Here, center of my terrain is:
Center  ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)

Now i want to place a camera in the center of that terrain to use it from an 
app:

const double M_PI_2 = 1.57079632679489661923;

int main( int argc, char** argv ) {

osg::ref_ptr root = new osg::Group;
osg::ref_ptr cessna = 
osgDB::readNodeFile("c:/OpenSceneGraph/data/cessnafire.osg");
osg::ref_ptr map = 
osgDB::readNodeFile("c:/Terrain/FromUSGS/output/out.osgb");
root->addChild( cessna.get() );
root->addChild( map.get() );

osg::ref_ptr viewer = new osgViewer::Viewer;
viewer->setSceneData( root.get() );

osg::Matrixd vm;
osg::EllipsoidModel ellipsoid;

ellipsoid.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(-85.4877762),
 osg::DegreesToRadians(30.5292506), 100, vm);
vm.invert(vm);

osg::Matrixd rotation2YUp;
rotation2YUp.makeRotate(-M_PI_2, osg::Vec3f(1.0, 0.0, 0.0));
vm *= rotation2YUp;
viewer->getCamera()->setViewMatrix(vm);

return viewer->run();
}

But i don't see anything. Just empty screen.
Well, since terrain had been built in geocentric mode, i think app somehow 
moved terrain and cessna to the correct position in ECEF.
So, i just need to move a camera to that position.

I guess camera's position is wrong, but i don't know how to fix it.

Thank you!

Cheers,
Elias

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64106#64106





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





--
SCHULTE Christian
Ingénieur Recherche
Responsable du Laboratoire de Simulation
ONERA - DCSD/PSEV
Département Commande des Systèmes et Dynamique du Vol
ONERA - Centre de Salon de Provence
BA 701
13661 SALON AIR C

Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2015-06-17 Thread Elias Tarasov
Hello!
It seems i have a problem Deniz had faced previously.
My generated terrain viewed from osgviewer is here:
https://drive.google.com/file/d/0ByDDImhSolf6Szh5YW81MDdqV2M/view?usp=sharing

My gdalinfo for dem file used to generate terrain is here:

Driver: GTiff/GeoTIFF
Files: n30_w086_1arc_v3_conv.tif
   n30_w086_1arc_v3_conv.tif.aux.xml
Size is 58, 50
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (-85.4959721,30.5362503)
Pixel Size = (0.0002778,-0.0002778)
Metadata:
  AREA_OR_POINT=Point
  DTED_CompilationDate=0002
  DTED_DataEdition=02
  DTED_DigitizingSystem=SRTM
  DTED_HorizontalAccuracy=0013
  DTED_HorizontalDatum=WGS84
  DTED_MaintenanceDate=
  DTED_MaintenanceDescription=
  DTED_MatchMergeDate=
  DTED_MatchMergeVersion=A
  DTED_NimaDesignator=DTED2
  DTED_OriginLatitude=030N
  DTED_OriginLongitude=086W
  DTED_Producer=USCNIMA
  DTED_RelHorizontalAccuracy=NA
  DTED_RelVerticalAccuracy=0004
  DTED_SecurityCode_DSI=U
  DTED_SecurityCode_UHL=U
  DTED_UniqueRef_DSI=H24 084
  DTED_UniqueRef_UHL=H24 084
  DTED_VerticalAccuracy_ACC=0005
  DTED_VerticalAccuracy_UHL=0005
  DTED_VerticalDatum=E96
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -85.4959722,  30.5362500) ( 85d29'45.50"W, 30d32'10.50"N)
Lower Left  ( -85.4959722,  30.5223611) ( 85d29'45.50"W, 30d31'20.50"N)
Upper Right ( -85.4798611,  30.5362500) ( 85d28'47.50"W, 30d32'10.50"N)
Lower Right ( -85.4798611,  30.5223611) ( 85d28'47.50"W, 30d31'20.50"N)
Center  ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)
Band 1 Block=58x50 Type=Int16, ColorInterp=Gray
  Min=31.000 Max=61.000
  Minimum=31.000, Maximum=61.000, Mean=49.202, StdDev=6.253
  NoData Value=0
  Unit Type: m
  Metadata:
STATISTICS_MAXIMUM=61
STATISTICS_MEAN=49.202413793103
STATISTICS_MINIMUM=31
STATISTICS_STDDEV=6.2528388891449

Here, center of my terrain is: 
Center  ( -85.4879167,  30.5293056) ( 85d29'16.50"W, 30d31'45.50"N)

Now i want to place a camera in the center of that terrain to use it from an 
app:

const double M_PI_2 = 1.57079632679489661923; 

int main( int argc, char** argv ) {

osg::ref_ptr root = new osg::Group;
osg::ref_ptr cessna = 
osgDB::readNodeFile("c:/OpenSceneGraph/data/cessnafire.osg");
osg::ref_ptr map = 
osgDB::readNodeFile("c:/Terrain/FromUSGS/output/out.osgb");
root->addChild( cessna.get() );
root->addChild( map.get() );

osg::ref_ptr viewer = new osgViewer::Viewer;
viewer->setSceneData( root.get() );

osg::Matrixd vm;
osg::EllipsoidModel ellipsoid;

ellipsoid.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(-85.4877762),
 osg::DegreesToRadians(30.5292506), 100, vm);
vm.invert(vm);

osg::Matrixd rotation2YUp;
rotation2YUp.makeRotate(-M_PI_2, osg::Vec3f(1.0, 0.0, 0.0));
vm *= rotation2YUp;
viewer->getCamera()->setViewMatrix(vm); 

return viewer->run();
}

But i don't see anything. Just empty screen. 
Well, since terrain had been built in geocentric mode, i think app somehow 
moved terrain and cessna to the correct position in ECEF. 
So, i just need to move a camera to that position.

I guess camera's position is wrong, but i don't know how to fix it.

Thank you!

Cheers,
Elias

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64106#64106





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2010-12-28 Thread deniz diktas
1) oops.. you are right! I am not passing them in radians  :-* 
ok I feel a little embarassed as of why I could not think of that  :x 
I guess because I always tend to think in terms of opengl logic: in opengl you 
pass angles in degrees. 

2) I have been able to see the terrain in osgviewer so no problem there..

Thank you so much Shayne, help greatly appreciated :)

best wishes!
deniz

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35203#35203





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2010-12-28 Thread deniz diktas
I am using osg::EllipsoidModel::convertLatLongHeightToXYZ() method to convert 
the coordinates as such:

osg:::EllipsoidModel em;
em.convertLatLongHeightToXYZ(_lat,_long,_alt, x,y,z);

when building the model I used osgdem with the following parameters:
osgdem --geocentric  -d  dted_dir  -o terrain.ive 

dted_dir contains dted files in a certain directory structure defined in 
dted-standard. I checked the validty of the dted with a commercial software, 
the geographic ranges are consistent with osgdem without --geocentric parameter 
(I looked at the contents of the height field of the first subtile:  lod=0) so 
there is no problem with the input file, I am sure of that.

-deniz

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35199#35199





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2010-12-28 Thread deniz diktas
Hi Shayne,

thank you for your reply.
but the problem I am facing is related to the transformation.
But I will keep your suggestion in mind when placing the camera, so thanks 
again :)

The input to the application will be a flight-path given as a list of 
consecutive points in geographic coordinates which have to be transformed to 
geocentric coordinates (I also have orientation information of the airplane) 
but somehow the ellipsoid model fails to do it appropriately. I found another 
tool that transforms the coordinates correctly and I could see the terrain: so 
the problem seems to be solved for now.

But I cannot see how & why osgdem transforms it correctly but the ellipsoid 
model fails to do it. So I still would be glad if someone could tell me what 
the problem is..

deniz

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35197#35197





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [vpb] geographic to geocentric coordinate transformation

2010-12-28 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
Deniz,

If you're using osgdem with the --geocentric flag set, you're building a
geocentric database which is correct.

Here's a code snippet that may help you position your camera on the spheroid
in geocentric space. It sets the view matrix for the camera given the lat,
lon and alt. Roll, pitch, and yaw are zero in this example which means you
will be flying level looking north.

osg::Matrixd vm;
ellipsoid->computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadia
ns(lat),
osg::DegreesToRadians(lon),
alt, vm);
vm.invert(vm);

osg::Matrixd rotation2YUp;
rotation2YUp.makeRotate(-M_PI_2, osg::Vec3f(1.0, 0.0, 0.0));
vm *= rotation2YUp;
view->getCamera()->setViewMatrix(vm);

Hope this helps...
-Shayne

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of deniz
diktas
Sent: Monday, December 27, 2010 3:35 PM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] [vpb] geographic to geocentric coordinate
transformation

Hi,

I am using osgdem to generate a terrain from a set of dted-files in
geocentric coordinates. What I am trying to do next is to navigate the
camera along a path given in geographic coordinates (lat, long, alt).

However, when I try to convert a geographic coordinate (of which I am sure
from where the terrain is visible) to geocentric coordinates, and place my
camera there I do not get to see anything. I transform the coordinates using
osg:EllipsoidModel. 

I also realized that I am getting weird output results from the Ellipsoid
transformation: when I construct a bounding sphere bounding the whole
terrain (built in geocentric coord-sys) and test a point at the center of
the terrain (converted from geographic to geocentric coordinates) to see if
it is included in this bonding sphere, it turns out that this point in
geocentric coordinates is not included inside this bounding sphere - which
is a contradiction.

am I missing something when performing the transformation from geographic to
geocentric coordinates? 
are there other transformations I have to incorporate into my calculation? 
or am I building my terrain database with the wrong parameters ?

I use --geocentric option and I pass the root directory of all dted files. 
I use osg-version 2.9.5 and virtual-planet-builder-v11.

any help is greatly appreciated..

Thank you!

Cheers,
deniz

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35183#35183





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


smime.p7s
Description: S/MIME cryptographic signature
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] [vpb] geographic to geocentric coordinate transformation

2010-12-27 Thread deniz diktas
Hi,

I am using osgdem to generate a terrain from a set of dted-files in geocentric 
coordinates. What I am trying to do next is to navigate the camera along a path 
given in geographic coordinates (lat, long, alt).

However, when I try to convert a geographic coordinate (of which I am sure from 
where the terrain is visible) to geocentric coordinates, and place my camera 
there I do not get to see anything. I transform the coordinates using  
osg:EllipsoidModel. 

I also realized that I am getting weird output results from the Ellipsoid 
transformation: when I construct a bounding sphere bounding the whole terrain 
(built in geocentric coord-sys) and test a point at the center of the terrain 
(converted from geographic to geocentric coordinates) to see if it is included 
in this bonding sphere, it turns out that this point in geocentric coordinates 
is not included inside this bounding sphere - which is a contradiction.

am I missing something when performing the transformation from geographic to 
geocentric coordinates? 
are there other transformations I have to incorporate into my calculation? 
or am I building my terrain database with the wrong parameters ?

I use --geocentric option and I pass the root directory of all dted files. 
I use osg-version 2.9.5 and virtual-planet-builder-v11.

any help is greatly appreciated..

Thank you!

Cheers,
deniz

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35183#35183





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org