Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 Pickett, bobthechemist, Artes, belisarius, rm -rf 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.

3  
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

1 Answer 1

up vote 3 down vote accepted
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}}]}]]

{}

share|improve this answer

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