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

Home » Public Forums » archive » Re: Efficient calculation of triangle surface areas
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Efficient calculation of triangle surface areas [message #35328] Wed, 11 June 2003 07:24
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
"Wolfgang Funk" <wolfgang.funk@igd.fhg.de> wrote in message
news:newscache$3e8bgh$iih$1@luna.igd.fhg.de...
> Hi all,
>
> I'd like to know the surface area of every single polygon within a mesh.
>
> MESH_SURFACEAREA gives me the cumulative surface area. Is there any
> other way but looping through the connectivity array of the mesh and
> calling MESH_SURFACEAREA for every single polygon?
>
> Thanx,
>
> Wolfgang
>
>
> -----

Here's a program that makes a sample mesh and then computes the area by
calling MESH_SURFACEAREA and then computes the area for each individual
triangle. I add them up to make sure that the results are the same.

This only works for triangular meshes. If you want something for more
general meshes, then the approach below can be extended with some of the
ideas in
http://geometryalgorithms.com/Archive/algorithm_0101/algorit hm_0101.htm.

Hope this helps.

Karl

pro tri

vol = congrid(bytscl(randomu((seed=0), 4, 4, 4)), 40, 40, 20)
ISOSURFACE, vol, 120, verts, conn
print, MESH_SURFACEAREA(verts, conn)

i = 0L
tot = 0.0
nConn = N_ELEMENTS(conn)

while i lt nConn do begin
tri = verts[*,conn[i+1:i+3]]
area = CROSSP(tri[*,0]-tri[*,1], tri[*,2]-tri[*,1])
area = SQRT(area ## TRANSPOSE(area))/2.0
tot = tot + area
i = i + 4
endwhile
print, tot
end
[Message index]
 
Read Message
Previous Topic: Zooming Object Graphics
Next Topic: Re: Transparent PNG file in PowerPoint

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

Current Time: Fri Oct 10 17:53:01 PDT 2025

Total time taken to generate the page: 2.16401 seconds