- Joined
- Mar 28, 2008
- Messages
- 666
- Reaction score
- 20
- Points
- 33
what's th best way to get the coordinates (lat and lng) in a distance of n meters into the direction of the vessels heading using orbiter api?
Sorry but I'm still confused with all the transformations...
---------- Post added 26-09-15 at 01:16 ---------- Previous post was 25-09-15 at 23:45 ----------
Ok I thing I got it:
But it seems to have strange results...
So can someone say me if it's seems to be corect please?
[Edit]
ok I got a good and easy solution now:
Sorry but I'm still confused with all the transformations...
---------- Post added 26-09-15 at 01:16 ---------- Previous post was 25-09-15 at 23:45 ----------
Ok I thing I got it:
Code:
VECTOR3 loc, glob, horz;
loc.x = 0;
loc.y = 0;
loc.z = distance;
double heading = ORBITERTOOLS::getFlightVectorHeading(v);
//oapiGetHeading(v->GetHandle(),&heading);
double x, z;
//Performce a 2D rotation so that nose is pointing into z direction
x = loc.x * cos(-heading) + loc.z * sin(heading);
z = -loc.x * sin(-heading) - loc.z * cos(heading);
loc.x = x;
loc.y = 0;
loc.z = z;
double lng, lat, rad;
v->HorizonInvRot(loc,horz);
v->Local2Global(horz,glob);
oapiGlobalToEqu(v->GetGravityRef(),glob,&lng,&lat, &rad);
But it seems to have strange results...
So can someone say me if it's seems to be corect please?
[Edit]
ok I got a good and easy solution now:
Code:
void pointRadialDistance(double lat1, double lon1, double bearing, double distance, VESSEL * v, double *lat2, double *lon2)
{
double rdistance = distance / oapiGetSize(v->GetGravityRef());
* lat2 = asin(sin(lat1) * cos(rdistance) + cos(lat1) * sin (rdistance) * cos(bearing) );
* lon2 = lon1 + atan2( sin (bearing) * sin (rdistance) * cos (lat1), cos (rdistance) - sin(lat1) * sin (* lat2 ));
}
Last edited: