Path: news.mathworks.com!not-for-mail 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$1@newscl01ah.mathworks.com> References: <jgdtsa$cnt$1@newscl01ah.mathworks.com> <jge159$mbo$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1328212037 17618 172.30.248.37 (2 Feb 2012 19:47:17 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 2 Feb 2012 19:47:17 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:756549 "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jge159$mbo$1@newscl01ah.mathworks.com>... > "Nic Roberts" wrote in message <jgdtsa$cnt$1@newscl01ah.mathworks.com>... > > 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