//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); } }
Volume of Mesh Calculation With WebGL
最新推荐文章于 2021-05-25 14:43:27 发布