Creating a polygon of many points in Julia


#1

I want to use something similar to Matlab’s inpolygon function and found this example in Julia:

lr = Point(1.2,1.0)
ur = Point(1.2,1.2)
ul = Point(1.0,1.2)
poly = Polygon(ll, lr, ur)
inpolygon(poly, Point(1.1,1.1)) 

This seems like exactly what I need but I need to add around 50 points so it’s not possible to add them manually as in this example. I tried to create the polygon by adding the points as a vector (in that case I could create an array of my points with a loop). This is what I tried:

r=[lr,ur,ul]
poly=Polygon(r)

but I got an error message, Polygon can apparently not accept an array of points. How do I create a polygon with many points in Julia?


#2

Try

Polygon(r...)

PS: Making your example self-contained would be helpful. Otherwise, we have to guess that you are using GeometricalPredicates.


#3

Thank you, it worked!
Of course, I’ll do that next time!