mod compass;
mod corrections;
mod current;
mod solver;
#[cfg(test)]
mod tests;
use crate::angle::{Deviation, Direction, Frame, TrueCourse, Variation};
use crate::units::{Angle, Speed};
pub use compass::{
compass_to_magnetic_by, compass_to_true_by, convert_compass_course_to_magnetic_course,
convert_compass_course_to_true_course, convert_magnetic_course_to_compass_course,
convert_true_course_to_compass_course, magnetic_to_compass_by, true_to_compass_by,
};
pub use corrections::{
bearing_from_relative, calculate_course_angle, compass_to_magnetic, gyro_error_from_transit,
gyro_speed_error, gyro_to_true, magnetic_to_compass, magnetic_to_true, true_to_gyro,
true_to_magnetic,
};
pub use current::{course_over_ground, course_to_steer, estimate_current};
pub const LARGE_VARIATION_DEG: f64 = 15.0;
pub const LARGE_DEVIATION_DEG: f64 = 10.0;
pub const COARSE_TABLE_GAP_DEG: f64 = 45.0;
pub const MAX_ITERATIONS_INVERSE_DEVIATION: u32 = 64;
pub const TOLERANCE_INVERSE_DEVIATION_DEG: f64 = 1e-9;
pub const MAX_BISECTIONS_INVERSE_DEVIATION: u32 = 80;
pub const MAX_GYRO_LATITUDE_DEG: f64 = 85.0;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(clippy::struct_excessive_bools)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Advisories {
pub large_variation: bool,
pub large_deviation: bool,
pub coarse_table: bool,
pub non_invertible_table: bool,
}
impl Advisories {
#[must_use]
pub const fn any(self) -> bool {
self.large_variation
|| self.large_deviation
|| self.coarse_table
|| self.non_invertible_table
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(bound = "")
)]
pub struct CourseSolution<F: Frame> {
pub course: Direction<F>,
pub deviation: Deviation,
pub variation: Variation,
pub total_correction: f64,
pub estimated_error: f64,
pub advisories: Advisories,
}
impl<F: Frame> CourseSolution<F> {
#[must_use]
pub const fn check_data_required(&self) -> bool {
self.advisories.any()
}
}
pub use kinavis_kernel::snapshot::GroundTrack;
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SteeringSolution {
pub heading: TrueCourse,
pub speed_over_ground: Speed,
pub drift_angle: Angle,
}
pub use kinavis_kernel::environment::Current;