···11pub mod angle;
22+pub mod axis;
23pub mod point;
34pub mod region;
4556pub use angle::Angle;
77+pub use axis::Axis;
68pub use point::Point;
79pub use region::{Containable, Region};
+18
src/geometry/point.rs
···3344use crate::Region;
5566+use super::Angle;
77+68#[cfg_attr(feature = "web", wasm_bindgen)]
79#[derive(Debug, Clone, Copy, Default, PartialEq)]
810pub struct Point(pub usize, pub usize);
···40424143 pub fn distances(&self, other: &Point) -> (usize, usize) {
4244 (self.0.abs_diff(other.0) + 1, self.1.abs_diff(other.1) + 1)
4545+ }
4646+4747+ pub fn rotated(&self, around: &Point, angle: Angle) -> Point {
4848+ let (dx, dy) = (
4949+ self.0 as f32 - around.0 as f32,
5050+ self.1 as f32 - around.1 as f32,
5151+ );
5252+5353+ let (cos, sin) = angle.cos_sin();
5454+ let new_x = dx * cos - dy * sin;
5555+ let new_y = dx * sin + dy * cos;
5656+5757+ Point(
5858+ (new_x + around.0 as f32) as usize,
5959+ (new_y + around.1 as f32) as usize,
6060+ )
4361 }
4462}
4563