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 IGNITION_MATH_SPHERICALCOORDINATES_HH_
18 #define IGNITION_MATH_SPHERICALCOORDINATES_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <ignition/math/Angle.hh>
24 #include <ignition/math/Vector3.hh>
25 #include <ignition/math/Helpers.hh>
26 #include <ignition/math/config.hh>
27 
28 namespace ignition
29 {
30  namespace math
31  {
32  inline namespace IGNITION_MATH_VERSION_NAMESPACE
33  {
34  class SphericalCoordinatesPrivate;
35 
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 
63  LOCAL = 4
64  };
65 
67  public: SphericalCoordinates();
68 
71  public: explicit SphericalCoordinates(const SurfaceType _type);
72 
79  public: SphericalCoordinates(const SurfaceType _type,
80  const ignition::math::Angle &_latitude,
81  const ignition::math::Angle &_longitude,
82  const double _elevation,
83  const ignition::math::Angle &_heading);
84 
87  public: SphericalCoordinates(const SphericalCoordinates &_sc);
88 
90  public: ~SphericalCoordinates();
91 
96  public: ignition::math::Vector3d SphericalFromLocalPosition(
97  const ignition::math::Vector3d &_xyz) const;
98 
103  public: ignition::math::Vector3d GlobalFromLocalVelocity(
104  const ignition::math::Vector3d &_xyz) const;
105 
110  public: static SurfaceType Convert(const std::string &_str);
111 
121  public: static double Distance(const ignition::math::Angle &_latA,
122  const ignition::math::Angle &_lonA,
123  const ignition::math::Angle &_latB,
124  const ignition::math::Angle &_lonB);
125 
128  public: SurfaceType Surface() const;
129 
132  public: ignition::math::Angle LatitudeReference() const;
133 
136  public: ignition::math::Angle LongitudeReference() const;
137 
140  public: double ElevationReference() const;
141 
146  public: ignition::math::Angle HeadingOffset() const;
147 
150  public: void SetSurface(const SurfaceType &_type);
151 
154  public: void SetLatitudeReference(const ignition::math::Angle &_angle);
155 
158  public: void SetLongitudeReference(const ignition::math::Angle &_angle);
159 
162  public: void SetElevationReference(const double _elevation);
163 
166  public: void SetHeadingOffset(const ignition::math::Angle &_angle);
167 
171  public: ignition::math::Vector3d LocalFromSphericalPosition(
172  const ignition::math::Vector3d &_xyz) const;
173 
178  public: ignition::math::Vector3d LocalFromGlobalVelocity(
179  const ignition::math::Vector3d &_xyz) const;
180 
182  public: void UpdateTransformationMatrix();
183 
190  PositionTransform(const ignition::math::Vector3d &_pos,
191  const CoordinateType &_in, const CoordinateType &_out) const;
192 
198  public: ignition::math::Vector3d VelocityTransform(
199  const ignition::math::Vector3d &_vel,
200  const CoordinateType &_in, const CoordinateType &_out) const;
201 
205  public: bool operator==(const SphericalCoordinates &_sc) const;
206 
210  public: bool operator!=(const SphericalCoordinates &_sc) const;
211 
215  public: SphericalCoordinates &operator=(
216  const SphericalCoordinates &_sc);
217 
218 
219 #ifdef _WIN32
220 // Disable warning C4251 which is triggered by
221 // std::unique_ptr
222 #pragma warning(push)
223 #pragma warning(disable: 4251)
224 #endif
225  private: std::unique_ptr<SphericalCoordinatesPrivate> dataPtr;
228 #ifdef _WIN32
229 #pragma warning(pop)
230 #endif
231  };
233  }
234  }
235 }
236 #endif
Helpers.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Angle
An angle and related functions.
Definition: Angle.hh:47
ignition
Definition: Angle.hh:39
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::CoordinateType
CoordinateType
Unique identifiers for coordinate types.
Definition: SphericalCoordinates.hh:51
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates
Convert spherical coordinates for planetary surfaces.
Definition: SphericalCoordinates.hh:38
Vector3.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: Vector3.hh:39
Angle.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SurfaceType
SurfaceType
Unique identifiers for planetary surface models.
Definition: SphericalCoordinates.hh:42