Galactica/crates/content/src/util.rs

25 lines
435 B
Rust

use nalgebra::{Point2, Vector2};
#[derive(Debug, Clone, Copy)]
pub struct Polar {
/// The center of this polar coordinate
pub center: Point2<f32>,
/// The radius of this polar coordinate
pub radius: f32,
/// In radians
pub angle: f32,
}
impl Polar {
pub fn to_cartesian(self) -> Point2<f32> {
let v = Vector2::new(
self.radius * self.angle.sin(),
self.radius * self.angle.cos(),
);
return self.center + v;
}
}