Polygonal button for touch interface from set of coordinates

Hi all,

I am currently working on a project that has a touch interface, where the user can zoom in on predefined regions on a map by touching them. I want to make neat buttons that cover exactly the area of the selected region, not a bunch of squares scattered all over them, this would be a lot of work, since a great number of regions must be mapped.

Thus, my problem is, is there a way to create a touchable region, somthing like a button, i.e., an irregular polygon, from a set of xy coordinates?

I searched very quickly through the new site and find nothing that can solve my problem. I know I can create a mesh over this set of coordinates and use it with Button (3d Mesh) module, but this would still be a lot of work. I don’t want to create a mesh out of every region on the map that is touchable.

Thanks in advance!

My idea would be to use 2 ConvexHull (2d) nodes. One is fed with the x/y of your polygon, the other is fed with the same points + your touch point(s) (node:Cons (Spreads). If both hulls match (i.e. a = (Value) comparison of the convex hull vertices returns true in every slice) your point is inside the area, otherwise it’s not.
As the name suggests this would only work for convex polygons.

Hi you can try use delanuay node to convert all your pre-mapped regions to meshes.

HitTest (2d Polygon) by fellow @vux should do exactly what you need

Hello, thanks for all the replies.

I ended up implementing the ray casting algorithm. It’s two subpatches, one that detects if two segments actually intersect each other, and also one that sums up all of the intersections between the casted ray (to the point) and all segments that form up a polygon.

I was curious, though, with the HitTest node. It might be useful for future projects. But I couldn’t use it. Still not using vvv45, I’m still in vvvv40beta24, but I downloaded the latest addon pack. Still it didn’t show up in the node list. How do I do it? It only works in vvvv45?

Thanks!

IntersectingLines.v4p (33.0 kB)
PointInsidePolygon.v4p (8.2 kB)