Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Points In/Out in 3D shapes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101206] Re: Points In/Out in 3D shapes
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 26 Jun 2009 06:54:27 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <h1vm8i$afl$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

if your shaped object is an implicit function like
x^2+y^2+z^2-1  for a sphere of radius 1 than the sign
of this implicit function serve as inside/ outside indicator.
If you object is build up from tetrahedrons you mist check if
the point is in one of the tetrahedrons.
If you have just the surface of the 3d object you must
split the object into tetrahedrons first.

Regards
   Jens
M wrote:
> Hallo All Mathematica gurus,
> I have the following code which helps to find if a point is inside or
> outside the 2D polygon.
> 
> pnPoly[{testx_, testy_}, pts_List] :=
>  Xor @@ ((Xor[#[[1, 2]] > testy, #[[2, 2]] >
>          testy] && ((testx - #[[2,
>             1]]) < (#[[1, 1]] - #[[2,
>              1]]) (testy - #[[2, 2]])/(#[[1, 2]] - #[[2, 2]]))) & /@
>     Partition[pts, 2, 1, {2, 2}])
> 
> 
> pol = {{-1, -1}, {0, 0}, {1, -1}, {0, 1}, {1, 0}};
> Graphics[{PointSize[Large], {FaceForm[LightGray], EdgeForm[Black],
>    Polygon[pol]},
>   If[pnPoly[#, pol], {Blue, Point[#]}, {Red, Point[#]}] & /@
>    RandomReal[{-1, 1}, {400, 2}]}]
> Clear[pol]
> 
> Ok. this works really good!.
> How can I test if a random point is inside or outside in a given
> volume of any 3D shaped object.
> I need to count the points that are inside the volume. Any
> suggestons ?
> 
> 
> Thank you in advance
> 
> 


  • Prev by Date: Re: Points In/Out in 3D shapes
  • Next by Date: Re: Plot with x value in Log
  • Previous by thread: Re: Points In/Out in 3D shapes
  • Next by thread: Re: Points In/Out in 3D shapes