Gazebo Math

API Reference

6.15.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 <memory>
21 #include <string>
22 
23 #include <gz/math/Angle.hh>
24 #include <gz/math/Vector3.hh>
25 #include <gz/math/Helpers.hh>
26 #include <gz/math/config.hh>
27 
28 namespace ignition
29 {
30  namespace math
31  {
32  // Inline bracket to help doxygen filtering.
33  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
34  //
35  class SphericalCoordinatesPrivate;
36 
38  class IGNITION_MATH_VISIBLE SphericalCoordinates
39  {
42  public: enum SurfaceType
43  {
46  EARTH_WGS84 = 1
47  };
48 
51  public: enum CoordinateType
52  {
54  SPHERICAL = 1,
55 
57  ECEF = 2,
58 
60  GLOBAL = 3,
61 
65  LOCAL = 4,
66 
68  LOCAL2 = 5
69  };
70 
72  public: SphericalCoordinates();
73 
76  public: explicit SphericalCoordinates(const SurfaceType _type);
77 
84  public: SphericalCoordinates(const SurfaceType _type,
85  const gz::math::Angle &_latitude,
86  const gz::math::Angle &_longitude,
87  const double _elevation,
88  const gz::math::Angle &_heading);
89 
92  public: SphericalCoordinates(const SphericalCoordinates &_sc);
93 
95  public: ~SphericalCoordinates();
96 
110  public: gz::math::Vector3d SphericalFromLocalPosition(
111  const gz::math::Vector3d &_xyz) const;
112 
124  public: gz::math::Vector3d GlobalFromLocalVelocity(
125  const gz::math::Vector3d &_xyz) const;
126 
131  public: static SurfaceType Convert(const std::string &_str);
132 
136  public: static std::string Convert(SurfaceType _type);
137 
147  public: static double Distance(const gz::math::Angle &_latA,
148  const gz::math::Angle &_lonA,
149  const gz::math::Angle &_latB,
150  const gz::math::Angle &_lonB);
151 
154  public: SurfaceType Surface() const;
155 
158  public: gz::math::Angle LatitudeReference() const;
159 
162  public: gz::math::Angle LongitudeReference() const;
163 
166  public: double ElevationReference() const;
167 
172  public: gz::math::Angle HeadingOffset() const;
173 
176  public: void SetSurface(const SurfaceType &_type);
177 
180  public: void SetLatitudeReference(const gz::math::Angle &_angle);
181 
184  public: void SetLongitudeReference(const gz::math::Angle &_angle);
185 
188  public: void SetElevationReference(const double _elevation);
189 
192  public: void SetHeadingOffset(const gz::math::Angle &_angle);
193 
199  public: gz::math::Vector3d LocalFromSphericalPosition(
200  const gz::math::Vector3d &_latLonEle) const;
201 
207  public: gz::math::Vector3d LocalFromGlobalVelocity(
208  const gz::math::Vector3d &_xyz) const;
209 
211  public: void UpdateTransformationMatrix();
212 
219  public: gz::math::Vector3d
220  PositionTransform(const gz::math::Vector3d &_pos,
221  const CoordinateType &_in, const CoordinateType &_out) const;
222 
229  public: gz::math::Vector3d VelocityTransform(
230  const gz::math::Vector3d &_vel,
231  const CoordinateType &_in, const CoordinateType &_out) const;
232 
236  public: bool operator==(const SphericalCoordinates &_sc) const;
237 
241  public: bool operator!=(const SphericalCoordinates &_sc) const;
242 
246  public: SphericalCoordinates &operator=(
247  const SphericalCoordinates &_sc);
248 
249 
250 #ifdef _WIN32
251 // Disable warning C4251 which is triggered by
252 // std::unique_ptr
253 #pragma warning(push)
254 #pragma warning(disable: 4251)
255 #endif
259 #ifdef _WIN32
260 #pragma warning(pop)
261 #endif
262  };
263  }
264  }
265 }
266 #endif
@ GLOBAL
Local tangent plane (East, North, Up)
Definition: gz/math/SphericalCoordinates.hh:60
@ ECEF
Earth centered, earth fixed Cartesian.
Definition: gz/math/SphericalCoordinates.hh:57
SphericalCoordinates & operator=(const SphericalCoordinates &_sc)
Assignment operator.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
STL class.
Convert spherical coordinates for planetary surfaces.
Definition: gz/math/SphericalCoordinates.hh:38
double ElevationReference() const
Get reference elevation in meters.
void UpdateTransformationMatrix()
Update coordinate transformation matrix with reference location.
Vector3d GlobalFromLocalVelocity(const Vector3d &_xyz) const
Convert a Cartesian velocity vector in the local frame to a global Cartesian frame with components Ea...
@ SPHERICAL
Latitude, Longitude and Altitude by SurfaceType.
Definition: gz/math/SphericalCoordinates.hh:54
Angle LatitudeReference() const
Get reference geodetic latitude.
Angle LongitudeReference() const
Get reference longitude.
@ LOCAL2
Heading-adjusted tangent plane (X, Y, Z)
Definition: gz/math/SphericalCoordinates.hh:68
void SetHeadingOffset(const Angle &_angle)
Set heading angle offset for the frame.
Vector3d VelocityTransform(const Vector3d &_vel, const CoordinateType &_in, const CoordinateType &_out) const
Convert between velocity in SPHERICAL/ECEF/LOCAL/GLOBAL frame Spherical coordinates use radians,...
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: gz/math/Vector3.hh:41
void SetLongitudeReference(const Angle &_angle)
Set reference longitude.
CoordinateType
Unique identifiers for coordinate types.
Definition: gz/math/SphericalCoordinates.hh:51
bool operator!=(const SphericalCoordinates &_sc) const
Inequality.
@ EARTH_WGS84
Model of reference ellipsoid for earth, based on WGS 84 standard. see wikipedia: World_Geodetic_Syste...
Definition: gz/math/SphericalCoordinates.hh:46
void SetLatitudeReference(const Angle &_angle)
Set reference geodetic latitude.
SurfaceType Surface() const
Get SurfaceType currently in use.
The Angle class is used to simplify and clarify the use of radians and degrees measurements....
Definition: gz/math/Angle.hh:61
static double Distance(const Angle &_latA, const Angle &_lonA, const Angle &_latB, const Angle &_lonB)
Get the distance between two points expressed in geographic latitude and longitude....
static SurfaceType Convert(const std::string &_str)
Convert a string to a SurfaceType. Allowed values: ["EARTH_WGS84"].
Vector3d SphericalFromLocalPosition(const Vector3d &_xyz) const
Convert a Cartesian position vector to geodetic coordinates. This performs a PositionTransform from L...
Vector3d LocalFromGlobalVelocity(const Vector3d &_xyz) const
Convert a Cartesian velocity vector with components East, North, Up to a local cartesian frame vector...
bool operator==(const SphericalCoordinates &_sc) const
Equality operator, result = this == _sc.
Angle HeadingOffset() const
Get heading offset for the reference frame, expressed as angle from East to x-axis,...
SurfaceType
Unique identifiers for planetary surface models.
Definition: gz/math/SphericalCoordinates.hh:42
Vector3d PositionTransform(const Vector3d &_pos, const CoordinateType &_in, const CoordinateType &_out) const
Convert between positions in SPHERICAL/ECEF/LOCAL/GLOBAL frame Spherical coordinates use radians,...
@ LOCAL
Heading-adjusted tangent plane (X, Y, Z) This has kept a bug for backwards compatibility,...
Definition: gz/math/SphericalCoordinates.hh:65
void SetSurface(const SurfaceType &_type)
Set SurfaceType for planetary surface model.
Vector3< double > Vector3d
Definition: gz/math/Vector3.hh:770
Vector3d LocalFromSphericalPosition(const Vector3d &_latLonEle) const
Convert a geodetic position vector to Cartesian coordinates. This performs a PositionTransform from S...
void SetElevationReference(const double _elevation)
Set reference elevation above sea level in meters.