NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
NEDtoECEF.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
38#include "NumCpp/NdArray.hpp"
39
41{
52 [[nodiscard]] inline reference_frames::ECEF NEDtoECEF(const reference_frames::NED& target,
53 const reference_frames::ECEF& referencePoint) noexcept
54 {
55 const auto referencePointLLA = ECEFtoLLA(referencePoint);
56
57 const auto sinLat = std::sin(referencePointLLA.latitude);
58 const auto cosLat = std::cos(referencePointLLA.latitude);
59 const auto sinLon = std::sin(referencePointLLA.longitude);
60 const auto cosLon = std::cos(referencePointLLA.longitude);
61
62 auto rotationMatrix = NdArray<double>(3, 3);
63 rotationMatrix(0, 0) = -sinLat * cosLon;
64 rotationMatrix(1, 0) = -sinLat * sinLon;
65 rotationMatrix(2, 0) = cosLat;
66 rotationMatrix(0, 1) = -sinLon;
67 rotationMatrix(1, 1) = cosLon;
68 rotationMatrix(2, 1) = 0.;
69 rotationMatrix(0, 2) = -cosLat * cosLon;
70 rotationMatrix(1, 2) = -cosLat * sinLon;
71 rotationMatrix(2, 2) = -sinLat;
72
73 auto targetVec = NdArray<double>(3, 1);
74 targetVec[0] = target.north();
75 targetVec[1] = target.east();
76 targetVec[2] = target.down();
77
78 auto referencePointVec = NdArray<double>(3, 1);
79 referencePointVec[0] = referencePoint.x;
80 referencePointVec[1] = referencePoint.y;
81 referencePointVec[2] = referencePoint.z;
82
83 const auto targetECEFVec = dot(rotationMatrix, targetVec) + referencePointVec;
84 return { targetECEFVec[0], targetECEFVec[1], targetECEFVec[2] };
85 }
86
97 [[nodiscard]] inline reference_frames::ECEF NEDtoECEF(const reference_frames::NED& target,
98 const reference_frames::LLA& referencePoint) noexcept
99 {
100 return NEDtoECEF(target, LLAtoECEF(referencePoint));
101 }
102} // namespace nc::coordinates::transforms
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
ECEF coordinates.
Definition ECEF.hpp:38
Geodetic coordinates.
Definition LLA.hpp:41
North east down coordinates.
Definition NED.hpp:40
Definition AERtoECEF.hpp:38
reference_frames::ECEF LLAtoECEF(const reference_frames::LLA &point) noexcept
Converts the LLA coordinates to ECEF https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#F...
Definition LLAtoECEF.hpp:46
reference_frames::ECEF NEDtoECEF(const reference_frames::NED &target, const reference_frames::ECEF &referencePoint) noexcept
Converts the NED coordinates to ECEF https://apps.dtic.mil/sti/pdfs/AD1170763.pdf Figure 11 https://a...
Definition NEDtoECEF.hpp:52
reference_frames::LLA ECEFtoLLA(const reference_frames::ECEF &ecef, double tol=1e-8) noexcept
Converts ECEF coordinates to LLA https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_...
Definition ECEFtoLLA.hpp:49
NdArray< dtype > dot(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition dot.hpp:48