I have a set of points Z
:
Z = {{x1,y1},{x2,y2},..,}
I would like to obtain a function that returns True
if a new point (does not have to be an element of Z
) {xnew,ynew}
is in the convex hull of Z
and False
if it is not.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have a set of points Z
:
Z = {{x1,y1},{x2,y2},..,}
I would like to obtain a function that returns True
if a new point (does not have to be an element of Z
) {xnew,ynew}
is in the convex hull of Z
and False
if it is not.
z = RandomReal[UniformDistribution[], {10, 2}]
Needs["ComputationalGeometry`"];
A point outside changes the hull...
Complement[z[[ConvexHull[z]]], Apply[#[[ConvexHull[#]]] &, {Join[z, {{-1, 0.5}}]}]]
{{0.142105, 0.343163}}
A point inside does not...
Complement[z[[ConvexHull[z]]], Apply[#[[ConvexHull[#]]] &, {Join[z, {{0.5, 0.5}}]}]]
{}