fix bug teta detection close of 0.0 and add readme

This commit is contained in:
2025-05-31 17:16:22 +02:00
parent fbf5ccbd5e
commit 4548aea909
3 changed files with 8 additions and 3 deletions

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# Polymusic

View File

@@ -52,8 +52,8 @@ impl MyApp {
teta: 0.0, teta: 0.0,
polygons: vec![ polygons: vec![
//Polygon::n_gon(0.0, 12), //Polygon::n_gon(0.0, 12),
Polygon::triangle(0.1), Polygon::triangle(0.0),
Polygon::square(1.0), Polygon::square(PI / 4.0),
], ],
}, },
}, },

View File

@@ -110,10 +110,13 @@ pub struct Polygon {
#[warn(dead_code)] #[warn(dead_code)]
impl Polygon { impl Polygon {
pub fn have_points_btw(&self, before: f32, after: f32) -> bool { pub fn have_points_btw(&self, before: f32, after: f32) -> bool {
if after < before {
return self.have_points_btw(before, 2.0 * PI) || self.have_points_btw(0.0, after);
}
let mut p_g; let mut p_g;
for p in self.points_teta.clone() { for p in self.points_teta.clone() {
p_g = p + self.global_teta; p_g = p + self.global_teta;
if before < p_g && p_g < after { if before <= p_g && p_g <= after {
return true; return true;
} }
if p_g > after { if p_g > after {