# Return “true” if point is in Convex Hull [duplicate]

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.

-

## marked as duplicate by C. E., bobthechemist, Artes, Dr. belisarius, R. M.♦Dec 19 '13 at 16:47

When you say "in the convex hull" do you mean is it one of the points within the hull set itself (or possibly lying on one of the lines between the vertices of the hull) or do you simply mean is the point somewhere inside? If the latter then the comment above applies OR you could just add your point to the hull set and rerun the convex hull calculation just on this. If your point is inside the hull then your point would be removed again and the hull set will not change. – Ymareth Dec 19 '13 at 10:57

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}}]}]]
`

{}

-