geo_visibility/
lib.rs

1//! This crate contains algorithms to compute [visibility polygon](https://www.wikiwand.com/en/Visibility_polygon).
2//!
3//! This code is a Rust port of the C++ lib [visibility](https://github.com/trylock/visibility).
4//!
5//! # Example
6//!
7//! The following example shows how to compute the visibility polygon of a point amongst line obstacles.  
8//! The [`visibility`] method is provided by the [`Visibility`] trait which is implemented for most [geo-types](https://docs.rs/geo-types/0.4.3/geo_types/).
9//!
10//! ```
11//! # fn main() {
12//! use geo::{Coord, Line};
13//! use geo_visibility::Visibility;
14//!
15//! let point = geo::Point::new(0.0, 0.0);
16//!
17//! let lines = vec![
18//!     Line::new(
19//!         Coord { x: 1.0, y: 1.0 },
20//!         Coord { x: 1.0, y: -1.0 },
21//!     ),
22//!     Line::new(
23//!         Coord { x: -1.0, y: -1.0 },
24//!         Coord { x: -1.0, y: -2.0 },
25//!     ),
26//! ];
27//!
28//! let visibility_polygon = point.visibility(lines.as_slice());
29//! # }
30//! ```
31//!
32//! [`Visibility`]: visibility/trait.Visibility.html
33//! [`visibility`]: visibility/trait.Visibility.html#method.visibility
34
35mod angle_comparator;
36mod comparable_line;
37mod orientation;
38mod ray;
39mod utils;
40mod visibility;
41mod visibility_event;
42
43pub use visibility::Visibility;