Volume of a mesh

  • Follow


Hello,

    I have been looking for an easy way to use opengl to calculate the
volume of a mesh. From what I understand is that if I have a mesh and know
all of the dimensions I should be able to calculate the volume. This is a o
brainer for a cube or other simple primitive, but how can I calculate the
volume of a more complex mesh, without explicitly storing all of the
information alongside it.

    Say I want to calculte the volume of a cube, That's simply length *
width * height. But if I wanted to know the volume of an axe head that I
modeld I have to take the wedge of half of the head in to account as well as
the curve at the same time. Does OpenGL have any functions to help with this
or is there an easy way to implement a calculation that would work on any
mesh?

    I'm doing this as a learning exercise and it seems like it would be very
doable for a novice like myself.

    I tried searching google but all I get is stuff about volume rendering.
Although very interesting, it dosen't seem to be what I am looking for.

    Thanks for reading.


0
Reply brentritchie (17) 8/28/2005 4:48:37 PM

Brent Ritchie wrote:

> Hello,
> 
>     I have been looking for an easy way to use opengl to
>     calculate the

That's not the purpose of OpenGL. Ask in
comp.graphics.algorithms.

Wolfgang Draxinger
-- 

0
Reply Wolfgang 8/28/2005 5:55:58 PM


--
"Brent Ritchie" <brentritchie@personainternet.com> wrote in message 
news:11h3qn6jsrapdbd@corp.supernews.com...
>    I have been looking for an easy way to use opengl to calculate the
> volume of a mesh. From what I understand is that if I have a mesh and know
> all of the dimensions I should be able to calculate the volume. This is a 
> o
> brainer for a cube or other simple primitive, but how can I calculate the
> volume of a more complex mesh, without explicitly storing all of the
> information alongside it.

If your mesh forms a closed, simple polyhedron, then you can
compute the volume as a sum of signed volumes of tetrahedra,
all tetrahedra sharing a common origin (any point you wish)
with the opposite triangle a facet of the polyhedron.  The
pseudocode here assumes the mesh triangles are counterclockwise
ordered when viewed from outside the mesh.

    volume = 0;
    for (i = 0; i < numTriangles; i++)
    {
        V0 = vertex 0 of triangle i;
        V1 = vertex 1 of triangle i;
        V2 = vertex 2 of triangle i;
        volume += Dot(V0, V1.Cross(V2));
    }
    volume /= 6;

The mesh triangle <V0,V1,V2> is counterclockwise ordered when
viewed from outside the mesh.


0
Reply wasting 8/29/2005 12:11:16 AM

"Wolfgang Draxinger" <wdraxinger@darkstargames.de> wrote in message
news:eea9u2-21p.ln1@darkstargames.dnsalias.net...
> Brent Ritchie wrote:
>
> > Hello,
> >
> >     I have been looking for an easy way to use opengl to
> >     calculate the
>
> That's not the purpose of OpenGL. Ask in
> comp.graphics.algorithms.
>

    I kind of figured OpenGL didn't have anything to do this. But I decided
to ask anyway just incase.

Thanks for the appropriate group.

> Wolfgang Draxinger
> -- 
>


0
Reply Brent 8/29/2005 4:54:53 PM

"wasting time" <wastingtime@whileatwork.com> wrote in message
news:EosQe.3506$_84.913@newsread1.news.atl.earthlink.net...
> --
> "Brent Ritchie" <brentritchie@personainternet.com> wrote in message
> news:11h3qn6jsrapdbd@corp.supernews.com...
> >    I have been looking for an easy way to use opengl to calculate the
> > volume of a mesh. From what I understand is that if I have a mesh and
know
> > all of the dimensions I should be able to calculate the volume. This is
a
> > o
> > brainer for a cube or other simple primitive, but how can I calculate
the
> > volume of a more complex mesh, without explicitly storing all of the
> > information alongside it.
>
> If your mesh forms a closed, simple polyhedron, then you can
> compute the volume as a sum of signed volumes of tetrahedra,
> all tetrahedra sharing a common origin (any point you wish)
> with the opposite triangle a facet of the polyhedron.  The
> pseudocode here assumes the mesh triangles are counterclockwise
> ordered when viewed from outside the mesh.
>
>     volume = 0;
>     for (i = 0; i < numTriangles; i++)
>     {
>         V0 = vertex 0 of triangle i;
>         V1 = vertex 1 of triangle i;
>         V2 = vertex 2 of triangle i;
>         volume += Dot(V0, V1.Cross(V2));
>     }
>     volume /= 6;
>
> The mesh triangle <V0,V1,V2> is counterclockwise ordered when
> viewed from outside the mesh.
>
>

    I have seen this before. But I like your pseudo code example it's
beginning to make more sense. I looked through mathworld and I've got to do
more research on the dot and cross functions for it to make sense.

    Thank you.


0
Reply Brent 8/29/2005 4:57:39 PM

4 Replies
295 Views

(page loaded in 0.109 seconds)

Similiar Articles:













7/20/2012 9:26:15 PM


Reply: