18#ifndef __FPSDK_COMMON_TRAFO_HPP__
19#define __FPSDK_COMMON_TRAFO_HPP__
29#include "fpsdk_common/ext/eigen_core.hpp"
30#include "fpsdk_common/ext/eigen_geometry.hpp"
50static constexpr double WGS84_A = 6378137.0;
51static constexpr double WGS84_B = 6356752.314245;
52static constexpr double WGS84_C = 40075016.6855785;
53static constexpr double WGS84_1F = 298.257223563;
54static constexpr double WGS84_E2 = 6.69437999014e-3;
70Eigen::Matrix3d
RotEnuEcef(
const double lat,
const double lon);
102Eigen::Matrix3d
RotNedEcef(
const double lat,
const double lon);
123Eigen::Vector3d
TfEnuEcef(
const Eigen::Vector3d& ecef,
const Eigen::Vector3d& wgs84llh_ref);
133Eigen::Vector3d
TfEcefEnu(
const Eigen::Vector3d& enu,
const Eigen::Vector3d& wgs84llh_ref);
143Eigen::Vector3d
TfNedEcef(
const Eigen::Vector3d& ecef,
const Eigen::Vector3d& wgs84llh_ref);
148Eigen::Vector3d
TfEcefNed(
const Eigen::Vector3d& ned,
const Eigen::Vector3d& wgs84llh_ref);
178Eigen::Vector3d
EcefPoseToEnuEul(
const Eigen::Vector3d& ecef_p,
const Eigen::Matrix3d& ecef_r);
187Eigen::Vector3d
QuatToEul(
const Eigen::Quaterniond& quat);
196Eigen::Vector3d
RotToEul(
const Eigen::Matrix3d& rot);
216#if FPSDK_USE_PROJ || defined(_DOXYGEN_)
343 bool Init(
const std::string& source_crs,
const std::string& target_crs,
const TransformerOpts& opts = {});
367 bool Transform(Eigen::Vector3d& inout,
const bool inv =
false)
const;
378 bool Transform(
const Eigen::Vector3d& in, Eigen::Vector3d& out,
const bool inv =
false)
const;
389 bool Transform(
const Eigen::Vector4d& in, Eigen::Vector4d& out,
const bool inv =
false)
const;
392 const std::string name_;
393 mutable std::mutex mutex_;
400 bool _Transform(
const Eigen::Vector4d& in, Eigen::Vector4d& out,
const bool inv)
const;
Base class to prevent copy or move.
Transformation utilities.
Eigen::Matrix3d RotEnuEcef(const double lat, const double lon)
Calculate the rotation matrix from ECEF to ENU for a given reference latitude/longitude.
Eigen::Matrix3d RotNedEcef(const double lat, const double lon)
Calculate the rotation matrix from ECEF to NED for a given reference latitude/longitude.
Eigen::Vector3d LlhDegToRad(const Eigen::Vector3d &llh_deg)
Convert llh from deg to rad, height component unchanged.
const char * CrsTypeStr(const CrsType type)
Stringify CRS type.
Eigen::Vector3d LlhRadToDeg(const Eigen::Vector3d &llh_rad)
Convert llh from rad to deg, height component unchanged.
static constexpr double WGS84_1F
WGS-84 1/f inverse of flattening parameter.
Eigen::Vector3d TfEcefNed(const Eigen::Vector3d &ned, const Eigen::Vector3d &wgs84llh_ref)
static constexpr double WGS84_B2
WGS-84 b^2.
Eigen::Vector3d TfNedEcef(const Eigen::Vector3d &ecef, const Eigen::Vector3d &wgs84llh_ref)
Convert ECEF coordinates to ENU with specified ENU origin.
static constexpr double WGS84_E2
WGS-84 first eccentricity squared.
Eigen::Vector3d QuatToEul(const Eigen::Quaterniond &quat)
Vector4 quaternion to intrinsic Euler angles in ZYX (yaw, pitch, roll).
static constexpr double WGS84_C
Circumference at equator (= 2π * WGS84_A) [m].
Eigen::Vector3d RotToEul(const Eigen::Matrix3d &rot)
Rotation Matrix to intrinsic Euler angles in ZYX (yaw, pitch, roll) order in radian.
static constexpr double WGS84_B
WGS-84 Earth radius minor axis [m].
Eigen::Matrix3d RotNedEnu()
Returns rotation matrix between NED and ENU.
Eigen::Vector3d TfWgs84LlhEcef(const Eigen::Vector3d &ecef)
Convert ECEF (x, y, z) coordinates to geodetic coordinates (latitude, longitude, height).
Eigen::Vector3d TfEcefEnu(const Eigen::Vector3d &enu, const Eigen::Vector3d &wgs84llh_ref)
Transform ENU coordinate to ECEF with specified ENU-origin.
CrsType
Coordinate reference system (CRS) types.
@ OTHER
Other type (engineering, temporal, ...).
@ GEOGRAPHIC_2D
Geographic 2D (lat/lon), e.g. EPSG:4326.
@ VERTICAL
Vertical (height), e.g. EPSG:5703.
@ UNKNOWN
Unknown (or not initialised).
@ COMPOUND
Compound (horizontal + vertical), e.g. EPSG:4258+5703.
@ GEOCENTRIC
Geocentric (ECEF x/y/z), e.g. EPSG:4978.
@ GEOGRAPHIC_3D
Geographic 3D (lat/lon/height), e.g. EPSG:4979.
@ PROJECTED
Projected (east/north), e.g. EPSG:2056.
static constexpr double WGS84_A
WGS-84 Earth radius major axis [m].
Eigen::Vector3d EcefPoseToEnuEul(const Eigen::Vector3d &ecef_p, const Eigen::Matrix3d &ecef_r)
Calculate yaw, pitch and roll in ENU from a given pose in ECEF.
Eigen::Vector3d TfEnuEcef(const Eigen::Vector3d &ecef, const Eigen::Vector3d &wgs84llh_ref)
Transform ECEF coordinate to ENU with specified ENU-origin.
Eigen::Vector3d TfEcefWgs84Llh(const Eigen::Vector3d &wgs84llh)
Convert geodetic coordinates (latitude, longitude, height) to ECEF (x, y, z).
static constexpr double WGS84_A2
WGS-84 a^2.
static constexpr double WGS84_EE2
WGS-84 e'^2 second eccentricity squared.
Fixposition SDK: Common library.
Coordinate reference system (CRS) information.
std::string name_
CRS name, e.g. "WGS 84".
std::vector< CrsType > sub_types_
Types of the parts of a COMPOUND CRS, e.g. { GEOGRAPHIC_2D, VERTICAL }.
Fixposition SDK: Common types and type helpers.