Calculate superficial area and volume of mesh with Three.js(WebGL)
来源:互联网 发布:淘宝收评价的是真的吗 编辑:程序博客网 时间:2024/06/09 20:42
//Created by Ken on Oct 20,2016 for volume compute when uploadfunction 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); }}function SuperficialAreaOfMesh(points) { var _len =points.length, _area = 0.0; if (!_len) return 0.0; var i= 0,vols=0; var va,vb,vc; do { va={X:points[i],Y:points[i+1],Z:points[i+2]}; vb={X:points[i+3],Y:points[i+4],Z:points[i+5]}; vc={X:points[i+6],Y:points[i+7],Z:points[i+8]}; var ab = {X:vb.X-va.X,Y:vb.Y-va.Y,Z:vb.Z-va.Z}; //vb.clone().sub(va); var ac = {X:vc.X-va.X,Y:vc.Y-va.Y,Z:va.Z-vc.Z}; //vc.clone().sub(va); var cross = new THREE.Vector3(); cross=crossVectors( ab, ac ); _area += Math.sqrt(Math.pow(cross.X,2)+Math.pow(cross.Y,2)+Math.pow(cross.Z,2))/2; i+=9; } while (i<points.length); return customRound(Math.abs(_area)/100,2);} function crossVectors( a, b ) { var ax = a.X, ay = a.Y, az = a.Z; var bx = b.X, by = b.Y, bz = b.Z; var P={X:ay * bz - az * by, Y:az * bx - ax * bz, Z:ax * by - ay * bx} return P;}
0 0
- Calculate superficial area and volume of mesh with Three.js(WebGL)
- Volume of Mesh Calculation With WebGL
- 检测使用 three.js 时的 WebGL 和浏览器兼容性(Detecting WebGL and browser compatibility with three.js)(转)
- Threejs 官网 - 检测使用 three.js 时的 WebGL 和浏览器兼容性(Detecting WebGL and browser compatibility with three.js)
- WebGL With Three.js – Lesson 6(转)
- WebGL three.js
- Webgl之three.js
- three.js(webGL库)
- three.js 与 webGL
- 《webgl入门指南》学习笔记二之three.js创建mesh
- (WebGL) Max to Three.js workflow tips and tricks
- WebGL库Three.js入门
- Calculate the area of dashed part
- Convert a model from Maya to WebGL for use with THREE.js
- 结合Blender和Three.js使用WEBGL
- Three.js WebGL 绘制流程(一)
- Three.js讲解以及WEBGL实例
- HTML5画布WebGL Three.js球体
- 微信文章图片反防盗链解决方案
- java处理保留小数点后几位
- Android学习笔记(八)
- linux之文件系统制作及移植
- 双向链表
- Calculate superficial area and volume of mesh with Three.js(WebGL)
- ecshop二次开发--QQ客服
- Android开发点滴(七) 改进版天气预报
- C++静态函数中调用非静态成员函数或变量
- 关于iOS10访问通讯录崩溃问题
- 谈谈北斗导航及其意义
- CSS初始化代码_Div+CSS教程
- android 小知识
- 关于开启不保留活动后引发RestoreInstanceState容易崩溃的问题小记