Galactica/crates/util/src/lib.rs

20 lines
442 B
Rust

#![warn(missing_docs)]
//! Various utilities
use nalgebra::Vector2;
pub mod constants;
pub mod timing;
/// Convert an angle in degrees to radians
pub fn to_radians(degrees: f32) -> f32 {
return (degrees / 360.0) * std::f32::consts::TAU;
}
/// Compute the clockwise angle between two vectors
/// Returns a value in [-pi, pi]
pub fn clockwise_angle(a: &Vector2<f32>, b: &Vector2<f32>) -> f32 {
(a.x * b.y - b.x * a.y).atan2(a.dot(&b))
}