aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/state.rs b/src/state.rs
index 90c8147..02a3a85 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -115,17 +115,19 @@ impl State {
Ok(())
}
- fn find_poly(&self) -> Vec<Point> {
- let mut last_line = Line::new(Point::new(0.0, 0.0), Point::new(1.0, 0.0));
+ fn find_poly(&self) -> Vec<&Point> {
+ let p1 = Point::new(0.0, 0.0);
+ let p2 = Point::new(1.0, 0.0);
+ let mut last_line = Line::new(&p1, &p2);
let mut xxx = 100;
- let mut res = vec![self.points[0].clone()];
+ let mut res = vec![&self.points[0]];
loop {
let last = res.last().expect("something in res");
let mut min_theta = TAU;
let mut min_p = &self.points[0];
for p in &self.points {
if !last.equal_pos(p) {
- let l2 = Line::new(last.clone(), p.clone());
+ let l2 = Line::new(last, p);
let theta = last_line.angle_between(&l2);
if theta < min_theta {
min_theta = theta;
@@ -133,8 +135,8 @@ impl State {
}
}
}
- last_line = Line::new(res.last().expect("something in res").clone(), min_p.clone());
- res.push(min_p.clone());
+ last_line = Line::new(res.last().expect("something in res"), min_p);
+ res.push(min_p);
xxx -= 1;
if xxx == 0 || res[0].equal_pos(res.last().expect("something in res")) {