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 
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 
88 
91 
97  const ignition::math::Vector3d &_xyz) const;
98 
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 
133 
137 
140  public: double ElevationReference() const;
141 
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 
172  const ignition::math::Vector3d &_xyz) const;
173 
179  const ignition::math::Vector3d &_xyz) const;
180 
183 
191  const CoordinateType &_in, const CoordinateType &_out) const;
192 
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 
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
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SphericalFromLocalPosition
ignition::math::Vector3d SphericalFromLocalPosition(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian position vector to geodetic coordinates.
Helpers.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Angle
An angle and related functions.
Definition: Angle.hh:48
ignition
Definition: Angle.hh:40
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::CoordinateType
CoordinateType
Unique identifiers for coordinate types.
Definition: SphericalCoordinates.hh:52
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SphericalCoordinates
SphericalCoordinates(const SphericalCoordinates &_sc)
Copy constructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::Convert
static SurfaceType Convert(const std::string &_str)
Convert a string to a SurfaceType.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates
Convert spherical coordinates for planetary surfaces.
Definition: SphericalCoordinates.hh:39
Vector3.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::LatitudeReference
ignition::math::Angle LatitudeReference() const
Get reference geodetic latitude.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::Surface
SurfaceType Surface() const
Get SurfaceType currently in use.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SphericalCoordinates
SphericalCoordinates(const SurfaceType _type, const ignition::math::Angle &_latitude, const ignition::math::Angle &_longitude, const double _elevation, const ignition::math::Angle &_heading)
Constructor with surface type, angle, and elevation inputs.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SetSurface
void SetSurface(const SurfaceType &_type)
Set SurfaceType for planetary surface model.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::~SphericalCoordinates
~SphericalCoordinates()
Destructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::LongitudeReference
ignition::math::Angle LongitudeReference() const
Get reference longitude.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SetHeadingOffset
void SetHeadingOffset(const ignition::math::Angle &_angle)
Set heading angle offset for the frame.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::LocalFromSphericalPosition
ignition::math::Vector3d LocalFromSphericalPosition(const ignition::math::Vector3d &_xyz) const
Convert a geodetic position vector to Cartesian coordinates.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::HeadingOffset
ignition::math::Angle HeadingOffset() const
Get heading offset for the reference frame, expressed as angle from East to x-axis,...
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::PositionTransform
ignition::math::Vector3d PositionTransform(const ignition::math::Vector3d &_pos, const CoordinateType &_in, const CoordinateType &_out) const
Convert between positions in SPHERICAL/ECEF/LOCAL/GLOBAL frame.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::Distance
static double Distance(const ignition::math::Angle &_latA, const ignition::math::Angle &_lonA, const ignition::math::Angle &_latB, const ignition::math::Angle &_lonB)
Get the distance between two points expressed in geographic latitude and longitude.
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:40
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::GlobalFromLocalVelocity
ignition::math::Vector3d GlobalFromLocalVelocity(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian velocity vector in the local frame to a global Cartesian frame with components Ea...
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SphericalCoordinates
SphericalCoordinates(const SurfaceType _type)
Constructor with surface type input.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::LocalFromGlobalVelocity
ignition::math::Vector3d LocalFromGlobalVelocity(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian velocity vector with components East, North, Up to a local cartesian frame vector...
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::UpdateTransformationMatrix
void UpdateTransformationMatrix()
Update coordinate transformation matrix with reference location.
Angle.hh
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SetLongitudeReference
void SetLongitudeReference(const ignition::math::Angle &_angle)
Set reference longitude.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SurfaceType
SurfaceType
Unique identifiers for planetary surface models.
Definition: SphericalCoordinates.hh:43
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::operator=
SphericalCoordinates & operator=(const SphericalCoordinates &_sc)
Assignment operator.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::ElevationReference
double ElevationReference() const
Get reference elevation in meters.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::VelocityTransform
ignition::math::Vector3d VelocityTransform(const ignition::math::Vector3d &_vel, const CoordinateType &_in, const CoordinateType &_out) const
Convert between velocity in SPHERICAL/ECEF/LOCAL/GLOBAL frame.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::operator!=
bool operator!=(const SphericalCoordinates &_sc) const
Inequality.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SetLatitudeReference
void SetLatitudeReference(const ignition::math::Angle &_angle)
Set reference geodetic latitude.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SetElevationReference
void SetElevationReference(const double _elevation)
Set reference elevation above sea level in meters.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::SphericalCoordinates
SphericalCoordinates()
Constructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::SphericalCoordinates::operator==
bool operator==(const SphericalCoordinates &_sc) const
Equality operator, result = this == _sc.