Gazebo Math

API Reference

7.5.1
gz/math/SphericalCoordinates.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_MATH_SPHERICALCOORDINATES_HH_
18 #define GZ_MATH_SPHERICALCOORDINATES_HH_
19 
20 #include <string>
21 
22 #include <gz/math/Angle.hh>
23 #include <gz/math/Vector3.hh>
24 #include <gz/math/Helpers.hh>
25 #include <gz/math/config.hh>
26 #include <gz/utils/ImplPtr.hh>
27 
28 namespace gz::math
29 {
30  // Inline bracket to help doxygen filtering.
31  inline namespace GZ_MATH_VERSION_NAMESPACE {
32 
34  class GZ_MATH_VISIBLE SphericalCoordinates
35  {
38  public: enum SurfaceType
39  {
42  EARTH_WGS84 = 1,
43 
47  MOON_SCS = 2,
48 
50  CUSTOM_SURFACE = 10
51  };
52 
55  public: enum CoordinateType
56  {
58  SPHERICAL = 1,
59 
61  ECEF = 2,
62 
64  GLOBAL = 3,
65 
69  LOCAL = 4,
70 
72  LOCAL2 = 5
73  };
74 
77 
80  public: explicit SphericalCoordinates(const SurfaceType _type);
81 
88  const SurfaceType _type,
89  const double _axisEquatorial,
90  const double _axisPolar);
91 
98  public: SphericalCoordinates(const SurfaceType _type,
99  const gz::math::Angle &_latitude,
100  const gz::math::Angle &_longitude,
101  const double _elevation,
102  const gz::math::Angle &_heading);
103 
118  const gz::math::Vector3d &_xyz) const;
119 
132  const gz::math::Vector3d &_xyz) const;
133 
138  public: static SurfaceType Convert(const std::string &_str);
139 
143  public: static std::string Convert(SurfaceType _type);
144 
155  public: GZ_DEPRECATED(7) static double Distance(
156  const gz::math::Angle &_latA,
157  const gz::math::Angle &_lonA,
158  const gz::math::Angle &_latB,
159  const gz::math::Angle &_lonB);
160 
171  public: static double DistanceWGS84(
172  const gz::math::Angle &_latA,
173  const gz::math::Angle &_lonA,
174  const gz::math::Angle &_latB,
175  const gz::math::Angle &_lonB);
176 
188  public: double DistanceBetweenPoints(
189  const gz::math::Angle &_latA,
190  const gz::math::Angle &_lonA,
191  const gz::math::Angle &_latB,
192  const gz::math::Angle &_lonB);
193 
196  public: SurfaceType Surface() const;
197 
200  public: double SurfaceRadius() const;
201 
204  public: double SurfaceAxisEquatorial() const;
205 
208  public: double SurfaceAxisPolar() const;
209 
212  public: double SurfaceFlattening() const;
213 
216  public: gz::math::Angle LatitudeReference() const;
217 
220  public: gz::math::Angle LongitudeReference() const;
221 
224  public: double ElevationReference() const;
225 
230  public: gz::math::Angle HeadingOffset() const;
231 
234  public: void SetSurface(const SurfaceType &_type);
235 
241  public: void SetSurface(
242  const SurfaceType &_type,
243  const double _axisEquatorial,
244  const double _axisPolar);
245 
248  public: void SetLatitudeReference(const gz::math::Angle &_angle);
249 
252  public: void SetLongitudeReference(const gz::math::Angle &_angle);
253 
256  public: void SetElevationReference(const double _elevation);
257 
260  public: void SetHeadingOffset(const gz::math::Angle &_angle);
261 
267  public: gz::math::Vector3d LocalFromSphericalPosition(
268  const gz::math::Vector3d &_latLonEle) const;
269 
275  public: gz::math::Vector3d LocalFromGlobalVelocity(
276  const gz::math::Vector3d &_xyz) const;
277 
279  public: void UpdateTransformationMatrix();
280 
287  public: gz::math::Vector3d
288  PositionTransform(const gz::math::Vector3d &_pos,
289  const CoordinateType &_in, const CoordinateType &_out) const;
290 
297  public: gz::math::Vector3d VelocityTransform(
298  const gz::math::Vector3d &_vel,
299  const CoordinateType &_in, const CoordinateType &_out) const;
300 
304  public: bool operator==(const SphericalCoordinates &_sc) const;
305 
309  public: bool operator!=(const SphericalCoordinates &_sc) const;
310 
312  GZ_UTILS_IMPL_PTR(dataPtr)
313  };
314  } // namespace GZ_MATH_VERSION_NAMESPACE
315 } // namespace gz::math
316 #endif // GZ_MATH_SPHERICALCOORDINATES_HH_