Skip to content

Commit da9237d

Browse files
committed
Fix pedantic warnings
1 parent 860697f commit da9237d

File tree

16 files changed

+493
-147
lines changed

16 files changed

+493
-147
lines changed

swiftnav/src/coords/ecef.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl ECEF {
5050
let p = (self.x() * self.x() + self.y() * self.y()).sqrt();
5151

5252
// Compute longitude first, this can be done exactly.
53-
let longitude = if p != 0.0 {
54-
self.y().atan2(self.x())
55-
} else {
53+
let longitude = if p == 0.0 {
5654
0.0
55+
} else {
56+
self.y().atan2(self.x())
5757
};
5858

5959
// If we are close to the pole then convergence is very slow, treat this is a
@@ -171,7 +171,7 @@ impl ECEF {
171171
/// Rotate this ECEF vector into NED coordinates, at a given
172172
/// reference point. This is approporiate for converting velocity vectors.
173173
///
174-
/// This is the inverse of [NED::ecef_vector_at].
174+
/// This is the inverse of [`NED::ecef_vector_at`].
175175
#[must_use]
176176
pub fn ned_vector_at(&self, point: &ECEF) -> NED {
177177
let m = math::ecef2ned_matrix(point.to_llh());

swiftnav/src/coords/llh.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ impl LLHRadians {
128128
///
129129
/// Uses the [`WGS84`] Ellipsoid
130130
#[must_use]
131+
#[allow(clippy::many_single_char_names)] // It's math, whatyagonnado?
131132
pub fn to_ecef(&self) -> ECEF {
132133
let d = WGS84::E * (self.latitude()).sin();
133134
let n = WGS84::A / (1. - d * d).sqrt();

swiftnav/src/coords/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//! Coordinates and conversions
1111
//!
1212
//! These four coordinates types are defined:
13-
//! * [LLHDegrees]/[LLHRadians] - Geodetic coordinates, Latitude Lontitude Height
13+
//! * [`LLHDegrees`]/[`LLHRadians`] - Geodetic coordinates, Latitude Lontitude Height
1414
//! * [ECEF] - Cartesian coordinates, Earth Centered, Earth Fixed
1515
//! * [NED] - Local direction coordinates, North East Down
16-
//! * [AzimuthElevation] - Relative direction coordinates, Azimith Elevation
16+
//! * [`AzimuthElevation`] - Relative direction coordinates, Azimith Elevation
1717
//!
1818
//! # Geodetic to Cartesian
1919
//!
@@ -242,6 +242,11 @@ impl Coordinate {
242242
}
243243

244244
/// Transform the coordinate from into a new reference frame
245+
///
246+
/// # Errors
247+
///
248+
/// An error is returned if a transformation from the coordinate's reference frame to the requested
249+
/// reference frame could not be found.
245250
pub fn transform_to(&self, new_frame: ReferenceFrame) -> Result<Self, TransformationNotFound> {
246251
get_transformation(self.reference_frame, new_frame)
247252
.map(|transformation| transformation.transform(self))

swiftnav/src/coords/ned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl NED {
4242
/// Rotate a local [`NED`] vector into a [`ECEF`] vector, at a given
4343
/// reference point. This is approporiate for converting velocity vectors.
4444
///
45-
/// This is the inverse of [ECEF::ned_vector_at].
45+
/// This is the inverse of [`ECEF::ned_vector_at`].
4646
#[must_use]
4747
pub fn ecef_vector_at(&self, ref_ecef: &ECEF) -> ECEF {
4848
let m = math::ecef2ned_matrix(ref_ecef.to_llh());

swiftnav/src/edc.rs

Lines changed: 259 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,262 @@
4141
//! ```
4242
4343
const CRC24Q_TABLE: [u32; 256] = [
44-
0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, 0xA18139,
45-
0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, 0xC54E89, 0x430272,
46-
0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, 0x64CFB0, 0xE2834B, 0xEE1ABD,
47-
0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, 0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F,
48-
0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631,
49-
0xB8FACA, 0xB4633C, 0x322FC7, 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A,
50-
0xD0AC8C, 0x56E077, 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5,
51-
0xF7614E, 0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5,
52-
0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC, 0xDCED5B,
53-
0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C, 0x7D6C62, 0xFB2099,
54-
0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, 0x15723B, 0x933EC0, 0x9FA736,
55-
0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4,
56-
0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15, 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53,
57-
0xC596A8, 0xC90F5E, 0x4F43A5, 0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791,
58-
0x688E67, 0xEEC29C, 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448,
59-
0xAC38B3, 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A,
60-
0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, 0x578814,
61-
0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, 0x3F964D, 0xB9DAB6,
62-
0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A, 0x9E1774, 0x185B8F, 0x14C279,
63-
0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863, 0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132,
64-
0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, 0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C,
65-
0x4EF3E7, 0x426A11, 0xC426EA, 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C,
66-
0x33D79A, 0xB59B61, 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3,
67-
0x141A58, 0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8,
68-
0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, 0x26359F,
69-
0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88, 0x87B4A6, 0x01F85D,
70-
0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, 0xE37B16, 0x6537ED, 0x69AE1B,
71-
0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9,
72-
0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538,
44+
0x0000_0000,
45+
0x0086_4CFB,
46+
0x008A_D50D,
47+
0x000C_99F6,
48+
0x0093_E6E1,
49+
0x0015_AA1A,
50+
0x0019_33EC,
51+
0x009F_7F17,
52+
0x00A1_8139,
53+
0x0027_CDC2,
54+
0x002B_5434,
55+
0x00AD_18CF,
56+
0x0032_67D8,
57+
0x00B4_2B23,
58+
0x00B8_B2D5,
59+
0x003E_FE2E,
60+
0x00C5_4E89,
61+
0x0043_0272,
62+
0x004F_9B84,
63+
0x00C9_D77F,
64+
0x0056_A868,
65+
0x00D0_E493,
66+
0x00DC_7D65,
67+
0x005A_319E,
68+
0x0064_CFB0,
69+
0x00E2_834B,
70+
0x00EE_1ABD,
71+
0x0068_5646,
72+
0x00F7_2951,
73+
0x0071_65AA,
74+
0x007D_FC5C,
75+
0x00FB_B0A7,
76+
0x000C_D1E9,
77+
0x008A_9D12,
78+
0x0086_04E4,
79+
0x0000_481F,
80+
0x009F_3708,
81+
0x0019_7BF3,
82+
0x0015_E205,
83+
0x0093_AEFE,
84+
0x00AD_50D0,
85+
0x002B_1C2B,
86+
0x0027_85DD,
87+
0x00A1_C926,
88+
0x003E_B631,
89+
0x00B8_FACA,
90+
0x00B4_633C,
91+
0x0032_2FC7,
92+
0x00C9_9F60,
93+
0x004F_D39B,
94+
0x0043_4A6D,
95+
0x00C5_0696,
96+
0x005A_7981,
97+
0x00DC_357A,
98+
0x00D0_AC8C,
99+
0x0056_E077,
100+
0x0068_1E59,
101+
0x00EE_52A2,
102+
0x00E2_CB54,
103+
0x0064_87AF,
104+
0x00FB_F8B8,
105+
0x007D_B443,
106+
0x0071_2DB5,
107+
0x00F7_614E,
108+
0x0019_A3D2,
109+
0x009F_EF29,
110+
0x0093_76DF,
111+
0x0015_3A24,
112+
0x008A_4533,
113+
0x000C_09C8,
114+
0x0000_903E,
115+
0x0086_DCC5,
116+
0x00B8_22EB,
117+
0x003E_6E10,
118+
0x0032_F7E6,
119+
0x00B4_BB1D,
120+
0x002B_C40A,
121+
0x00AD_88F1,
122+
0x00A1_1107,
123+
0x0027_5DFC,
124+
0x00DC_ED5B,
125+
0x005A_A1A0,
126+
0x0056_3856,
127+
0x00D0_74AD,
128+
0x004F_0BBA,
129+
0x00C9_4741,
130+
0x00C5_DEB7,
131+
0x0043_924C,
132+
0x007D_6C62,
133+
0x00FB_2099,
134+
0x00F7_B96F,
135+
0x0071_F594,
136+
0x00EE_8A83,
137+
0x0068_C678,
138+
0x0064_5F8E,
139+
0x00E2_1375,
140+
0x0015_723B,
141+
0x0093_3EC0,
142+
0x009F_A736,
143+
0x0019_EBCD,
144+
0x0086_94DA,
145+
0x0000_D821,
146+
0x000C_41D7,
147+
0x008A_0D2C,
148+
0x00B4_F302,
149+
0x0032_BFF9,
150+
0x003E_260F,
151+
0x00B8_6AF4,
152+
0x0027_15E3,
153+
0x00A1_5918,
154+
0x00AD_C0EE,
155+
0x002B_8C15,
156+
0x00D0_3CB2,
157+
0x0056_7049,
158+
0x005A_E9BF,
159+
0x00DC_A544,
160+
0x0043_DA53,
161+
0x00C5_96A8,
162+
0x00C9_0F5E,
163+
0x004F_43A5,
164+
0x0071_BD8B,
165+
0x00F7_F170,
166+
0x00FB_6886,
167+
0x007D_247D,
168+
0x00E2_5B6A,
169+
0x0064_1791,
170+
0x0068_8E67,
171+
0x00EE_C29C,
172+
0x0033_47A4,
173+
0x00B5_0B5F,
174+
0x00B9_92A9,
175+
0x003F_DE52,
176+
0x00A0_A145,
177+
0x0026_EDBE,
178+
0x002A_7448,
179+
0x00AC_38B3,
180+
0x0092_C69D,
181+
0x0014_8A66,
182+
0x0018_1390,
183+
0x009E_5F6B,
184+
0x0001_207C,
185+
0x0087_6C87,
186+
0x008B_F571,
187+
0x000D_B98A,
188+
0x00F6_092D,
189+
0x0070_45D6,
190+
0x007C_DC20,
191+
0x00FA_90DB,
192+
0x0065_EFCC,
193+
0x00E3_A337,
194+
0x00EF_3AC1,
195+
0x0069_763A,
196+
0x0057_8814,
197+
0x00D1_C4EF,
198+
0x00DD_5D19,
199+
0x005B_11E2,
200+
0x00C4_6EF5,
201+
0x0042_220E,
202+
0x004E_BBF8,
203+
0x00C8_F703,
204+
0x003F_964D,
205+
0x00B9_DAB6,
206+
0x00B5_4340,
207+
0x0033_0FBB,
208+
0x00AC_70AC,
209+
0x002A_3C57,
210+
0x0026_A5A1,
211+
0x00A0_E95A,
212+
0x009E_1774,
213+
0x0018_5B8F,
214+
0x0014_C279,
215+
0x0092_8E82,
216+
0x000D_F195,
217+
0x008B_BD6E,
218+
0x0087_2498,
219+
0x0001_6863,
220+
0x00FA_D8C4,
221+
0x007C_943F,
222+
0x0070_0DC9,
223+
0x00F6_4132,
224+
0x0069_3E25,
225+
0x00EF_72DE,
226+
0x00E3_EB28,
227+
0x0065_A7D3,
228+
0x005B_59FD,
229+
0x00DD_1506,
230+
0x00D1_8CF0,
231+
0x0057_C00B,
232+
0x00C8_BF1C,
233+
0x004E_F3E7,
234+
0x0042_6A11,
235+
0x00C4_26EA,
236+
0x002A_E476,
237+
0x00AC_A88D,
238+
0x00A0_317B,
239+
0x0026_7D80,
240+
0x00B9_0297,
241+
0x003F_4E6C,
242+
0x0033_D79A,
243+
0x00B5_9B61,
244+
0x008B_654F,
245+
0x000D_29B4,
246+
0x0001_B042,
247+
0x0087_FCB9,
248+
0x0018_83AE,
249+
0x009E_CF55,
250+
0x0092_56A3,
251+
0x0014_1A58,
252+
0x00EF_AAFF,
253+
0x0069_E604,
254+
0x0065_7FF2,
255+
0x00E3_3309,
256+
0x007C_4C1E,
257+
0x00FA_00E5,
258+
0x00F6_9913,
259+
0x0070_D5E8,
260+
0x004E_2BC6,
261+
0x00C8_673D,
262+
0x00C4_FECB,
263+
0x0042_B230,
264+
0x00DD_CD27,
265+
0x005B_81DC,
266+
0x0057_182A,
267+
0x00D1_54D1,
268+
0x0026_359F,
269+
0x00A0_7964,
270+
0x00AC_E092,
271+
0x002A_AC69,
272+
0x00B5_D37E,
273+
0x0033_9F85,
274+
0x003F_0673,
275+
0x00B9_4A88,
276+
0x0087_B4A6,
277+
0x0001_F85D,
278+
0x000D_61AB,
279+
0x008B_2D50,
280+
0x0014_5247,
281+
0x0092_1EBC,
282+
0x009E_874A,
283+
0x0018_CBB1,
284+
0x00E3_7B16,
285+
0x0065_37ED,
286+
0x0069_AE1B,
287+
0x00EF_E2E0,
288+
0x0070_9DF7,
289+
0x00F6_D10C,
290+
0x00FA_48FA,
291+
0x007C_0401,
292+
0x0042_FA2F,
293+
0x00C4_B6D4,
294+
0x00C8_2F22,
295+
0x004E_63D9,
296+
0x00D1_1CCE,
297+
0x0057_5035,
298+
0x005B_C9C3,
299+
0x00DD_8538,
73300
];
74301

75302
/// Calculate Qualcomm 24-bit Cyclical Redundancy Check (CRC-24Q).
@@ -89,10 +316,10 @@ const CRC24Q_TABLE: [u32; 256] = [
89316
/// Only the lower 24 bits of the initial value are used!
90317
#[must_use]
91318
pub fn compute_crc24q(buf: &[u8], initial_value: u32) -> u32 {
92-
let mut crc = initial_value & 0xFFFFFF;
319+
let mut crc = initial_value & 0x00FF_FFFF;
93320
for &byte in buf {
94-
let index = ((crc >> 16) ^ byte as u32) as usize & 0xFF;
95-
crc = ((crc << 8) & 0xFFFFFF) ^ CRC24Q_TABLE[index];
321+
let index = ((crc >> 16) ^ u32::from(byte)) as usize & 0xFF;
322+
crc = ((crc << 8) & 0x00FF_FFFF) ^ CRC24Q_TABLE[index];
96323
}
97324
crc
98325
}

swiftnav/src/math.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ pub(crate) const fn compile_time_max_u16(a: u16, b: u16) -> u16 {
3535
///
3636
/// - This function is marked as `const`, allowing it to be evaluated at compile time.
3737
/// - The algorithm iteratively refines the approximation of the square root until the result stabilizes.
38+
#[allow(clippy::many_single_char_names)] // This is pure math, single character names are used in the source material
3839
pub(crate) const fn compile_time_sqrt(s: f64) -> f64 {
3940
let mut x = s;
4041
let mut y = 0.0;
4142
let mut z;
4243
let mut i = 0;
44+
#[allow(clippy::float_cmp)] // We intentionally iterate until the values stop changing
4345
while y != x {
4446
y = x;
4547
z = s / y;
46-
x = (y + z) / 2.0;
48+
x = f64::midpoint(y, z);
4749
i += 1;
4850
}
49-
if i > 100 {
50-
panic!("SLOW_SQRT failed to converge");
51-
}
51+
assert!((i <= 100), "SLOW_SQRT failed to converge");
5252
x
5353
}
5454

0 commit comments

Comments
 (0)