Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mbattifarano authored and frewsxcv committed Jun 3, 2017
1 parent 8cf5c92 commit 4ca324f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/algorithm/intersects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ impl<T> Intersects<Point<T>> for Line<T>
let ty = if dy == T::zero() {None} else {Some((p.y() - self.start.y()) / dy)};
match (tx, ty) {
(None, None) => { // Degenerate line
println!("degenerate");
*p == self.start
},
(Some(t), None) => { // Horizontal line
println!("horizontal");
p.y() == self.start.y() &&
T::zero() <= t &&
t <= T::one()
},
(None, Some(t)) => { // Vertical line
println!("vertical");
p.x() == self.start.x() &&
T::zero() <= t &&
t <= T::one()
Expand Down Expand Up @@ -84,14 +81,14 @@ impl<T> Intersects<Line<T>> for Line<T>
let d = a1*b2 - a2*b1;
if d == T::zero() {
// lines are parallel
// return true iff line and self are co-linear
self.start.intersects(&line) | self.end.intersects(&line) |
line.start.intersects(&self) | line.end.intersects(&self)
// return true iff at least one endpoint intersects the other line
self.start.intersects(&line) || self.end.intersects(&line) ||
line.start.intersects(&self) || line.end.intersects(&self)
} else {
let s = (c1*b2 - c2*b1) / d;
let t = (a1*c2 - a2*c1) / d;
(T::zero() <= s) & (s <= T::one()) &
(T::zero() <= t) & (t <= T::one())
(T::zero() <= s) && (s <= T::one()) &&
(T::zero() <= t) && (t <= T::one())
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/algorithm/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ impl<T> RotatePoint<T> for Line<T>
let pts = vec![self.start, self.end];
let rotated = rotation_matrix(angle, point, &pts);
Line::new(rotated[0], rotated[1])

}
}

Expand Down

0 comments on commit 4ca324f

Please sign in to comment.