Jump to content

[LUA] Export waypoints


Doug

Recommended Posts

Hi !

 

I'm working to build a complete navigation system.

I have a problem with the x,y,z position of waypoints.

How have the position of my aircraft with the same x,y,z system ?

I only have a function wich give me LatLongAlt but no x,y,z.

 

LoGetRoute()  -- (args - 0,results = table)
get_route_result =
{
   goto_point, -- next waypoint
   route       -- all waypoints of route (or approach route if arrival or landing)
}
waypoint_table =
{
   this_point_num,        -- number of point ( >= 0)
   world_point = {x,y,z}, -- world position in meters
   speed_req,             -- speed at point m/s 
   estimated_time,        -- sec
   next_point_num,           -- if -1 that's the end of route
}

Regards

LOTATC .NET // LOVICA .NET // 3rd Wing

Link to comment
Share on other sites

  • ED Team
Hi !

 

I'm working to build a complete navigation system.

I have a problem with the x,y,z position of waypoints.

How have the position of my aircraft with the same x,y,z system ?

I only have a function wich give me LatLongAlt but no x,y,z.

 

LoGetRoute()  -- (args - 0,results = table)
get_route_result =
{
   goto_point, -- next waypoint
   route       -- all waypoints of route (or approach route if arrival or landing)
}
waypoint_table =
{
   this_point_num,        -- number of point ( >= 0)
   world_point = {x,y,z}, -- world position in meters
   speed_req,             -- speed at point m/s 
   estimated_time,        -- sec
   next_point_num,           -- if -1 that's the end of route
}

 

Regards

 

sorry it's our mistake , ( i forgot to add this routines to 1.12 export , they are will be available in BS)

 

but try to use this code


float MapCoords::zeroX = 5000000.f; 
float MapCoords::zeroZ = 6600000.f;
// data for recalculation

float MapCoords::centerX = 11465000.f - zeroX; // circle center
float MapCoords::centerZ =  6500000.f - zeroZ;

float MapCoords::pnSxW_X = 4468608.57f - zeroX; // point 40dgN : 24dgE
float MapCoords::pnSxW_Z = 5730893.72f - zeroZ;

float MapCoords::pnNxW_X = 5357858.31f - zeroX; // point 48dgN : 24dgE
float MapCoords::pnNxW_Z = 5828649.53f - zeroZ;

float MapCoords::pnSxE_X = 4468608.57f - zeroX; // point 40dgN : 42dgE
float MapCoords::pnSxE_Z = 7269106.20f - zeroZ;

float MapCoords::pnNxE_X = 5357858.31f - zeroX; // point 48dgN : 42dgE
float MapCoords::pnNxE_Z = 7171350.00f - zeroZ;

// 
double MapCoords::lenNorth = sqrt((pnNxW_X-centerX)*(pnNxW_X-centerX) + (pnNxW_Z-centerZ)*(pnNxW_Z-centerZ));
double MapCoords::lenSouth = sqrt((pnSxW_X-centerX)*(pnSxW_X-centerX) + (pnSxW_Z-centerZ)*(pnSxW_Z-centerZ));
double MapCoords::lenN_S = lenSouth - lenNorth;

double MapCoords::RealAngleMaxLongitude = atan (((double)pnSxW_Z - centerZ)/(pnSxW_X - centerX)) * 180.f / PI;
// borders
float MapCoords::EndWest = 24.f;
float MapCoords::EndEast = 42.f;
float MapCoords::EndNorth = 48.f;
float MapCoords::EndSouth = 40.f;
float MapCoords::MiddleLongitude = (EndWest + EndEast) / 2;
float MapCoords::ToLengthN_S = (float)((EndNorth - EndSouth) / lenN_S);
double MapCoords::ToAngleW_E = (MiddleLongitude - EndWest) / RealAngleMaxLongitude;

double MapCoords::Longitude(float x, float z)	// degrees , (x (meters) - to North, z (meters) - to East)
{
double ang = - atan (((double)(z - centerZ)) / (x - centerX)) * ToDegree;
return ang * ToAngleW_E + MiddleLongitude;
}

double MapCoords::Latitude(float x, float z)	// degrees (x (meters) - to North, z (meters) - to East)
{
double len = lenSouth - sqrt((x-centerX)*(x-centerX) + (z-centerZ)*(z-centerZ));
return len * ToLengthN_S + EndSouth;
}

