visioncortex/
polar.rs

1use crate::Point2;
2use num_traits::Float;
3
4/// Polar coordinate in 2D space
5#[derive(Default, Debug, Clone, Copy, PartialEq)]
6pub struct Polar2<F: Float> {
7    /// angle
8    pub a: F,
9    /// radius
10    pub r: F,
11}
12
13impl<F: Float> Polar2<F> {
14    pub fn to_point(&self) -> Point2<F> {
15        Point2 {
16            x: self.r * self.a.cos(),
17            y: self.r * self.a.sin(),
18        }
19    }
20}
21
22/// 2D Polar with `f64` component
23pub type PolarF64 = Polar2<f64>;