Advertisement

Triangle orientation for a closed solid

Started by May 01, 2002 07:11 PM
5 comments, last by qzou 22 years, 9 months ago
Hi, there, I have a closed solid which is modelled as a collection of triangles. In order to calculate the solid volume, I need to set the vertex orientation of every triangle to be counterclockwise so that the triangle normals point outside. Could someone tell me how to do it. Thanks a lot
quote:
In order to calculate the solid volume, I need to set the vertex orientation of every triangle to be counterclockwise so that the triangle normals point outside.


Triangle orientation is irrelevant when calculating the solid's volume. Where did you get this rubbish from?

To calculate the volume pick some point interior to the solid. For every triangle form a tetrahedron specified by the triangle vertices and the interior vertex. The volume is then the some of the volumes of those tetrahedrons.

In turn, the volume of a tetrahedron with vertices x1 ,x2 ,x3 , x4 is calculated as 1/3! * determinant( [ x1 y1 z1 1; x2 y2 z2 1; x3 y3 z3 1; x4 y4 z4 1 ] )

edit: that is for a convex solid, if it isn't you need to split it up into conxex pieces.

[edited by - sQuid on May 1, 2002 9:03:00 PM]
Advertisement
Thank very much for your reply. However, I do not want to use the interier point to calculate the tetrahedron voulmes. I have to use an arbitrary point, say (0,0,0), to calculate the signed tetrahedron volumes, then add the volumes for the solid volume. In this case, the triangle orientation does matter.

Cheers
Ah OK. That makes more sense. When you describe the solid the triangles that make up its surface should all be specified as three vertices in some order, eg v1,v2,v3. This ordering determines the orientation. If it''s anti-clockwise then the outward facing normal is just given by (v2-v1) x (v3-v1).

I imagine you''re then taking the dot-product of this normal with the vector from the "arbitrary point" to the midpoint of the triangle to determine the sign of the tetrahedron volume.

To set the orientation you just, well, set it in the triangle descriptions.
Even if your triangles aren''t orientated somehow, as long your corpse is convex your problem can be solved easy:
In a convex corpse all vertices are on the same side off a surounding plane (or on it).
For each triangle with points P1, P2, P3 pick just a P4 not element (P1, P2, P3) and calculate the distance of P4 from the plane (P1, P2, P3).
If distance is negative, you are done with this triangle.
If distance is positive, replace triangle (P1, P2, P3) by (P1, P3, P2), and you are done with this triangle.
If distance was 0: P4 is on plane (P1, P2, P3). Pick a new point as P4 and redo.

Repeat with all triangles.
Maybe your definition of distance is other than mine, and now all your normals point inside... not a big deal.
-----The scheduled downtime is omitted cause of technical problems.
Pick one triangle which is correctly oriented. Then orient an adjacent triangle by making sure the edge they share goes in the opposite direction in the second triangle to the first.

e.g. if the first triangle is ABC and the second ABD their common edge is AB so the second should be oriented with AB reversed, e.g. BAD, to match it''s orientation. Continue like this through all triangles, orienting one adjacent to already oriented triangles each time.

If you don''t know the orientation of the first triangle it''s still OK. Just assume it is correct and orient the remaining triangles based on it. If you were right the answer should be correct. If not you get minus the volume, so just negate this for the correct answer (fixing the orientations at the same time if you still care about them).

Note the polyhedra does not have to be convex or simply connected for this to work, e.g. it will work on a donut or teapot. It also will work for polygons other than triangles.
John BlackburneProgrammer, The Pitbull Syndicate
Advertisement
Thanks a lot, guys.

This topic is closed to new replies.

Advertisement