Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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.

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
up vote 4 down vote accepted
z = RandomReal[UniformDistribution[], {10, 2}]


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


share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.