Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Insdie or outside of a volume?

Subject: Insdie or outside of a volume?

From: Nic Roberts

Date: 2 Feb, 2012 12:00:10

Message: 1 of 5

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?

Subject: Insdie or outside of a volume?

From: Bruno Luong

Date: 2 Feb, 2012 12:56:09

Message: 2 of 5

"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

Subject: Insdie or outside of a volume?

From: Roger Stafford

Date: 2 Feb, 2012 19:47:17

Message: 3 of 5

"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

Subject: Insdie or outside of a volume?

From: Adam A

Date: 8 Feb, 2012 09:09:12

Message: 4 of 5

> I would like to create a 3D matrix representation of this volume, with matrix elements representing either inside the volume or outside the volume.

That sounds like you're trying to voxelize the mesh. If so, this function might be useful to you:

http://www.mathworks.co.uk/matlabcentral/fileexchange/27390-mesh-voxelisation

Subject: Insdie or outside of a volume?

From: Nic Roberts

Date: 9 Feb, 2012 10:51:26

Message: 5 of 5

"Adam A" wrote in message <jgte3o$mib$1@newscl01ah.mathworks.com>...
> > I would like to create a 3D matrix representation of this volume, with matrix elements representing either inside the volume or outside the volume.
>
> That sounds like you're trying to voxelize the mesh. If so, this function might be useful to you:
>
> http://www.mathworks.co.uk/matlabcentral/fileexchange/27390-mesh-voxelisation

Thanks for the replies. Y'all have made me do quite a bit of reading to understand what you posted but it was worth it.

And big thanks for the link to the voxeliing code.

Nic

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us