Re: Points In/Out in 3D shapes
- To: mathgroup at smc.vnet.net
- Subject: [mg101283] Re: Points In/Out in 3D shapes
- From: M <xrayspectrum at googlemail.com>
- Date: Tue, 30 Jun 2009 06:31:43 -0400 (EDT)
- References: <h1vm8i$afl$1@smc.vnet.net> <h229bl$hup$1@smc.vnet.net>
On Jun 26, 12:53 pm, Jens-Peer Kuska <ku... at informatik.uni-leipzig.de>
wrote:
> 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
Thank you for your genereous replies ..
I am working on it.
cheeers