POV-Ray : Newsgroups : povray.general : Volume of a 3d mesh Server Time
10 Aug 2024 17:30:02 EDT (-0400)
  Volume of a 3d mesh (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Lance Birch
Subject: Re: Volume of a 3d mesh
Date: 9 Dec 1999 21:35:58
Message: <3850670e@news.povray.org>
Just buy MAX, it'll do that for you and then be able to apply dynamics to
all the objects in your scene :)  Oh, plus it'll find the pivot point
center-of-gravity for any object too, ain't that handy :)

--
Lance.
The Zone - http://come.to/the.zone
Bill DeWitt <the### [at] earthlinknet> wrote in message
news:3850378c@news.povray.org...
>
> "Ken" <tyl### [at] pcabellnet> wrote :
> >
> > That's the only excuse you need to buy Rhino ?
> >
>
>     That is the one I need to get it past my Poverty Filter. If I could
use
> it to even possibly, maybe, someday help my income -somehow-, I could
> rationalize the rest.
>
>


Post a reply to this message

From: Ken
Subject: Re: Volume of a 3d mesh
Date: 9 Dec 1999 21:40:44
Message: <38506803.207AEF7@pcabell.net>
Lance Birch wrote:
> 
> Just buy MAX, it'll do that for you and then be able to apply dynamics to
> all the objects in your scene :)  Oh, plus it'll find the pivot point
> center-of-gravity for any object too, ain't that handy :)

If MAX is so great why doesn't it offer direct file support for POV-Ray
like Rhino does at a fraction of the cost ?

-- 
Ken Tyler -  1200+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Lance Birch
Subject: Re: Volume of a 3d mesh
Date: 9 Dec 1999 22:30:14
Message: <385073c6@news.povray.org>
Because it's built to export to RenderMan :)  hehehe

--
Lance.
The Zone - http://come.to/the.zone
Ken <tyl### [at] pcabellnet> wrote in message
news:385### [at] pcabellnet...
>
>
> Lance Birch wrote:
> >
> > Just buy MAX, it'll do that for you and then be able to apply dynamics
to
> > all the objects in your scene :)  Oh, plus it'll find the pivot point
> > center-of-gravity for any object too, ain't that handy :)
>
> If MAX is so great why doesn't it offer direct file support for POV-Ray
> like Rhino does at a fraction of the cost ?
>
> --
> Ken Tyler -  1200+ Povray, Graphics, 3D Rendering, and Raytracing Links:
> http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Volume of a 3d mesh
Date: 10 Dec 1999 09:13:00
Message: <385109B2.C7393E5D@my-dejanews.com>
Boy, you are a math whiz!  But I'm slightly confused in your notation, it's
almost as if you wrote three matrices instead of one. By "determinant of
this matrix", you mean:

                        A.x * B.y * C.z  + .....

Will pov or one of your macros do this calc for me?

John VanSickle wrote:

> Greg M. Johnson wrote:
> >
> > Is there an automatic way to calculate the volume of a 3d mesh?
>
> For each triangle, take the following matrix:
>
> [A.x  A.y  A.z]
> [B.x  B.y  B.z]
> [C.x  C.y  C.z]
>
> Where A, B, and C are the vertices of the triangle.  Make sure that
> the order from A to B to C goes in the same direction for each triangle
> (either clockwise or counter-clockwise) when viewed from the outside
> of the mesh.
>
> Take the determinant of this matrix.  Divide it by six.  If the
> determinant is negative, leave it that way.
>
> Add up all of the determinants for all of the triangles.  Divide by
> six.  If the sum is negative, make it positive.  The result is the
> volume of the mesh.
>
> Note that every edge *MUST* be shared by exactly TWO triangles, or the
> sum will be entirely meaningless.
>
> Hope this helps,
> John
> --
> ICQ: 46085459


Post a reply to this message

From: Ron Parker
Subject: Re: Volume of a 3d mesh
Date: 10 Dec 1999 09:18:58
Message: <38510bd2@news.povray.org>
#macro Determinant( A, B, C )
  (A.x * B.y * C.z + A.y * B.z * C.x + A.z * B.x * C.y -
   A.x * B.z * C.x - A.y * B.x * C.z - A.z * B.y * C.x)
#end

On Fri, 10 Dec 1999 09:09:55 -0500, Greg M. Johnson wrote:
>Boy, you are a math whiz!  But I'm slightly confused in your notation, it's
>almost as if you wrote three matrices instead of one. By "determinant of
>this matrix", you mean:
>
>                        A.x * B.y * C.z  + .....
>
>Will pov or one of your macros do this calc for me?
>
>John VanSickle wrote:
>
>> Greg M. Johnson wrote:
>> >
>> > Is there an automatic way to calculate the volume of a 3d mesh?
>>
>> For each triangle, take the following matrix:
>>
>> [A.x  A.y  A.z]
>> [B.x  B.y  B.z]
>> [C.x  C.y  C.z]
>>
>> Where A, B, and C are the vertices of the triangle.  Make sure that
>> the order from A to B to C goes in the same direction for each triangle
>> (either clockwise or counter-clockwise) when viewed from the outside
>> of the mesh.
>>
>> Take the determinant of this matrix.  Divide it by six.  If the
>> determinant is negative, leave it that way.
>>
>> Add up all of the determinants for all of the triangles.  Divide by
>> six.  If the sum is negative, make it positive.  The result is the
>> volume of the mesh.
>>
>> Note that every edge *MUST* be shared by exactly TWO triangles, or the
>> sum will be entirely meaningless.
>>
>> Hope this helps,
>> John
>> --
>> ICQ: 46085459
>
>
>


