QGCGeo.h 2.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*=====================================================================

 QGroundControl Open Source Ground Control Station

 (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

 This file is part of the QGROUNDCONTROL project

 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

 ======================================================================*/

/// @file
///     @brief Coordinate transformation math functions.
///     @link https://github.com/PX4/Firmware/blob/master/src/lib/geo/geo.c
///     @link http://psas.pdx.edu/CoordinateSystem/Latitude_to_LocalTangent.pdf
///     @link http://dspace.dsto.defence.gov.au/dspace/bitstream/1947/3538/1/DSTO-TN-0432.pdf
///     @author David Goodman <dagoodma@gmail.com>

LM's avatar
LM committed
31 32 33
#ifndef QGCGEO_H
#define QGCGEO_H

34
#include <QGeoCoordinate>
35 36 37 38 39 40

/* Safeguard for systems lacking sincos (e.g. Mac OS X Leopard) */
#ifndef sincos
#define sincos(th,x,y) { (*(x))=sin(th); (*(y))=cos(th); }
#endif

LM's avatar
LM committed
41
/**
42 43
 * @brief Project a geodetic coordinate on to local tangential plane (LTP) as coordinate with East,
 * North, and Down components in meters.
44 45 46 47
 * @param[in] coord Geodetic coordinate to project onto LTP.
 * @param[in] origin Geoedetic origin for LTP projection.
 * @param[out] x North component of coordinate in local plane.
 * @param[out] y East component of coordinate in local plane.
48
 * @param[out] z Down component of coordinate in local plane.
LM's avatar
LM committed
49
 */
50
void convertGeoToNed(QGeoCoordinate coord, QGeoCoordinate origin, double* x, double* y, double* z);
LM's avatar
LM committed
51

52
/**
53
 * @brief Transform a local (East, North, and Down) coordinate into a geodetic coordinate.
54 55
 * @param[in] x North component of local coordinate in meters.
 * @param[in] x East component of local coordinate in meters.
56
 * @param[in] x Down component of local coordinate in meters.
57 58 59
 * @param[in] origin Geoedetic origin for LTP.
 * @param[out] coord Geodetic coordinate to hold result.
 */
60
void convertNedToGeo(double x, double y, double z, QGeoCoordinate origin, QGeoCoordinate *coord);
LM's avatar
LM committed
61 62

#endif // QGCGEO_H