void MapCoords::GetCoords(double inLatitudeDegrees, double inLongitudeDegrees, float &outX, float &outZ)
{
// Lo coordinates system
double realAng = (inLongitudeDegrees - MiddleLongitude) / ToAngleW_E / ToDegree;	
double realLen = lenSouth - (inLatitudeDegrees - EndSouth) / ToLengthN_S;
outX = centerX - realLen * cos (realAng);
outZ = centerZ + realLen * sin (realAng);
}

sigpic2354_5.gif
Link to comment
Share on other sites

Here you can found LUA fonctions of Alex's work:

 

--data for recalculation
zeroX = 5000000
zeroZ = 6600000

centerX = 11465000 - zeroX --circle center
centerZ =  6500000 - zeroZ

pnSxW_X = 4468608 - zeroX -- point 40dgN : 24dgE
pnSxW_Z = 5730893 - zeroZ

pnNxW_X = 5357858 - zeroX -- point 48dgN : 24dgE
pnNxW_Z = 5828649 - zeroZ

pnSxE_X = 4468608 - zeroX -- point 40dgN : 42dgE
pnSxE_Z = 7269106 - zeroZ

pnNxE_X = 5357858 - zeroX -- point 48dgN : 42dgE
pnNxE_Z = 7171350 - zeroZ

lenNorth = math.sqrt((pnNxW_X-centerX)*(pnNxW_X-centerX) + (pnNxW_Z-centerZ)*(pnNxW_Z-centerZ))
lenSouth = math.sqrt((pnSxW_X-centerX)*(pnSxW_X-centerX) + (pnSxW_Z-centerZ)*(pnSxW_Z-centerZ))
lenN_S = lenSouth - lenNorth

RealAngleMaxLongitude = math.atan ((pnSxW_Z - centerZ)/(pnSxW_X - centerX)) * 180/pi
-- borders
EndWest = 24
EndEast = 42
EndNorth = 48
EndSouth = 40
MiddleLongitude = (EndWest + EndEast) / 2
ToLengthN_S = ((EndNorth - EndSouth) / lenN_S)
ToAngleW_E = (MiddleLongitude - EndWest) / RealAngleMaxLongitude

ToDegree = 360/(2*pi)


function getLongitude(x, z)    -- degrees , (x (meters) - to North, z (meters) - to East)

   ang = - math.atan (((z - centerZ)) / (x - centerX)) * ToDegree
   return ang * ToAngleW_E + MiddleLongitude

end

function getLatitude(x, z)    --degrees (x (meters) - to North, z (meters) - to East)

   len = lenSouth - math.sqrt((x-centerX)*(x-centerX) + (z-centerZ)*(z-centerZ))
   return len * ToLengthN_S + EndSouth

end

function getXYCoords(inLatitudeDegrees, inLongitudeDegrees) -- args: 2 numbers // Return two value in order: X, Y

   -- Lo coordinates system
   realAng = (inLongitudeDegrees - MiddleLongitude) / ToAngleW_E / ToDegree
   realLen = lenSouth - (inLatitudeDegrees - EndSouth) / ToLengthN_S
   outX = centerX - realLen * cos (realAng)
   outZ = centerZ + realLen * sin (realAng)
   return outX, outY
end

To get latitude and longitude with X,Z coord, you have to do this:

myLat = getLatitude(myXCoord, myZCoord)

myLong = getLongitude(myXCoord, myZCoord)

 

To get X,Z coord with Lat/Long you have to do this (not usefull):

myXCoord, myZCoord = getXYCoords(myLat, myLong)

 

myLat and myLong are two float like 48.2034

 

To convert a latitude (°, min, sec):

floatDeg = integerDeg + (60*min + sec)/3600

 

Ex of Krymsk:

44° 57' 45" N --> 44 + (60*57 + 45)/3600 = 44.9625

 

 

 

Regards

Doug

LOTATC .NET // LOVICA .NET // 3rd Wing

Link to comment
Share on other sites

DarkSoul> Simmeters have already working version of Lockon glasspanel gauges and HUD view export so if they will support MFD/ABRIS/Flir you only add "few dozen" switches, displays and warning lights connected for instance via opencockpits IO cards.. Opencockpits architecture is already supported in Lockon FC, MSFS, IL2, Falcon, and EECH is in alpha now..

 

abris.gifabris1.jpgabris_tec.gif

http://avia.transas.com/eng/abris.htm

Link to comment
Share on other sites

  • 2 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...