Volume of Complex objects
How can I calculate the volume of complex objects based on vector product. I have list of triangle开发者_JAVA技巧s that construct the object mesh.
I have a :
- list of triangles.
- a triangle is composed by 3 Nodes.
- a Node have x,y and z coordinate.
You can select one point P (for example, origin) and then calculate volumes of all tetrahedrons PABC, where A, B and C are vertices of a triangle from a list. The volume of each such tetrahedron equals abs(((PA x PB) . PC) / 2), where "x" and "." are cross product and dot product respectively and abs is an absolute value. To calculate the volume of the entire object you can sum up all volumes but without taking the absolute value of each. Thus, volumes of some tetrahedrons will be taken with the plus in the sum, and some with the minus. So, the volume of the entire object will be abs(sum(((PAi x PBi) . PCi) / 2)), where Ai, Bi, Ci are vertices of the ith triangle and sum is taken for all i.
精彩评论