Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG Graphics mbed TS_DISCO_F746NG
Location.cpp
00001 // 00002 // Location.cpp 00003 // 00004 00005 #include "Location.h" 00006 #include "math.h" 00007 #include "Commons.h" 00008 00009 Location::Location() 00010 { 00011 SetLocation(0,0,0); 00012 } 00013 00014 Location::Location(float x, float y, float height) 00015 { 00016 SetLocation(x, y, height); 00017 } 00018 00019 void Location::SetLocation(float x, float y, float height) 00020 { 00021 _x = x; 00022 _y = y; 00023 _h = height; 00024 00025 ToAngular(); 00026 } 00027 00028 void Location::SetLocationAngular(float distance, float azimuth, float elevation) 00029 { 00030 _distance = distance; 00031 _azimuth = azimuth; 00032 _elevation = elevation; 00033 00034 ToCartesian(); 00035 } 00036 00037 float Location::GetX() 00038 { 00039 return _x; 00040 } 00041 00042 float Location::GetY() 00043 { 00044 return _y; 00045 } 00046 00047 float Location::GetHeight() 00048 { 00049 return _h; 00050 } 00051 00052 float Location::GetDistance() 00053 { 00054 return _distance; 00055 } 00056 00057 float Location::GetAzimuth() 00058 { 00059 return _azimuth; 00060 } 00061 00062 float Location::GetElevation() 00063 { 00064 return _elevation; 00065 } 00066 00067 void Location::ToAngular() 00068 { 00069 _distance = (float)sqrt(_x * _x + _y * _y + _h * _h); 00070 if (_distance > 0) 00071 { 00072 if (_x >= 0) 00073 _azimuth = ((float)M_PI_2 - asinf(_y / _distance)); 00074 else 00075 _azimuth = (float)(M_PI + M_PI_2 + asinf(_y / _distance)); 00076 } 00077 else 00078 _azimuth = 0.f; 00079 00080 _elevation = _distance > 0 ? asinf(_h / _distance) : 0.f; 00081 } 00082 00083 void Location::ToCartesian() 00084 { 00085 _x = _distance * sinf(_azimuth); 00086 _y = _distance * cosf(_azimuth); 00087 _h = _distance * sinf(_elevation); 00088 } 00089 00090
Generated on Wed Jul 13 2022 08:01:03 by
1.7.2