-- 
These are my opinions.  I do NOT speak for the POV-Team.
The superpatch: http://www2.fwi.com/~parkerr/superpatch/
My other stuff: http://www2.fwi.com/~parkerr/traces.html


Post a reply to this message

From: John VanSickle
Subject: Re: Volume of a 3d mesh
Date: 11 Dec 1999 23:21:06
Message: <38532418.2253F955@erols.com>
Greg M. Johnson wrote:
> 
> Boy, you are a math whiz!  But I'm slightly confused in your notation,
> it's almost as if you wrote three matrices instead of one. By
> "determinant of this matrix", you mean:
> 
>                         A.x * B.y * C.z  + .....
> 
> Will pov or one of your macros do this calc for me?

Thanks to the fact that it's a 3x3 matrix with it elements conveniently
stored in three vectors, and the fact that the determinant of a 3x3
matrix can be found by taking the cross product of the second and third rows, and
taking the dot
product of that result and the first row, the determinant can be easily found with POV
code.

#macro Determinant(A,B,C)
  vdot(A,vcross(B,C))
#end

Regards,
John
-- 
Hmm, 62 words in one sentence.  I guess I've been reading too much
Victor Hugo...


Post a reply to this message

From: Bill DeWitt
Subject: Re: Volume of a 3d mesh
Date: 14 Dec 1999 12:30:24
Message: <38567eb0@news.povray.org>
"John VanSickle" <van### [at] erolscom> wrote in message
news:38502D2D.3F208819@erols.com...
> Greg M. Johnson wrote:
> >
> > Is there an automatic way to calculate the volume of a 3d mesh?
>
<snip>

    I've been trying to figure this out, considering that I don't really
understand matrixes or meshes and I am working with a D in highschool
algebra.

    The only way I can see to do it is to somehow read the mesh into an
separate program of some sort. Was this what you meant, John? I think I can
write a C program that might do it, though I think it -might- be just barely
possible in PovRay itself.

    Also, I now have a trial version of Rhino (been running for 3 days so as
to not use up any iterations 8-) and it exports a nice mesh. Can I assume
that the order in which it is written  "goes in the same direction for each
triangle (either clockwise or counter-clockwise) "? Oh, I think I just
thought of a way to test this but just in case I still would like to hear
any input. Basically I am thinking of writing a parser inside of a povray
file.

    Thanks for any help.


Post a reply to this message

From: John VanSickle
Subject: Re: Volume of a 3d mesh
Date: 15 Dec 1999 17:17:53
Message: <385814FE.E9BA9AD5@erols.com>
Bill DeWitt wrote:
> 
>     I've been trying to figure this out, considering that I don't really
> understand matrixes or meshes and I am working with a D in highschool
> algebra.
> 
>     The only way I can see to do it is to somehow read the mesh into an
> separate program of some sort. Was this what you meant, John? I think I can
> write a C program that might do it, though I think it -might- be just
> barely possible in PovRay itself.

If the object file you're using writes the numbers in human-readable format,
and separates the figures with commas, then yes, a POV-Ray script can read
the file in.  Try editing the file with a text editor.  If you see a bunch of
numbers (possibly separated by commas), you're good to go; if you see a whole
bunch of garbage, then the data is either (a) written in the internal format
for representing floating point numbers, or (b) has been scrambled/encrypted
for some reason.  Note that to be readable by POV, the numbers must all be
separated by commas; if they aren't there, you'll have to add them.

You will of course need to know which number represents what.  If the file
contains nothing but triangle data, you can be fairly sure that any
fractional numbers represent a component of a vector; but whether this is
vector is a vertex, normal, or UV mapping, is still not discernable.  It's
one of those guessing games that makes computer fun to use.

If you can arrange to create a mesh with a known number of vertices and
triangles, you can look for those same numbers in the data file; this will be
very helpful in figuring out the file format.

>     Also, I now have a trial version of Rhino (been running for 3 days so
> as to not use up any iterations 8-) and it exports a nice mesh. Can I
> assume that the order in which it is written  "goes in the same direction
> for each triangle (either clockwise or counter-clockwise) "?

No.  It might just throw them out there.

The way to definitively tell is to look at every edge, and look to see the
order in which the end points are referenced the triangles that border on
that edge.  If they are referred to in reverse order from each other, the
triangles face in the same direction; otherwise they face in opposite
directions.  When making this test, the third vertex in each triangle is
treated as if it *precedes* the first.

This is probably confusing, so I'll try to simplify it a bit.  You have two
triangles, ABC and DEF.

