2

Is there such function in Julia?

Desperately trying to migrate to Julia from MATLAB, but still finding myself dependent on it...

aberdysh
  • 1,634
  • 2
  • 13
  • 34

3 Answers3

9

The GeometricalPredicates package has inpolygon: https://github.com/JuliaGeometry/GeometricalPredicates.jl

Jeff Bezanson
  • 3,147
  • 23
  • 26
3

You could also investigate Luxor.jl:

using Luxor

p1 = Point(0,   0)
p2 = Point(10,  0) 
p3 = Point(10, 10) 
p4 = Point(0,  10) 

isinside(Point(5, 5), [p1, p2, p3, p4]) # true

isinside(Point(15, 5), [p1, p2, p3, p4]) # false

But make sure to check for vertex and edge exceptions...

daycaster
  • 2,655
  • 2
  • 15
  • 18
0

The PolygonOps package does point-in-polygon testing too.

It's more user-friendly, but possibly slower, than GeometricalPredicates.

(Hat tip: Julia forum.)

Vectornaut
  • 473
  • 5
  • 11