SphericalCoordinates.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
27 namespace ignition
28 {
29  namespace math
30  {
31  class SphericalCoordinatesPrivate;
32 
36  {
39  public: enum SurfaceType
40  {
43  EARTH_WGS84 = 1
44  };
45 
48  public: enum CoordinateType
49  {
51  SPHERICAL = 1,
52 
54  ECEF = 2,
55 
57  GLOBAL = 3,
58 
60  LOCAL = 4
61  };
62 
64  public: SphericalCoordinates();
65 
68  public: explicit SphericalCoordinates(const SurfaceType _type);
69 
76  public: SphericalCoordinates(const SurfaceType _type,
77  const ignition::math::Angle &_latitude,
78  const ignition::math::Angle &_longitude,
79  const double _elevation,
80  const ignition::math::Angle &_heading);
81 
84  public: SphericalCoordinates(const SphericalCoordinates &_sc);
85 
87  public: ~SphericalCoordinates();
88 
93  public: ignition::math::Vector3d SphericalFromLocalPosition(
94  const ignition::math::Vector3d &_xyz) const;
95 
100  public: ignition::math::Vector3d GlobalFromLocalVelocity(
101  const ignition::math::Vector3d &_xyz) const;
102 
107  public: static SurfaceType Convert(const std::string &_str);
108 
118  public: static double Distance(const ignition::math::Angle &_latA,
119  const ignition::math::Angle &_lonA,
120  const ignition::math::Angle &_latB,
121  const ignition::math::Angle &_lonB);
122 
125  public: SurfaceType Surface() const;
126 
129  public: ignition::math::Angle LatitudeReference() const;
130 
133  public: ignition::math::Angle LongitudeReference() const;
134 
137  public: double ElevationReference() const;
138 
143  public: ignition::math::Angle HeadingOffset() const;
144 
147  public: void SetSurface(const SurfaceType &_type);
148 
151  public: void SetLatitudeReference(const ignition::math::Angle &_angle);
152 
155  public: void SetLongitudeReference(const ignition::math::Angle &_angle);
156 
159  public: void SetElevationReference(const double _elevation);
160 
163  public: void SetHeadingOffset(const ignition::math::Angle &_angle);
164 
168  public: ignition::math::Vector3d LocalFromSphericalPosition(
169  const ignition::math::Vector3d &_xyz) const;
170 
175  public: ignition::math::Vector3d LocalFromGlobalVelocity(
176  const ignition::math::Vector3d &_xyz) const;
177 
179  public: void UpdateTransformationMatrix();
180 
187  PositionTransform(const ignition::math::Vector3d &_pos,
188  const CoordinateType &_in, const CoordinateType &_out) const;
189 
195  public: ignition::math::Vector3d VelocityTransform(
196  const ignition::math::Vector3d &_vel,
197  const CoordinateType &_in, const CoordinateType &_out) const;
198 
202  public: bool operator==(const SphericalCoordinates &_sc) const;
203 
207  public: bool operator!=(const SphericalCoordinates &_sc) const;
208 
212  public: SphericalCoordinates &operator=(
213  const SphericalCoordinates &_sc);
214 
215 
216 #ifdef _WIN32
217 // Disable warning C4251 which is triggered by
218 // std::unique_ptr
219 #pragma warning(push)
220 #pragma warning(disable: 4251)
221 #endif
222  private: std::unique_ptr<SphericalCoordinatesPrivate> dataPtr;
225 #ifdef _WIN32
226 #pragma warning(pop)
227 #endif
228  };
230  }
231 }
232 #endif
An angle and related functions.
Definition: Angle.hh:44
CoordinateType
Unique identifiers for coordinate types.
Definition: SphericalCoordinates.hh:48
SurfaceType
Unique identifiers for planetary surface models.
Definition: SphericalCoordinates.hh:39
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: System.hh:59
Convert spherical coordinates for planetary surfaces.
Definition: SphericalCoordinates.hh:35
Definition: Angle.hh:38