rust/landgen/src/outline.rs
changeset 14044 aeac678d7c79
parent 14043 1ac129df8e5b
parent 14038 bf77c4d2294f
child 14045 128fbd36eee4
--- a/rust/landgen/src/outline.rs	Tue Oct 30 23:51:01 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-use integral_geometry::Point;
-
-pub struct Outline {
-    points: Vec<Point>,
-}
-
-fn check_intersect(
-    segment1_start: &Point,
-    segment1_end: &Point,
-    segment2_start: &Point,
-    segment2_end: &Point,
-) -> bool {
-    let dm: i32 = (segment2_end.y - segment2_start.y) * (segment1_end.x - segment1_start.x)
-        - (segment2_end.x - segment2_start.x) * (segment1_end.y - segment1_start.y);
-
-    if dm == 0 {
-        return false;
-    }
-
-    let c1: i32 = (segment2_end.x - segment2_start.x) * (segment1_start.y - segment2_start.y)
-        - (segment2_end.y - segment2_start.y) * (segment1_start.x - segment2_start.x);
-
-    if dm > 0 {
-        if (c1 < 0) || (c1 > dm) {
-            return false;
-        }
-    } else {
-        if (c1 > 0) || (c1 < dm) {
-            return false;
-        }
-    }
-
-    let c2: i32 = (segment1_end.x - segment2_start.x) * (segment1_start.y - segment2_start.y)
-        - (segment1_end.y - segment2_start.y) * (segment1_start.x - segment2_start.x);
-
-    if dm > 0 {
-        if (c2 < 0) || (c2 > dm) {
-            return false;
-        }
-    } else {
-        if (c2 > 0) || (c2 < dm) {
-            return false;
-        }
-    }
-
-    true
-}
-
-impl Outline {
-    fn check_intersects_self_at_index(&self, index: usize) -> bool {
-        if index <= 0 || index > self.points.len() {
-            return false;
-        }
-
-        for i in 1..=self.points.len() - 3 {
-            if i <= index - 1 || i >= index + 2 {
-                if i != index - 1 && check_intersect(
-                    &self.points[index],
-                    &self.points[index - 1],
-                    &self.points[i],
-                    &self.points[i - 1],
-                ) {
-                    return true;
-                }
-                if i != index + 2 && check_intersect(
-                    &self.points[index],
-                    &self.points[index + 1],
-                    &self.points[i],
-                    &self.points[i - 1],
-                ) {
-                    return true;
-                }
-            }
-        }
-
-        false
-    }
-}
-
-#[cfg(test)]
-#[test]
-fn intersection() {
-    let p1 = Point { x: 0, y: 0 };
-    let p2 = Point { x: 0, y: 10 };
-    let p3 = Point { x: -5, y: 5 };
-    let p4 = Point { x: 5, y: 5 };
-    let p5 = Point { x: 5, y: 16 };
-
-    assert!(check_intersect(&p1, &p2, &p3, &p4));
-    assert!(!check_intersect(&p1, &p2, &p3, &p5));
-}