//! Define a centroid (center of mass) representing
//! a star detection in an unresolved image
//! Centroids are the output of the star extraction process and are used as input to the star matching process.
//!usecrate::Matrix2;usecrate::Vector3;#[derive(Debug, Clone, PartialEq)]pubstructCentroid{pubx:f32, // Centroid position in radians along columns (image x-axis)
puby:f32, // Centroid position in radians along rows (image y-axis)
pubmass:Option<f32>, // Optional "brightness" value that can be used for filtering, but the exact meaning is image-dependent.
pubcov:Option<Matrix2>, // Optional covariance matrix representing the uncertainty in the centroid position.
}implCentroid{/// Unit vector pointing to the centroid's position in camera coordinates.
/// Assumes the camera's optical axis is aligned with the +Z axis, +X points to the right in the image, and +Y points down in the image.
pubfnuvec(&self)-> Vector3{let x =self.x;let y =self.y;// For small angles, we can approximate the unit vector as:
// uvec ≈ (x, y, 1) normalized
let z =1.0;let norm =(x * x + y * y + z * z).sqrt();Vector3::new(x / norm, y / norm, z / norm)}}