If (A=D and B=F) or
   (A=D and C=E) or
   (A=E and B=D) or
   (A=E and C=F) or
   (A=F and B=E) or
   (A=F and C=D) or
   (B=D and C=F) or
   (B=E and C=D) or
   (B=F and C=E)

then the triangles face in the same direction.

If (A=D and B=E) or
   (A=D and C=F) or
   (A=E and B=F) or
   (A=E and C=D) or
   (A=F and B=D) or
   (A=F and C=E) or
   (B=D and C=E) or
   (B=E and C=F) or
   (B=F and C=D)

then the triangles face in opposite directions.

> Oh, I think I just thought of a way to test this but just in case I still
> would like to hear any input. Basically I am thinking of writing a parser
> inside of a povray file.

The trick is handling the mismatched triangles; you eventually have to turn
one around, but you have to make sure you're turning the correct one around,
and for speed reasons you should have a mechanism to prevent checking a
given edge more than once.  These problems are left as an exercise to the
interested student :-).

Regards,
John


Post a reply to this message

From: Bill DeWitt
Subject: Re: Volume of a 3d mesh
Date: 15 Dec 1999 17:33:11
Message: <38581727@news.povray.org>
John, Thank for taking the time to type this all out. I even think I begin
to understand it. 8-)

    Now lets see if when added to the mix of a thousand other unfinished
projects, I can get anything done with the information...

"John VanSickle" <van### [at] erolscom> wrote in message
news:385814FE.E9BA9AD5@erols.com...
> Bill DeWitt wrote:
> >
> >     I've been trying to figure this out, considering that I don't really
> > understand matrixes or meshes and I am working with a D in highschool
> > algebra.
> >
> >     The only way I can see to do it is to somehow read the mesh into an
> > separate program of some sort. Was this what you meant, John? I think I
can
> > write a C program that might do it, though I think it -might- be just
> > barely possible in PovRay itself.
>
> If the object file you're using writes the numbers in human-readable
format,
> and separates the figures with commas, then yes, a POV-Ray script can read
> the file in.  Try editing the file with a text editor.  If you see a bunch
of
> numbers (possibly separated by commas), you're good to go; if you see a
whole
> bunch of garbage, then the data is either (a) written in the internal
format
> for representing floating point numbers, or (b) has been
scrambled/encrypted
> for some reason.  Note that to be readable by POV, the numbers must all be
> separated by commas; if they aren't there, you'll have to add them.
>
> You will of course need to know which number represents what.  If the file
> contains nothing but triangle data, you can be fairly sure that any
> fractional numbers represent a component of a vector; but whether this is
> vector is a vertex, normal, or UV mapping, is still not discernable.  It's
> one of those guessing games that makes computer fun to use.
>
> If you can arrange to create a mesh with a known number of vertices and
> triangles, you can look for those same numbers in the data file; this will
be
> very helpful in figuring out the file format.
>
> >     Also, I now have a trial version of Rhino (been running for 3 days
so
> > as to not use up any iterations 8-) and it exports a nice mesh. Can I
> > assume that the order in which it is written  "goes in the same
direction
> > for each triangle (either clockwise or counter-clockwise) "?
>
> No.  It might just throw them out there.
>
> The way to definitively tell is to look at every edge, and look to see the
> order in which the end points are referenced the triangles that border on
> that edge.  If they are referred to in reverse order from each other, the
> triangles face in the same direction; otherwise they face in opposite
> directions.  When making this test, the third vertex in each triangle is
> treated as if it *precedes* the first.
>
> This is probably confusing, so I'll try to simplify it a bit.  You have
two
> triangles, ABC and DEF.
>
> If (A=D and B=F) or
>    (A=D and C=E) or
>    (A=E and B=D) or
>    (A=E and C=F) or
>    (A=F and B=E) or
>    (A=F and C=D) or
>    (B=D and C=F) or
>    (B=E and C=D) or
>    (B=F and C=E)
>
> then the triangles face in the same direction.
>
> If (A=D and B=E) or
>    (A=D and C=F) or
>    (A=E and B=F) or
>    (A=E and C=D) or
>    (A=F and B=D) or
>    (A=F and C=E) or
>    (B=D and C=E) or
>    (B=E and C=F) or
>    (B=F and C=D)
>
> then the triangles face in opposite directions.
>
> > Oh, I think I just thought of a way to test this but just in case I
still
> > would like to hear any input. Basically I am thinking of writing a
parser
> > inside of a povray file.
>
> The trick is handling the mismatched triangles; you eventually have to
turn
> one around, but you have to make sure you're turning the correct one
around,
> and for speed reasons you should have a mechanism to prevent checking a
> given edge more than once.  These problems are left as an exercise to the
> interested student :-).
>
> Regards,
> John


Post a reply to this message

From: Bill DeWitt
Subject: Re: Volume of a 3d mesh
Date: 15 Dec 1999 22:36:23
Message: <38585e37@news.povray.org>
Silly me...

    Reading the documentation, I find that Rhino will calculate the volume
of the mesh I need. Says "+/- 0.0043"... close enough for government work...


Post a reply to this message

<<< Previous 5 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.