1 // ATCutils.hxx - Utility functions for the ATC / AI subsytem
3 // Written by David Luff, started March 2002.
5 // Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <simgear/math/point3d.hxx>
26 // These are defined here because I had a problem with SG_DEGREES_TO_RADIANS
27 #define DCL_PI 3.1415926535f
28 #define DCL_DEGREES_TO_RADIANS (DCL_PI/180.0)
29 #define DCL_RADIANS_TO_DEGREES (180.0/DCL_PI)
31 /*******************************
33 * Communication functions
35 ********************************/
37 // Convert any number to spoken digits
38 string ConvertNumToSpokenDigits(string n);
40 // Convert a 2 digit rwy number to a spoken-style string
41 string ConvertRwyNumToSpokenString(int n);
43 // Return the phonetic letter of a letter represented as an integer 1->26
44 string GetPhoneticIdent(int i);
47 /*******************************
49 * Positional functions
51 ********************************/
53 // Given two positions, get the HORIZONTAL separation (in meters)
54 double dclGetHorizontalSeparation(Point3D pos1, Point3D pos2);
56 // Given a point and a line, get the HORIZONTAL shortest distance from the point to a point on the line.
57 // Expects to be fed orthogonal co-ordinates, NOT lat & lon !
58 double dclGetLinePointSeparation(double px, double py, double x1, double y1, double x2, double y2);
60 // Given a position (lat/lon/elev), heading, vertical angle, and distance, calculate the new position.
61 // Assumes that the ground is not hit!!! Expects heading and angle in degrees, distance in meters.
62 Point3D dclUpdatePosition(Point3D pos, double heading, double angle, double distance);
64 // Get a heading from one lat/lon to another (in degrees)
65 double GetHeadingFromTo(Point3D A, Point3D B);
67 // Given a heading (in degrees), bound it from 0 -> 360
68 void dclBoundHeading(double &hdg);