isce3 0.25.0
Loading...
Searching...
No Matches
Frame.icc
1namespace isce3 { namespace antenna {
2
3inline typename Frame::Vec3_t Frame::sphToCart(
4 double el_theta, double az_phi) const
5{
6 Vec3_t vec;
7 switch (_grid_type) {
8 case SphGridType::EL_AND_AZ: {
9 double theta {std::sqrt(el_theta * el_theta + az_phi * az_phi)};
10 double phi {std::atan2(az_phi, el_theta)};
11 double sin_theta {std::sin(theta)};
12 vec << sin_theta * std::cos(phi), sin_theta * std::sin(phi),
13 std::cos(theta);
14 return vec;
15 }
16
17 case SphGridType::EL_OVER_AZ: {
18 double cos_az {std::cos(az_phi)};
19 vec << std::sin(el_theta) * cos_az, std::sin(az_phi),
20 std::cos(el_theta) * cos_az;
21 return vec;
22 }
23
24 case SphGridType::AZ_OVER_EL: {
25 double cos_el {std::cos(el_theta)};
26 vec << std::sin(el_theta), cos_el * std::sin(az_phi),
27 cos_el * std::cos(az_phi);
28 return vec;
29 }
30
31 case SphGridType::THETA_PHI: {
32 double sin_el {std::sin(el_theta)};
33 vec << sin_el * std::cos(az_phi), sin_el * std::sin(az_phi),
34 std::cos(el_theta);
35 return vec;
36 }
37 }
38 throw isce3::except::RuntimeError(
39 ISCE_SRCINFO(), "Unknown Spherical Grid Type!");
40}
41
42inline std::vector<typename Frame::Vec3_t> Frame::sphToCart(
43 const std::vector<double>& el_theta,
44 const std::vector<double>& az_phi) const
45{
46 auto size {el_theta.size()};
47 if (size != az_phi.size())
48 throw isce3::except::LengthError(
49 ISCE_SRCINFO(), "Size mismatch between two angle containers!");
50 std::vector<Vec3_t> vec;
51 vec.reserve(size);
52 for (decltype(size) idx = 0; idx < size; ++idx)
53 vec.push_back(sphToCart(el_theta[idx], az_phi[idx]));
54 return vec;
55}
56
57inline std::vector<typename Frame::Vec3_t> Frame::sphToCart(
58 const std::vector<double>& el_theta, double az_phi) const
59{
60 auto size {el_theta.size()};
61 std::vector<Vec3_t> vec;
62 vec.reserve(size);
63 for (const auto& el_tht : el_theta)
64 vec.push_back(sphToCart(el_tht, az_phi));
65 return vec;
66}
67
68inline std::vector<typename Frame::Vec3_t> Frame::sphToCart(
69 double el_theta, const std::vector<double>& az_phi) const
70{
71 auto size {az_phi.size()};
72 std::vector<Vec3_t> vec;
73 vec.reserve(size);
74 for (const auto& azphi : az_phi)
75 vec.push_back(sphToCart(el_theta, azphi));
76 return vec;
77}
78
79inline typename Frame::Vec2_t Frame::cartToSph(Vec3_t vec) const
80{
81 vec.normalize();
82 Vec2_t v_elaz;
83 switch (_grid_type) {
84 case SphGridType::EL_AND_AZ:
85 double theta, phi;
86 theta = std::acos(vec(2));
87 phi = std::atan2(vec(1), vec(0));
88 v_elaz << theta * std::cos(phi), theta * std::sin(phi);
89 return v_elaz;
90
91 case SphGridType::EL_OVER_AZ:
92 v_elaz << std::atan2(vec(0), vec(2)), std::asin(vec(1));
93 return v_elaz;
94
95 case SphGridType::AZ_OVER_EL:
96 v_elaz << std::asin(vec(0)), std::atan2(vec(1), vec(2));
97 return v_elaz;
98
99 case SphGridType::THETA_PHI:
100 v_elaz << std::acos(vec(2)), std::atan2(vec(1), vec(0));
101 return v_elaz;
102 }
103 throw isce3::except::RuntimeError(
104 ISCE_SRCINFO(), "Unknown Spherical Grid Type!");
105}
106
107inline std::vector<typename Frame::Vec2_t> Frame::cartToSph(
108 std::vector<Vec3_t> vec) const
109{
110 std::vector<Vec2_t> vec2;
111 vec2.reserve(vec.size());
112 for (const auto& val3 : vec)
113 vec2.push_back(cartToSph(val3));
114 return vec2;
115}
116
117// non-member regular functions
118inline bool operator==(const Frame& lhs, const Frame& rhs)
119{
120 return (lhs.gridType() == rhs.gridType());
121}
122
123inline bool operator!=(const Frame& lhs, const Frame& rhs)
124{
125 return !(lhs == rhs);
126}
127
128}} // namespace isce3::antenna
A class for antenna frame and spherical-cartesian coordinate transformation.
Definition Frame.h:21
constexpr SphGridType gridType() const
Get grid type enum value.
Definition Frame.h:56
Vec2_t cartToSph(Vec3_t vec) const
Convert from cartesian into spherical coordinate with unit radius.
Definition Frame.icc:79
Vec3_t sphToCart(double el_theta, double az_phi) const
Convert from spherical coordinate with unit radius into cartesian.
Definition Frame.icc:3
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.