aberdysh
aberdysh

Reputation: 1664

Julia's equivalent of MATLAB's inpolygon()

Is there such function in Julia?

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

Upvotes: 2

Views: 1241

Answers (3)

Vectornaut
Vectornaut

Reputation: 531

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

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

(Hat tip: Julia forum.)

Upvotes: 0

daycaster
daycaster

Reputation: 2707

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...

Upvotes: 3

Jeff Bezanson
Jeff Bezanson

Reputation: 3207

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

Upvotes: 10

Related Questions