Volume of Mesh Calculation With WebGL
2016-10-20 17:52
267 查看
//Created by Ken on Oct 20,2016 for volume compute when upload function SignedVolumeOfTriangle(p1, p2, p3) { var v321 = p3.X*p2.Y*p1.Z; var v231 = p2.X*p3.Y*p1.Z; var v312 = p3.X*p1.Y*p2.Z; var v132 = p1.X*p3.Y*p2.Z; var v213 = p2.X*p1.Y*p3.Z; var v123 = p1.X*p2.Y*p3.Z; var singnedVolume=(1/6)*(-v321 + v231 + v312 - v132 - v213 + v123); return singnedVolume; } function VolumeOfMesh(points) { var i= 0,vols=0; var P1,P2,P3; do { P1={X:points[i],Y:points[i+1],Z:points[i+2]}; P2={X:points[i+3],Y:points[i+4],Z:points[i+5]}; P3={X:points[i+6],Y:points[i+7],Z:points[i+8]}; vols+=SignedVolumeOfTriangle(P1, P2, P3); i+=9; } while (i<points.length); return customRound(Math.abs(vols)/1000,2); } function customRound(number,fractiondigits){ with(Math){ return round(number*pow(10,fractiondigits))/pow(10,fractiondigits); } }
相关文章推荐
- Calculate superficial area and volume of mesh with Three.js(WebGL)
- A Minimum Volume Covering Approach with a Set of Ellipsoids
- Patterns in Java: A Catalog of Reusable Design Patterns Illustrated with UML, 2nd Edition, Volume 1
- How to train models of Object Detection with Discriminatively Trained Part Based Models
- 论文阅读 Visual Categorization with Bags of Keypoints
- 下篇:Fusion of LiDAR 3D Points Cloud with 2D Digital Camera Image/3D点云与2D数字图像的融合
- Pymode requires vim compiled with +python. Most of features will be disabled.
- Warning LNK4098 : defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library
- returns a number of second with no user activity (called in an OnTimer event of a TTimer component).
- Reducing the Dimensionality of Data with Neural Networks
- Java 程序报错“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclo”
- Resource is out of sync with the file system:
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- LeetCode(30)--Substring with Concatenation of All Words
- 30. Substring with Concatenation of All Words
- java can not access a member of with modifiers
- LeetCode 30. Substring with Concatenation of All Words(单词连接)
- leetcode 30. Substring with Concatenation of All Words
- rror creating bean with name 'adminController': Injection of autowired dependencies failed;
- Keep the resource of the grid cluster consistency with OS status.