Added a function to determine whether a point is on a given runway
This commit is contained in:
parent
0333c21bbf
commit
46261bb51b
2 changed files with 33 additions and 0 deletions
src/ATC
|
@ -30,6 +30,7 @@
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
|
||||||
#include "ATCutils.hxx"
|
#include "ATCutils.hxx"
|
||||||
|
#include "ATCProjection.hxx"
|
||||||
|
|
||||||
// Convert any number to spoken digits
|
// Convert any number to spoken digits
|
||||||
string ConvertNumToSpokenDigits(string n) {
|
string ConvertNumToSpokenDigits(string n) {
|
||||||
|
@ -280,3 +281,25 @@ double dclGetAirportElev( const string& id ) {
|
||||||
return -9999.0;
|
return -9999.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Runway stuff
|
||||||
|
// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
|
||||||
|
bool OnRunway(Point3D pt, FGRunway* rwy) {
|
||||||
|
FGATCAlignedProjection ortho;
|
||||||
|
Point3D centre(rwy->lon, rwy->lat, 0.0); // We don't need the elev
|
||||||
|
ortho.Init(centre, rwy->heading);
|
||||||
|
|
||||||
|
Point3D xyc = ortho.ConvertToLocal(centre);
|
||||||
|
Point3D xyp = ortho.ConvertToLocal(pt);
|
||||||
|
|
||||||
|
//cout << "Length offset = " << fabs(xyp.y() - xyc.y()) << '\n';
|
||||||
|
//cout << "Width offset = " << fabs(xyp.x() - xyc.x()) << '\n';
|
||||||
|
|
||||||
|
if((fabs(xyp.y() - xyc.y()) < ((rwy->length/2.0) + 5.0))
|
||||||
|
&& (fabs(xyp.x() - xyc.x()) < (rwy->width/2.0))) {
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
#include <Airports/simple.hxx>
|
#include <Airports/simple.hxx>
|
||||||
|
#include <Airports/runways.hxx>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <simgear/math/point3d.hxx>
|
#include <simgear/math/point3d.hxx>
|
||||||
|
@ -91,3 +92,12 @@ bool dclFindAirportID( const string& id, FGAirport *a );
|
||||||
|
|
||||||
// get airport elevation
|
// get airport elevation
|
||||||
double dclGetAirportElev( const string& id );
|
double dclGetAirportElev( const string& id );
|
||||||
|
|
||||||
|
/****************
|
||||||
|
*
|
||||||
|
* Runways
|
||||||
|
*
|
||||||
|
****************/
|
||||||
|
|
||||||
|
// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
|
||||||
|
bool OnRunway(Point3D pt, FGRunway* rwy);
|
||||||
|
|
Loading…
Add table
Reference in a new issue