1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//! Rotation use crate::{Angle, Ellipse, P2}; pub trait Rotate { fn rotate(self, pivot: P2, theta: Angle) -> Self; } impl Rotate for P2 { fn rotate(self, pivot: P2, theta: Angle) -> Self { let radius = (self - pivot).length(); let current = Ellipse::circle(pivot, radius); let current_theta = current.circumphase(&self); current.circumpoint(current_theta + theta) } }