/
Sangak
/
ardupilot
Обзор
Документация
Войти
/
Sangak
/
ardupilot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
libraries/AP_Math/location.cpp
62 строки
2 KB
Leonard Hall
AP_Math: No Compiler Change
11 июл 2025, 07:50
11 июл 2025, 07:50
5a06f14
Код
Авторство
О чём код?
/* * location.cpp * Copyright (C) Andrew Tridgell 2011 * * This file 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. * * This file 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 this program. If not, see <http://www.gnu.org/licenses/>. */ /* * this module deals with calculations involving locations */ #include <stdlib.h> #include "AP_Math.h" #include "location.h" // return bearing_rad in radians between two positions float get_bearing_rad(const Vector2f &origin, const Vector2f &destination) { return wrap_2PI(atan2f(destination.y - origin.y, destination.x - origin.x)); } // return bearing_cd in centi-degrees between two positions float get_bearing_cd(const Vector2f &origin, const Vector2f &destination) { return rad_to_cd(get_bearing_rad(origin, destination)); } // return true when lat and lng are within range bool check_lat(float lat) { return fabsf(lat) <= 90; } bool check_lng(float lng) { return fabsf(lng) <= 180; } bool check_lat(int32_t lat) { return labs(lat) <= 90*1e7; } bool check_lng(int32_t lng) { return labs(lng) <= 180*1e7; } bool check_latlng(float lat, float lng) { return check_lat(lat) && check_lng(lng); } bool check_latlng(int32_t lat, int32_t lng) { return check_lat(lat) && check_lng(lng); }