#include <Aircraft/aircraft.hxx>
#include <Environment/environment.hxx>
#include <Environment/environment_mgr.hxx>
-#include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
#include <ATCDCL/ATCutils.hxx>
#include <osg/GLU>
double length = runway->lengthM() * 0.5;
double width = runway->widthM() * 0.5;
double frontLat, frontLon, backLat, backLon,az, tempLat, tempLon;
-
- geo_direct_wgs_84(alt, runway->_lat, runway->_lon, runway->_heading, length, &backLat, &backLon, &az);
+ double runwayLon = runway->geod().getLongitudeDeg(),
+ runwayLat = runway->geod().getLatitudeDeg();
+ double heading = runway->headingDeg();
+
+ geo_direct_wgs_84(alt, runwayLat, runwayLon, heading, length, &backLat, &backLon, &az);
sgGeodToCart(backLat * SG_DEGREES_TO_RADIANS, backLon * SG_DEGREES_TO_RADIANS, alt, points3d[4]);
- geo_direct_wgs_84(alt, runway->_lat, runway->_lon, runway->_heading + 180, length, &frontLat, &frontLon, &az);
+ geo_direct_wgs_84(alt, runwayLat, runwayLon, heading + 180, length, &frontLat, &frontLon, &az);
sgGeodToCart(frontLat * SG_DEGREES_TO_RADIANS, frontLon * SG_DEGREES_TO_RADIANS, alt, points3d[5]);
- geo_direct_wgs_84(alt, backLat, backLon, runway->_heading + 90, width, &tempLat, &tempLon, &az);
+ geo_direct_wgs_84(alt, backLat, backLon, heading + 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[0]);
- geo_direct_wgs_84(alt, backLat, backLon, runway->_heading - 90, width, &tempLat, &tempLon, &az);
+ geo_direct_wgs_84(alt, backLat, backLon, heading - 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[1]);
- geo_direct_wgs_84(alt, frontLat, frontLon, runway->_heading - 90, width, &tempLat, &tempLon, &az);
+ geo_direct_wgs_84(alt, frontLat, frontLon, heading - 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[2]);
- geo_direct_wgs_84(alt, frontLat, frontLon, runway->_heading + 90, width, &tempLat, &tempLon, &az);
+ geo_direct_wgs_84(alt, frontLat, frontLon, heading + 90, width, &tempLat, &tempLon, &az);
sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[3]);
}
void runway_instr::drawArrow()
{
- Point3D ac(0.0), rwy(0.0);
- ac.setlat(current_aircraft.fdm_state->get_Latitude_deg());
- ac.setlon(current_aircraft.fdm_state->get_Longitude_deg());
- rwy.setlat(runway->_lat);
- rwy.setlon(runway->_lon);
- float theta = GetHeadingFromTo(ac, rwy);
+ SGGeod acPos(SGGeod::fromDeg(
+ fgGetDouble("/position/longitude-deg"),
+ fgGetDouble("/position/latitude-deg")));
+ float theta = SGGeodesy::courseDeg(acPos, runway->geod());
theta -= fgGetDouble("/orientation/heading-deg");
theta = -theta;
glMatrixMode(GL_MODELVIEW);
void runway_instr::setLineWidth()
{
//Calculate the distance from the runway, A
- double course, distance;
- calc_gc_course_dist(Point3D(runway->longitude() * SGD_DEGREES_TO_RADIANS,
- runway->latitude() * SGD_DEGREES_TO_RADIANS, 0.0),
- Point3D(current_aircraft.fdm_state->get_Longitude(),
- current_aircraft.fdm_state->get_Latitude(), 0.0 ),
- &course, &distance);
- distance *= SG_METER_TO_NM;
+ SGGeod acPos(SGGeod::fromDeg(
+ fgGetDouble("/position/longitude-deg"),
+ fgGetDouble("/position/latitude-deg")));
+ double distance = SGGeodesy::distanceNm(acPos, runway->geod());
+
//Get altitude above runway, B
double alt_nm = get_agl();
static const SGPropertyNode *startup_units_node = fgGetNode("/sim/startup/units");