I'm struggling with an intersection question.

From my ac position I'll try to catch the first terrain intersection

hit. My ray is defined by azimuth/elevation angles.

What I like to use is the handy get_cart_ground_intersection() method

but I found no example to setup the correct direction vector from

my angles.

The example direction is hitting the surface at the correct longitude

but latitude is about 1km off. I need some geo transformation but

can't find the right example.

Thanks

Wolfgang R.

- Code: Select all
`static int terrain_service_calculate(struct terrain_interrogation_res_t * response)`

{

SGGeod startLoc = SGGeod::fromRadM(response->view_lon_rad, response->view_lat_rad, response->view_altitude_m);

SGGeod hitpos;

SGVec3d SGstart = SGVec3d::fromGeod(startLoc);

SGVec3d direction(0,0,-1);

SGVec3d nearestHit;

bool ret;

SG_LOG(SG_TERRAIN, SG_WARN, "Intersection start [SGGeod] : " << startLoc);

SG_LOG(SG_TERRAIN, SG_WARN, "Intersection start [SGVec3d]: " << SGstart);

SG_LOG(SG_TERRAIN, SG_WARN, "Intersection direction [SGVec3d]: " << direction);

ret = globals->get_scenery()->get_cart_ground_intersection(SGstart, direction, nearestHit);

if(ret)

{

SG_LOG(SG_TERRAIN, SG_WARN, "hit");

SGGeodesy::SGCartToGeod(nearestHit, hitpos);

SG_LOG(SG_TERRAIN, SG_WARN, "Intersection nearestHit [SGVec3d]: " << nearestHit);

SG_LOG(SG_TERRAIN, SG_WARN, "Intersection hitpos [SGGeod] : " << hitpos);

}

else

{

SG_LOG(SG_TERRAIN, SG_WARN, "no hit");

}

...