comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: something strange with MESH_VOLUME
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: something strange with MESH_VOLUME [message #59583] Wed, 02 April 2008 16:56 Go to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
yingjie, Peng wrote:

> I just want to calculate the volume of a cube with MESH_VOLUME and
> start to test with the following simple code:
>
>
> cube =[[0,0,10] ,[1,0,10] ,[1,1,10] ,[0,1,10] $
> ,[0,0,11] ,[1,0,11] ,[1,1,11] ,[0,1,11] ]
>
> conn=[4,0,1,2,3, $
> 4,0,1,5,4, $
> 4,1,2,6,5, $
> 4,2,3,7,6, $
> 4,3,0,4,7, $
> 4,4,5,6,7]
>
> print,MESH_VOLUME ( cube , conn )
>
> It gives me a volume: 7.66667
> It's just a cube with each length of 1 and the volume should be 1.
> Why is 7.66667 ~~~~>o<~~~~~~
> I have tried one whole night to find the problem but nothing worked.

The answer can be found (maybe) subtly stated in the docs:

"The MESH_VOLUME function computes the volume that the mesh encloses. A
region that a mesh encloses has a positive value for its volume when it
is enclosed by mesh polygons that face outward from the enclosed region.
Outward-facing polygons follow the convention of their vertices being
ordered in a counter-clockwise direction while observing the polygon
from the outside of the enclosed region. Likewise, a region has a
negative value for its volume when it is enclosed by polygons that face
inward to the enclosed region."

Look at the how your polygons are "wound" in your connectivity array.
The first two are counter-clockwise, but the last 4 are clockwise. They
must all be wound CCW to get the correct answer:

cube =[[0,0,10] ,[1,0,10] ,[1,1,10] ,[0,1,10] $
,[0,0,11] ,[1,0,11] ,[1,1,11] ,[0,1,11] ]

conn=[4,0,1,2,3, $
4,0,1,5,4, $
4,1,5,6,2, $
4,2,6,7,3, $
4,0,3,7,4, $
4,5,4,7,6]

print, MESH_VOLUME (cube , conn)

IDL> .GO
1.00000


-Rick
Re: something strange with MESH_VOLUME [message #59666 is a reply to message #59583] Thu, 03 April 2008 13:51 Go to previous message
yingjie, Peng is currently offline  yingjie, Peng
Messages: 11
Registered: March 2006
Junior Member
Dear Rick,

Thanks very much for your kind explanation, which really help.
Actually, I like your RHTgrCamera and DirectInput.dlm on your webpage,
both fancy codes!

with best regards,
yingjie
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDlgrSymbol recompute_dimensions ??
Next Topic: How to compute the merged volume of two 3D objects

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:23:17 PDT 2025

Total time taken to generate the page: 0.00378 seconds