NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
NEDtoECEF.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
39#include "NumCpp/NdArray.hpp"
40
42{
53 [[nodiscard]] inline reference_frames::ECEF NEDtoECEF(const reference_frames::NED& target,
54 const reference_frames::ECEF& referencePoint) noexcept
55 {
56 const auto referencePointLLA = ECEFtoLLA(referencePoint);
57
58 const auto sinLat = std::sin(referencePointLLA.latitude);
59 const auto cosLat = std::cos(referencePointLLA.latitude);
60 const auto sinLon = std::sin(referencePointLLA.longitude);
61 const auto cosLon = std::cos(referencePointLLA.longitude);
62
63 auto rotationMatrix = NdArray<double>(3, 3);
64 rotationMatrix(0, 0) = -sinLat * cosLon;
65 rotationMatrix(1, 0) = -sinLat * sinLon;
66 rotationMatrix(2, 0) = cosLat;
67 rotationMatrix(0, 1) = -sinLon;
68 rotationMatrix(1, 1) = cosLon;
69 rotationMatrix(2, 1) = 0.;
70 rotationMatrix(0, 2) = -cosLat * cosLon;
71 rotationMatrix(1, 2) = -cosLat * sinLon;
72 rotationMatrix(2, 2) = -sinLat;
73
74 auto targetVec = NdArray<double>(3, 1);
75 targetVec[0] = target.north();
76 targetVec[1] = target.east();
77 targetVec[2] = target.down();
78
79 auto referencePointVec = NdArray<double>(3, 1);
80 referencePointVec[0] = referencePoint.x;
81 referencePointVec[1] = referencePoint.y;
82 referencePointVec[2] = referencePoint.z;
83
84 const auto targetECEFVec = dot(rotationMatrix, targetVec) + referencePointVec;
85 return { targetECEFVec[0], targetECEFVec[1], targetECEFVec[2] };
86 }
87
98 [[nodiscard]] inline reference_frames::ECEF NEDtoECEF(const reference_frames::NED& target,
99 const reference_frames::LLA& referencePoint) noexcept
100 {
101 return NEDtoECEF(target, LLAtoECEF(referencePoint));
102 }
103} // namespace nc::coordinates::transforms
ECEF coordinates.
Definition: ECEF.hpp:40
Geodetic coordinates.
Definition: LLA.hpp:40
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:53
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
auto sin(dtype inValue) noexcept
Definition: sin.hpp:49
NdArray< dtype > dot(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: dot.hpp:47
auto cos(dtype inValue) noexcept
Definition: cos.hpp:49