Galactica/crates/content/src/util.rs

20 lines
352 B
Rust

use cgmath::{Angle, Deg, Point2, Vector2};
#[derive(Debug, Clone, Copy)]
pub struct Polar {
pub center: Point2<f32>,
pub radius: f32,
pub angle: Deg<f32>,
}
impl Polar {
pub fn to_cartesian(self) -> Point2<f32> {
let v = Vector2 {
x: self.radius * self.angle.sin(),
y: self.radius * self.angle.cos(),
};
return self.center + v;
}
}