MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Convex hull iin 3-D, anyone?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84831] Re: Convex hull iin 3-D, anyone?
  • From: Valeri Astanoff <astanoff at gmail.com>
  • Date: Wed, 16 Jan 2008 03:25:26 -0500 (EST)
  • References: <fmhqqh$brd$1@smc.vnet.net>

On 15 jan, 09:28, Steve Gray <stev... at roadrunner.com> wrote:
> Can anyone point me to a Mathematica function that computes the convex hull of
> a set of points in 3 dimensions? Speed is not very important and I
> don't need to do a large number of points, probably less than 20.
> Thank you for any information.
>
> Steve Gray

Good day,

Here is a toy solution:

In[1]:= hullQ[{x_,y_,z_},pts_List]:=
Module[{pl,a,b,c,d,fi},
pl[{x0_,y0_,z0_}]=a x0+b y0+c z0+d;
fi=FindInstance[Not[a==0&&b==0&&c==0&&d==0]&&pl[{x,y,z}]==0&&
(And@@(pl[#]>=0&/@pts)||
 And@@(pl[#]<=0&/@pts)),
{a,b,c,d},Reals];
Length[fi]>0
];

In[2]:=
pts=Table[{RandomInteger[{0,10}],RandomInteger[{0,10}],RandomInteger[{0,10}]},
{20}]

Out[2]= {{5,10,0},{8,0,1},{10,9,10},{4,7,6},{0,9,4},
{2,0,8},{3,4,3},{9,4,9},{5,6,5},{2,0,3},
{3,9,5},{6,5,1},{10,0,10},{8,6,3},{5,6,3},
{6,8,5},{9,4,0},{2,8,0},{10,4,8},{0,9,4}}

In[3]:= Select[pts,hullQ[#,pts]&]

Out[3]= {{5,10,0},{8,0,1},{10,9,10},{0,9,4},{2,0,8},
{2,0,3},{10,0,10},{9,4,0},{2,8,0},{10,4,8},{0,9,4}}


hth

V.Astanoff


  • Prev by Date: ClearAll["Global`*"] does not clear all in version 6
  • Next by Date: Version 6 graphics can be painfully slow
  • Previous by thread: Re: Convex hull iin 3-D, anyone?
  • Next by thread: Creating a Legend with ListPlot using PlotMarkers