From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Insdie or outside of a volume?
Date: Thu, 2 Feb 2012 19:47:17 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <jgep85$h6i$>
References: <jgdtsa$cnt$> <jge159$mbo$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1328212037 17618 (2 Feb 2012 19:47:17 GMT)
NNTP-Posting-Date: Thu, 2 Feb 2012 19:47:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:756549

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jge159$mbo$>...
> "Nic Roberts" wrote in message <jgdtsa$cnt$>...
> > Hi,
> > 
> > I have an STL file which I can read in so that I get face number, co-ords of each face (triangle) and the normal vector for each face. The faces form a closed volume. 
> > 
> > I would like to create a 3D matrix representation of this volume, with matrix elements representing either inside the volume or outside the volume.
> > 
> > So my question is how do determine if a given coordinate is inside the volume or not?
> For a point P: (x,y,z) count the number n of triangle face {Ti} such that
> 1. (x,y) inside the projection of {Ti} on xy plane (use Tseach function for that)
> 2. zi > z, where zi is coordinate that Ti meat the line { (x,y,t) t in R } (simple linear algebra).
> P is inside the volume if the number n is odd, P is outside otherwise.
> Bruno 
- - - - - - - -
  Another method might be to use outward pointing normals to calculate the signed solid angle projected by each triangle onto a given point (x,y,z).  The algebraic sum of these should be 4*pi if (x,y,z) is interior and 0 otherwise.

Roger Stafford