cad_cs/libs/cs/
abstracts.rs1use std::ops::{Add, Div, Mul, Neg, Sub};
4
5use crate::libs::{angle::AngleFmt, cs::model::Cs};
6
7pub trait AbstractProjectionsCs2 {
10 fn new_from_rf(r: f64, phi_rad: f64) -> Self;
11 fn new_as_xy(&self) -> Cs<3>;
12 fn new_as_xz(&self) -> Cs<3>;
13 fn new_as_yz(&self) -> Cs<3>;
14 fn new_as_xy_from_rf(&self) -> Self;
15 fn new_as_xyz_from_rf_with_z(&self, z: f64) -> Cs<3>;
16 fn new_as_xyz_from_rf_with_y(&self, y: f64) -> Cs<3>;
17 fn new_as_xyz_from_rf_with_x(&self, x: f64) -> Cs<3>;
18}
19
20pub trait AbstractProjectionsCs3 {
23 fn new_from_rft(r: f64, phi_rad: f64, theta_rad: f64) -> Self;
24 fn new_from_rfz(r_d2: f64, phi_rad: f64, z: f64) -> Self;
25 fn new_from_rfx(r_d2: f64, phi_rad: f64, x: f64) -> Self;
26 fn new_from_rfy(r_d2: f64, phi_rad: f64, y: f64) -> Self;
27 fn new_as_xyz_from_rft(&self) -> Cs<3>;
28}
29
30pub trait AbstractMathCsGeneric {
33 fn sub(&self, other: &Self) -> Self;
34 fn add(&self, other: &Self) -> Self;
35 fn dot(&self, other: &Self) -> f64;
36 fn r_sq(&self) -> f64;
37 fn r(&self) -> f64;
38 fn normalize_r_projection(&self) -> Self;
39 fn angle_between(&self, other: &Self) -> f64;
40}
41
42pub trait AbstractMathCs2 {
45 fn rxy(&self) -> f64;
46 fn arctan_y_x(&self) -> f64;
47 fn arctan_x_y(&self) -> f64;
48 fn to_rf_from_xy(&self) -> Cs<2>;
49 fn to_ecef_from_rad_sn_we(&self, r: f64) -> Cs<3>;
50 fn q(&self) -> u8;
51 fn q_sign(&self) -> [&'static str; 2];
52 fn rxy_sq(&self) -> f64;
53 fn cross(&self, other: &Cs<2>) -> f64;
54 fn perp(&self) -> Cs<2>;
55}
56
57pub trait AbstractMathCs3 {
60 fn rxy(&self) -> f64;
61 fn rxz(&self) -> f64;
62 fn ryz(&self) -> f64;
63 fn rxyz(&self) -> f64;
64 fn arctan_y_x(&self) -> f64;
65 fn arctan_z_x(&self) -> f64;
66 fn arctan_z_y(&self) -> f64;
67 fn arctan_x_y(&self) -> f64;
68 fn arctan_x_z(&self) -> f64;
69 fn arctan_y_z(&self) -> f64;
70 fn arccos_x_rxyz(&self) -> f64;
71 fn arccos_y_rxyz(&self) -> f64;
72 fn arccos_z_rxyz(&self) -> f64;
73 fn to_rf_from_xy(&self) -> Cs<2>;
74 fn to_rf_from_xz(&self) -> Cs<2>;
75 fn to_rf_from_yz(&self) -> Cs<2>;
76 fn to_rfx_from_xyz(&self) -> Cs<3>;
77 fn to_rfy_from_xyz(&self) -> Cs<3>;
78 fn to_rfz_from_xyz(&self) -> Cs<3>;
79 fn to_rft_from_xyz(&self) -> Cs<3>;
80 fn to_ecef_from_dms_sn_we(
81 sn_d: i16,
82 sn_m: u8,
83 sn_s: f32,
84 we_d: i16,
85 we_m: u8,
86 we_s: f32,
87 r: f64,
88 ) -> Self;
89 fn to_dms_sn_we_from_xyz(&self) -> crate::libs::cs::model::CoordsSphericalEcefSnWeDms;
90 fn q(&self) -> u8;
91 fn q_sign(&self) -> [&'static str; 3];
92 fn rxyz_sq(&self) -> f64;
93 fn rxy_sq(&self) -> f64;
94 fn rxz_sq(&self) -> f64;
95 fn ryz_sq(&self) -> f64;
96 fn normalize_rxy_projection(&self) -> Cs<3>;
97 fn normalize_rxz_projection(&self) -> Cs<3>;
98 fn normalize_ryz_projection(&self) -> Cs<3>;
99 fn cross(&self, other: &Cs<3>) -> Cs<3>;
100}
101
102pub trait AbstractModelCsGeneric<const N: usize> {
105 fn new(data: [f64; N]) -> Self;
106 fn origin() -> Self;
107 fn as_slice(&self) -> &[f64];
108}
109
110pub trait AbstractHelperCs2 {
115 fn print_q(&self, name: &str);
118
119 fn print_xy(&self, name: &str);
122
123 fn print_rf(&self, name: &str, fmt: AngleFmt);
126
127 fn print(&self, name: &str, fmt: AngleFmt);
130}
131
132pub trait AbstractHelperCs3 {
137 fn print_q(&self, name: &str);
138 fn print_xyz(&self, name: &str);
139 fn print_rft(&self, name: &str, fmt: AngleFmt);
140 fn print_rfx(&self, name: &str, fmt: AngleFmt);
141 fn print_rfy(&self, name: &str, fmt: AngleFmt);
142 fn print_rfz(&self, name: &str, fmt: AngleFmt);
143 fn print_dms_sn_we(&self, name: &str);
144 fn print(&self, name: &str, fmt: AngleFmt);
145}
146
147pub trait AbstractArithmeticCsGeneric:
148 Add<Output = Self>
149 + Sub<Output = Self>
150 + Neg<Output = Self>
151 + Mul<f64, Output = Self>
152 + Div<f64, Output = Self>
153 + Sized {
155 fn add_cs(&self, rhs: &Self) -> Self;
157 fn sub_cs(&self, rhs: &Self) -> Self;
158 fn neg_cs(&self) -> Self;
159 fn mul_scalar(&self, rhs: f64) -> Self;
160 fn div_scalar(&self, rhs: f64) -> Self;
161}
162
163pub trait AbstractSignStrExt {
166 fn sign_str(self) -> &'static str;
169
170 fn sign_sn(self) -> &'static str;
173
174 fn sign_we(self) -> &'static str;
177}