Loading...
Searching...
No Matches
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
26#include <ignition/math/config.hh>
27
28namespace 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
227 private: std::unique_ptr<SphericalCoordinatesPrivate> dataPtr;
228#ifdef _WIN32
229#pragma warning(pop)
230#endif
231 };
233 }
234 }
235}
236#endif
An angle and related functions.
Definition Angle.hh:48
Convert spherical coordinates for planetary surfaces.
Definition SphericalCoordinates.hh:39
SphericalCoordinates & operator=(const SphericalCoordinates &_sc)
Assignment operator.
void SetSurface(const SurfaceType &_type)
Set SurfaceType for planetary surface model.
static SurfaceType Convert(const std::string &_str)
Convert a string to a SurfaceType.
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.
void SetLongitudeReference(const ignition::math::Angle &_angle)
Set reference longitude.
SurfaceType Surface() const
Get SurfaceType currently in use.
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.
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.
double ElevationReference() const
Get reference elevation in meters.
bool operator==(const SphericalCoordinates &_sc) const
Equality operator, result = this == _sc.
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...
SphericalCoordinates(const SurfaceType _type)
Constructor with surface type input.
void SetLatitudeReference(const ignition::math::Angle &_angle)
Set reference geodetic latitude.
bool operator!=(const SphericalCoordinates &_sc) const
Inequality.
ignition::math::Vector3d SphericalFromLocalPosition(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian position vector to geodetic coordinates.
void UpdateTransformationMatrix()
Update coordinate transformation matrix with reference location.
CoordinateType
Unique identifiers for coordinate types.
Definition SphericalCoordinates.hh:52
SphericalCoordinates(const SphericalCoordinates &_sc)
Copy constructor.
ignition::math::Angle LatitudeReference() const
Get reference geodetic latitude.
ignition::math::Angle HeadingOffset() const
Get heading offset for the reference frame, expressed as angle from East to x-axis,...
void SetHeadingOffset(const ignition::math::Angle &_angle)
Set heading angle offset for the frame.
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::Vector3d VelocityTransform(const ignition::math::Vector3d &_vel, const CoordinateType &_in, const CoordinateType &_out) const
Convert between velocity in SPHERICAL/ECEF/LOCAL/GLOBAL frame.
void SetElevationReference(const double _elevation)
Set reference elevation above sea level in meters.
SurfaceType
Unique identifiers for planetary surface models.
Definition SphericalCoordinates.hh:43
ignition::math::Vector3d LocalFromSphericalPosition(const ignition::math::Vector3d &_xyz) const
Convert a geodetic position vector to Cartesian coordinates.
ignition::math::Angle LongitudeReference() const
Get reference longitude.
The Vector3 class represents the generic vector containing 3 elements.
Definition Vector3.hh:40
Definition Angle.hh:40