Skip to content

Commit

Permalink
Complete 'Usage' section
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed Dec 17, 2020
1 parent 2b1f5bb commit 111f8c6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ python setup.py install
Usage
-----

With segments (defined as pairs of endpoints' coordinates)
With segments
```python
>>> unit_segments = [((0., 0.), (1., 0.)),
... ((0., 0.), (0., 1.))]
>>> from ground.geometries import to_point_cls, to_segment_cls
>>> Point, Segment = to_point_cls(), to_segment_cls()
>>> unit_segments = [Segment(Point(0, 0), Point(1, 0)),
... Segment(Point(0, 0), Point(0, 1))]

```
we can check if they intersect
Expand All @@ -62,16 +64,18 @@ True
we can also find in which points segments intersect
```python
>>> from bentley_ottmann.planar import segments_intersections
>>> segments_intersections(unit_segments)
{(0.0, 0.0): {(0, 1)}}
>>> segments_intersections(unit_segments) == {(0, 0): {(0, 1)}}
True

```
here we can see that `0`th and `1`st segments intersect at point `(0.0, 0.0)`.
here we can see that `0`th and `1`st segments intersect at point `(0, 0)`.

With polygons (defined as sequence of vertices' coordinates)
With contours
```python
>>> triangle = [(0., 0.), (1., 0.), (0., 1.)]
>>> degenerate_triangle = [(0., 0.), (2., 0.), (1., 0.)]
>>> from ground.geometries import to_contour_cls
>>> Contour = to_contour_cls()
>>> triangle = Contour([Point(0, 0), Point(1, 0), Point(0, 1)])
>>> degenerate_triangle = Contour([Point(0, 0), Point(2, 0), Point(1, 0)])

```
we can check if they are self-intersecting or not
Expand Down

0 comments on commit 111f8c6

Please sign in to comment.