From 2ef78ecf46fda4b3ee7b69bc28622b823ef2f1b9 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Fri, 8 May 2015 18:52:25 +0200 Subject: [PATCH 01/27] Update version in development branch. --- src/core/jsm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/jsm.js b/src/core/jsm.js index 5938ddf0..f1b7c176 100644 --- a/src/core/jsm.js +++ b/src/core/jsm.js @@ -1,6 +1,6 @@ var JSM = function () { this.mainVersion = 0; - this.subVersion = 36; + this.subVersion = 37; }; JSM.Eps = 0.00000001; From afabc76c3451fde21cab0b548841186749385a91 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sun, 10 May 2015 08:56:32 +0200 Subject: [PATCH 02/27] Add bounding sphere request to TriangleBody. --- build/jsmodeler.js | 5 ++-- build/jsmodeler.viewer.js | 2 +- documentation/jsmdoc/include/jsmdoc.json | 12 ++++++++ src/modeler/trianglebody.js | 35 ++++++++++++++++++++++++ test/unittest/tests/modeler.js | 15 ++++++++++ 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 2f1f17ed..61c178c3 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,4 +1,4 @@ -/* JSModeler 0.36 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=36};JSM.Eps=1E-8;JSM.Inf=9999999999;JSM.RadDeg=57.29577951308232;JSM.DegRad=0.017453292519943;JSM.IsZero=function(a){return Math.abs(a)JSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)JSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)p.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e], c=b.AddNormal(c.x,c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;e Date: Sun, 10 May 2015 14:25:14 +0200 Subject: [PATCH 03/27] Correct obj file reading in case of invalid indices. --- src/import/importerobj.js | 3 ++ test/unittest/testfiles/invalidindices.obj | 32 ++++++++++++++++++++++ test/unittest/tests/import.js | 20 ++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/unittest/testfiles/invalidindices.obj diff --git a/src/import/importerobj.js b/src/import/importerobj.js index ceece63a..c777fe68 100644 --- a/src/import/importerobj.js +++ b/src/import/importerobj.js @@ -233,6 +233,9 @@ JSM.ConvertObjToJsonData = function (stringBuffer, callbacks) if (result !== undefined) { return result; } + if (globalIndex < 0 || globalIndex >= globalArray.length) { + return undefined; + } var coordinate = globalArray[globalIndex]; if (mode === 0) { diff --git a/test/unittest/testfiles/invalidindices.obj b/test/unittest/testfiles/invalidindices.obj new file mode 100644 index 00000000..1f7e1219 --- /dev/null +++ b/test/unittest/testfiles/invalidindices.obj @@ -0,0 +1,32 @@ +# Alias OBJ Model File +# Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited +# File units = meters + +mtllib cubeobj.mtl + +g Mesh1 Model + +usemtl FrontColor +v -1.94623 0 0.600186 +v -1.94623 0 -0.979814 +v 1.51377 0 -0.979814 +v 1.51377 0 0.600186 +f 1/1/1 2/2/1 3/3/1 4/4/1 + +v -1.94623 0.69 0.600186 +v -1.94623 0.69 -0.979814 +f 2/5/2 1/6/2 5/7/2 6/8/2 + +usemtl M_0076_Green +v 1.51377 0.69 0.600186 +f 1/9/3 4/10/3 7/11/3 5/12/3 + +usemtl M_0103_Blue +v 1.51377 0.69 -0.979814 +f 4/13/4 3/14/4 8/15/4 7/16/4 + +usemtl FrontColor +f 3/17/5 2/18/5 6/19/5 8/20/5 + +usemtl M_0020_Red +f 6/21/6 5/22/6 7/23/6 8/24/6 diff --git a/test/unittest/tests/import.js b/test/unittest/tests/import.js index edca4458..c9647b50 100644 --- a/test/unittest/tests/import.js +++ b/test/unittest/tests/import.js @@ -222,6 +222,26 @@ importSuite.AddTest ('ConvertObjToJsonDataTest', function (test) }; test.Assert (JSON.stringify (jsonData) == JSON.stringify (refJsonData)); + var jsonData = JSM.ConvertObjToJsonData (GetStringBufferFromFile ('../testfiles/invalidindices.obj')); + var refJsonData = { + "version":1, + "materials":[ + {"name":"Default","ambient":[0.5,0.5,0.5],"diffuse":[0.5,0.5,0.5],"specular":[0.1,0.1,0.1],"shininess":0,"opacity":1} + ], + "meshes":[ + { + "name":"Mesh1 Model", + "vertices":[-1.94623,0,0.600186,-1.94623,0,-0.979814,1.51377,0,-0.979814,1.51377,0,0.600186,-1.94623,0.69,0.600186,-1.94623,0.69,-0.979814,1.51377,0.69,0.600186,1.51377,0.69,-0.979814], + "normals":[0,-1,0,0,-1,0,-1,0,0,-1,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,-1,0,0,-1,0,1,0,0,1,0], + "uvs":[0,0], + "triangles":[ + {"material":0,"parameters":[0,1,2,0,0,0,0,0,0,0,2,3,1,1,1,0,0,0,1,0,4,2,2,2,0,0,0,1,4,5,3,3,3,0,0,0,0,3,6,4,4,4,0,0,0,0,6,4,5,5,5,0,0,0,3,2,7,6,6,6,0,0,0,3,7,6,7,7,7,0,0,0,2,1,5,8,8,8,0,0,0,2,5,7,9,9,9,0,0,0,5,4,6,10,10,10,0,0,0,5,6,7,11,11,11,0,0,0]} + ] + } + ] + }; + test.Assert (JSON.stringify (jsonData) == JSON.stringify (refJsonData)); + var jsonData = JSM.ConvertObjToJsonData (GetStringBufferFromFile ('../testfiles/cubeobj.obj'), { onFileRequested : function (fileName) { test.Assert (fileName == 'cubeobj.mtl'); From ba61e6643d6feb29a7e4f0061a65ee8a160b7726 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 12 May 2015 17:04:54 +0200 Subject: [PATCH 04/27] Dispose geometry on mesh remove. --- src/three/threeviewer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/three/threeviewer.js b/src/three/threeviewer.js index b9ac717c..17b9ae0f 100644 --- a/src/three/threeviewer.js +++ b/src/three/threeviewer.js @@ -237,6 +237,7 @@ JSM.ThreeViewer.prototype.GetMesh = function (index) JSM.ThreeViewer.prototype.RemoveMesh = function (mesh) { + mesh.geometry.dispose (); this.scene.remove (mesh); this.DrawIfNeeded (); }; @@ -248,6 +249,7 @@ JSM.ThreeViewer.prototype.RemoveMeshes = function () for (i = 0; i < this.scene.children.length; i++) { current = this.scene.children[i]; if (current instanceof THREE.Mesh) { + current.geometry.dispose (); this.scene.remove (current); i--; } From 6b675fd48f2fd609535b490044a3e777cb822024 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Wed, 8 Jul 2015 19:38:19 +0200 Subject: [PATCH 05/27] Do not set zero shininess value to three.js material. --- build/jsmodeler.js | 2 +- build/jsmodeler.viewer.js | 20 +++--- sandbox/minimal2.html | 130 ++++++++++++++++++++++++++++++++++++ src/three/threeconverter.js | 22 ++++-- 4 files changed, 159 insertions(+), 15 deletions(-) create mode 100644 sandbox/minimal2.html diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 61c178c3..ddc55081 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -302,7 +302,7 @@ var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; diff --git a/build/jsmodeler.viewer.js b/build/jsmodeler.viewer.js index 63f898a0..09706ef9 100644 --- a/build/jsmodeler.viewer.js +++ b/build/jsmodeler.viewer.js @@ -1,13 +1,13 @@ /* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';JSM.ResizeImageToPowerOfTwoSides=function(a){if(JSM.IsPowerOfTwo(a.width)&&!JSM.IsPowerOfTwo(a.height))return a;var b=JSM.NextPowerOfTwo(a.width),d=JSM.NextPowerOfTwo(a.height),c=document.createElement("canvas");c.width=b;c.height=d;c=c.getContext("2d");c.drawImage(a,0,0,b,d);return c.getImageData(0,0,b,d)}; JSM.ConvertBodyToThreeMeshes=function(a,b,d){var c={textureLoadedCallback:null,hasConvexPolygons:!1,doubleSided:!0};void 0!==d&&null!==d&&(c.textureLoadedCallback=JSM.ValueOrDefault(d.textureLoadedCallback,c.textureLoadedCallback),c.hasConvexPolygons=JSM.ValueOrDefault(d.hasConvexPolygons,c.hasConvexPolygons),c.doubleSided=JSM.ValueOrDefault(d.doubleSided,c.doubleSided));var f=[],e=null;JSM.ExplodeBodyToTriangles(a,b,{hasConvexPolygons:c.hasConvexPolygons,onGeometryStart:function(){e=new THREE.Geometry}, -onGeometryEnd:function(a){var b=null!==a.texture,d=1!==a.opacity,A=new THREE.MeshPhongMaterial({ambient:a.ambient,color:a.diffuse,specular:a.specular,shininess:a.shininess});c.doubleSided&&(A.side=THREE.DoubleSide);d&&(A.opacity=a.opacity,A.transparent=!0);if(b){var r=THREE.ImageUtils.loadTexture(a.texture,new THREE.UVMapping,function(){r.image=JSM.ResizeImageToPowerOfTwoSides(r.image);null!==c.textureLoadedCallback&&c.textureLoadedCallback()});r.wrapS=THREE.RepeatWrapping;r.wrapT=THREE.RepeatWrapping; -A.map=r}e.computeFaceNormals();a=new THREE.Mesh(e,A);f.push(a)},onTriangle:function(a,b,c,d,f,k,l,F,m){var q=e.vertices.length;e.vertices.push(new THREE.Vector3(a.x,a.y,a.z));e.vertices.push(new THREE.Vector3(b.x,b.y,b.z));e.vertices.push(new THREE.Vector3(c.x,c.y,c.z));a=new THREE.Face3(q+0,q+1,q+2);e.faces.push(a);null!==d&&(null!==f&&null!==k)&&(a=[],a.push(new THREE.Vector3(d.x,d.y,d.z)),a.push(new THREE.Vector3(f.x,f.y,f.z)),a.push(new THREE.Vector3(k.x,k.y,k.z)),e.faces[e.faces.length-1].vertexNormals= -a);null!==l&&(null!==F&&null!==m)&&(d=[],d.push(new THREE.Vector2(l.x,-l.y)),d.push(new THREE.Vector2(F.x,-F.y)),d.push(new THREE.Vector2(m.x,-m.y)),e.faceVertexUvs[0].push(d))}});return f};JSM.ConvertModelToThreeMeshes=function(a,b,d){var c=[],f=[],e,h;for(e=0;e + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Example + + + + + + + + + + diff --git a/src/three/threeconverter.js b/src/three/threeconverter.js index 3d3303e8..0105dea6 100644 --- a/src/three/threeconverter.js +++ b/src/three/threeconverter.js @@ -28,11 +28,20 @@ JSM.ConvertBodyToThreeMeshes = function (body, materials, conversionData) var hasTexture = (material.texture !== null); var hasOpacity = (material.opacity !== 1.0); + var ambient = material.ambient; + var diffuse = material.diffuse; + var specular = material.specular; + var shininess = material.shininess; + if (shininess === 0.0) { + specular = 0; + shininess = 1; + } + var threeMaterial = new THREE.MeshPhongMaterial ({ - ambient : material.ambient, - color : material.diffuse, - specular : material.specular, - shininess : material.shininess + ambient : ambient, + color : diffuse, + specular : specular, + shininess : shininess }); if (theConversionData.doubleSided) { @@ -182,6 +191,11 @@ JSM.ConvertJSONDataToThreeMeshes = function (jsonData, textureLoadedCallback, en textureRotation = 0.0; } } + + if (shininess === 0.0) { + specularColor.setRGB (0.0, 0.0, 0.0); + shininess = 1; + } var material = new THREE.MeshPhongMaterial ({ ambient : diffuseColor.getHex (), From 07cb2e63936c3f473e94e0ddfa32bdc54829e668 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Wed, 8 Jul 2015 21:27:13 +0200 Subject: [PATCH 06/27] Hex color value instead of decimal. --- src/three/threeconverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/three/threeconverter.js b/src/three/threeconverter.js index 0105dea6..dfcdb8de 100644 --- a/src/three/threeconverter.js +++ b/src/three/threeconverter.js @@ -33,7 +33,7 @@ JSM.ConvertBodyToThreeMeshes = function (body, materials, conversionData) var specular = material.specular; var shininess = material.shininess; if (shininess === 0.0) { - specular = 0; + specular = 0x000000; shininess = 1; } From 7c6dd821bf0e695694d273eece56bef5eaab073a Mon Sep 17 00:00:00 2001 From: kovacsv Date: Wed, 15 Jul 2015 19:42:53 +0200 Subject: [PATCH 07/27] Move some Coord2D functions to Coord2D class. --- build/jsmodeler.js | 54 ++--- .../demo/include/settingscontrols.js | 6 +- documentation/jsmdoc/include/jsmdoc.json | 139 ++++++------ sandbox/3dsdump.html | 1 + sandbox/bezier.html | 1 + sandbox/beziercurve.html | 1 + sandbox/bspline.html | 3 +- sandbox/charts.html | 1 + sandbox/contourbody.html | 1 + sandbox/convexhull.html | 1 + sandbox/coplanar.html | 1 + sandbox/csg.html | 1 + sandbox/csg2.html | 1 + sandbox/curvedprism.html | 1 + sandbox/docimages.html | 1 + sandbox/doublesided.html | 1 + sandbox/githublogo.html | 1 + sandbox/heightmap.html | 1 + sandbox/hiddenline.html | 1 + sandbox/importer.html | 1 + sandbox/jsonimport.html | 1 + sandbox/jsonimporttexture.html | 1 + sandbox/minimal.html | 1 + sandbox/minimal2.html | 1 + sandbox/octree.html | 1 + sandbox/pointcloud.html | 1 + sandbox/pointcloudjson.html | 1 + sandbox/print.html | 1 + sandbox/prismwithhole.html | 1 + sandbox/randommat.html | 1 + sandbox/renderer.html | 1 + sandbox/revolved.html | 1 + sandbox/smartbuilder.html | 1 + sandbox/smartbuilder2.html | 1 + sandbox/solids.html | 1 + sandbox/specular.html | 1 + sandbox/svgonthefly.html | 3 +- sandbox/svgtomodel.html | 1 + sandbox/svgtomodeltexture.html | 1 + sandbox/tasks.html | 1 + sandbox/texture.html | 1 + sandbox/tictactoecanvas.html | 1 + sandbox/triangulate.html | 1 + sandbox/triangulatewithhole.html | 1 + sandbox/tube.html | 1 + sandbox/undermouse.html | 1 + sandbox/viewer.html | 1 + src/extras/svgtomodel.js | 4 +- src/geometry/coord.js | 114 +--------- src/geometry/coord2d.js | 200 ++++++++++++++++++ src/geometry/coordutils2d.js | 117 +--------- src/geometry/polygonutils.js | 4 +- src/geometry/sector.js | 2 +- src/geometry/sectorutils.js | 6 +- src/viewer/spriteviewer.js | 2 +- test/unittest/jsmodelertest.js | 1 + test/unittest/tests/extras.js | 2 +- test/unittest/tests/geometry.js | 157 +++++++------- test/unittest/tests/modeler.js | 134 ++++++------ test/viewertest/cameratest.html | 1 + test/viewertest/csgtest.html | 1 + test/viewertest/importtest.html | 1 + test/viewertest/svgtomodeltest.html | 1 + test/viewertest/texturetest.html | 1 + test/viewertest/viewertest.html | 1 + test/viewertest/viewertypes.html | 1 + tools/files.txt | 1 + 67 files changed, 513 insertions(+), 485 deletions(-) create mode 100644 src/geometry/coord2d.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index ddc55081..bcbb7e89 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -6,15 +6,15 @@ JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;cg&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);JSM.CoordIsEqual2DWithEps(d,c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0g&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0 + diff --git a/sandbox/bezier.html b/sandbox/bezier.html index cc67a56d..21a65825 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index 675c93a9..1a562b71 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/bspline.html b/sandbox/bspline.html index d9d623b9..062023c8 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -13,6 +13,7 @@ + @@ -103,7 +104,7 @@ var fullDistance = 0.0; var i, distance; for (i = 0; i < this.dataPoints.length - 1; i++) { - distance = JSM.CoordDistance2D (this.dataPoints[i], this.dataPoints[i + 1]); + distance = this.dataPoints[i].DistanceTo (this.dataPoints[i + 1]); distances.push (distance); fullDistance += distance; } diff --git a/sandbox/charts.html b/sandbox/charts.html index eb0a55d2..ca64685d 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/contourbody.html b/sandbox/contourbody.html index 22b55f14..92ed8a21 100644 --- a/sandbox/contourbody.html +++ b/sandbox/contourbody.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index 772ac474..eb98c30b 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 0080bae1..9bc60c07 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/csg.html b/sandbox/csg.html index 8b999081..35b84840 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/csg2.html b/sandbox/csg2.html index 3d701021..c7c24106 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index f45b6418..b1428748 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/docimages.html b/sandbox/docimages.html index 6fe835bf..2e0b9aea 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index c8df6a8c..045a2b7b 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index 585193c2..765aa9f8 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index 3d030dbf..f27e4664 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 4c71d421..17d73d37 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/importer.html b/sandbox/importer.html index 8978d768..1c4207fa 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index 96f9a053..e1129f24 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index 6dcaabd6..12c2f843 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/minimal.html b/sandbox/minimal.html index 6dd7f2a4..e0491193 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index a31e6d80..c08f0917 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/octree.html b/sandbox/octree.html index f6523c8a..2788caae 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 8e5dc781..83462cf6 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index cefa1177..8e53cd08 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/print.html b/sandbox/print.html index ebf7c819..2c659dea 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index 41d9dfaa..80227a0c 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/randommat.html b/sandbox/randommat.html index acba94cd..5b1d9871 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/renderer.html b/sandbox/renderer.html index e879e87b..43f11231 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/revolved.html b/sandbox/revolved.html index a2e98069..5056db80 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index 5322c269..5207e33c 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index db17a611..cb4ac29b 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/solids.html b/sandbox/solids.html index afd35647..10d96d1e 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/specular.html b/sandbox/specular.html index e3f6ebc9..50476385 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index 70a0b12e..b8ed3946 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -13,6 +13,7 @@ + @@ -85,8 +86,6 @@ - - Example diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index 3d5bdf2e..f57eacfb 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 294587a8..2cf59e29 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/tasks.html b/sandbox/tasks.html index ae658058..e4a7234a 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/texture.html b/sandbox/texture.html index 495a01d9..387ee9e1 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index eec75378..c4362eca 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -12,6 +12,7 @@ + diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index eb2deeff..ba9025af 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/triangulatewithhole.html b/sandbox/triangulatewithhole.html index 856fe825..07a5933a 100644 --- a/sandbox/triangulatewithhole.html +++ b/sandbox/triangulatewithhole.html @@ -14,6 +14,7 @@ + diff --git a/sandbox/tube.html b/sandbox/tube.html index 23cc1994..9434d7fe 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index da821a67..1f19757a 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -13,6 +13,7 @@ + diff --git a/sandbox/viewer.html b/sandbox/viewer.html index a8449198..48e3cc61 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -13,6 +13,7 @@ + diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index 29b67cc1..ce500ea7 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -28,7 +28,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var contourVertexCount = result.VertexCount (contour); if (contourVertexCount > 0) { - if (JSM.CoordIsEqual2DWithEps (result.GetVertex (contour, contourVertexCount - 1), transformedCoord, 0.1)) { + if (result.GetVertex (contour, contourVertexCount - 1).IsEqualWithEps (transformedCoord, 0.1)) { return resultCoord; } } @@ -128,7 +128,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var firstCoord = polygon.GetVertex (contour, 0); var lastCoord = polygon.GetVertex (contour, vertexCount - 1); - if (JSM.CoordIsEqual2DWithEps (firstCoord, lastCoord, 0.1)) { + if (firstCoord.IsEqualWithEps (lastCoord, 0.1)) { polygon.GetContour (contour).vertices.pop (); } } diff --git a/src/geometry/coord.js b/src/geometry/coord.js index f94e3e4c..2bd00f0d 100644 --- a/src/geometry/coord.js +++ b/src/geometry/coord.js @@ -1,99 +1,3 @@ -/** -* Class: Coord2D -* Description: Represents a 2D coordinate. -* Parameters: -* x {number} the first component -* y {number} the second component -*/ -JSM.Coord2D = function (x, y) -{ - this.x = x; - this.y = y; -}; - -/** -* Function: Coord2D.Set -* Description: Sets the coordinate. -* Parameters: -* x {number} the first component -* y {number} the second component -*/ -JSM.Coord2D.prototype.Set = function (x, y) -{ - this.x = x; - this.y = y; -}; - -/** -* Function: Coord2D.ToString -* Description: Converts the coordinate values to string. -* Returns: -* {string} the string representation of the coordinate -*/ -JSM.Coord2D.prototype.ToString = function () -{ - return ('(' + this.x + ', ' + this.y + ')'); -}; - -/** -* Function: Coord2D.Clone -* Description: Clones the coordinate. -* Returns: -* {Coord2D} a cloned instance -*/ -JSM.Coord2D.prototype.Clone = function () -{ - return new JSM.Coord2D (this.x, this.y); -}; - -/** -* Class: PolarCoord -* Description: Represents a 2D polar coordinate. -* Parameters: -* radius {number} the first component -* angle {number} the second component -*/ -JSM.PolarCoord = function (radius, angle) -{ - this.radius = radius; - this.angle = angle; -}; - -/** -* Function: PolarCoord.Set -* Description: Sets the coordinate. -* Parameters: -* radius {number} the first component -* angle {number} the second component -*/ -JSM.PolarCoord.prototype.Set = function (radius, angle) -{ - this.radius = radius; - this.angle = angle; -}; - -/** -* Function: PolarCoord.ToString -* Description: Converts the coordinate values to string. -* Returns: -* {string} the string representation of the coordinate -*/ -JSM.PolarCoord.prototype.ToString = function () -{ - return ('(' + this.radius + ', ' + this.angle + ')'); -}; - -/** -* Function: PolarCoord.Clone -* Description: Clones the coordinate. -* Returns: -* {PolarCoord} a cloned instance -*/ -JSM.PolarCoord.prototype.Clone = function () -{ - return new JSM.PolarCoord (this.radius, this.angle); -}; - /** * Class: Coord * Description: Represents a 3D coordinate. @@ -146,6 +50,12 @@ JSM.Coord.prototype.Clone = function () return new JSM.Coord (this.x, this.y, this.z); }; +/** +* Class: Vector +* Description: Same as Coord. +*/ +JSM.Vector = JSM.Coord; + /** * Class: SphericalCoord * Description: Represents a 3D spherical coordinate. @@ -197,15 +107,3 @@ JSM.SphericalCoord.prototype.Clone = function () { return new JSM.SphericalCoord (this.radius, this.theta, this.phi); }; - -/** -* Class: Vector2D -* Description: Same as Coord2D. -*/ -JSM.Vector2D = JSM.Coord2D; - -/** -* Class: Vector -* Description: Same as Coord. -*/ -JSM.Vector = JSM.Coord; diff --git a/src/geometry/coord2d.js b/src/geometry/coord2d.js new file mode 100644 index 00000000..19536b64 --- /dev/null +++ b/src/geometry/coord2d.js @@ -0,0 +1,200 @@ +/** +* Class: Coord2D +* Description: Represents a 2D coordinate. +* Parameters: +* x {number} the first component +* y {number} the second component +*/ +JSM.Coord2D = function (x, y) +{ + this.x = x; + this.y = y; +}; + +/** +* Function: Coord2D.Set +* Description: Sets the coordinate. +* Parameters: +* x {number} the first component +* y {number} the second component +*/ +JSM.Coord2D.prototype.Set = function (x, y) +{ + this.x = x; + this.y = y; +}; + +/** +* Function: Coord2D.IsEqual +* Description: Returns if the coordinate is equal with the given one. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {boolean} the result +*/ +JSM.Coord2D.prototype.IsEqual = function (coord) +{ + return JSM.IsEqual (this.x, coord.x) && JSM.IsEqual (this.y, coord.y); +}; + +/** +* Function: Coord2D.IsEqualWithEps +* Description: Returns if the coordinate is equal with the given one. Uses the given epsilon for comparison. +* Parameters: +* coord {Coord2D} the coordinate +* eps {number} the epsilon +* Returns: +* {boolean} the result +*/ +JSM.Coord2D.prototype.IsEqualWithEps = function (coord, eps) +{ + return JSM.IsEqualWithEps (this.x, coord.x, eps) && JSM.IsEqualWithEps (this.y, coord.y, eps); +}; + + +/** +* Function: Coord2D.DistanceTo +* Description: Calculates the coordinate distance to the given one. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {number} the result +*/ +JSM.Coord2D.prototype.DistanceTo = function (coord) +{ + return Math.sqrt ((coord.x - this.x) * (coord.x - this.x) + (coord.y - this.y) * (coord.y - this.y)); +}; + +/** +* Function: Coord2D.Length +* Description: Calculates the length of the coordinate vector. +* Returns: +* {number} the result +*/ +JSM.Coord2D.prototype.Length = function () +{ + return Math.sqrt (this.x * this.x + this.y * this.y); +}; + +/** +* Function: Coord2D.MultiplyScalar +* Description: Multiplies the vector with a scalar. +* Parameters: +* scalar {number} the scalar +* Returns: +* {Coord2D} this pointer +*/ +JSM.Coord2D.prototype.MultiplyScalar = function (scalar) +{ + this.x *= scalar; + this.y *= scalar; + return this; +}; + +/** +* Function: Coord2D.Normalize +* Description: Normalizes the coordinate vector. +* Returns: +* {Coord2D} this pointer +*/ +JSM.Coord2D.prototype.Normalize = function () +{ + var length = this.Length (); + if (JSM.IsPositive (length)) { + this.MultiplyScalar (1.0 / length); + } + return this; +}; + +/** +* Function: Coord2D.SetLength +* Description: Sets the length of the coordinate vector. +* Parameters: +* length {number} the length +* Returns: +* {Coord2D} this pointer +*/ +JSM.Coord2D.prototype.SetLength = function (length) +{ + var thisLength = this.Length (); + if (JSM.IsPositive (thisLength)) { + this.MultiplyScalar (length / thisLength); + } + return this; +}; + +/** +* Function: Coord2D.ToString +* Description: Converts the coordinate values to string. +* Returns: +* {string} the string representation of the coordinate +*/ +JSM.Coord2D.prototype.ToString = function () +{ + return ('(' + this.x + ', ' + this.y + ')'); +}; + +/** +* Function: Coord2D.Clone +* Description: Clones the coordinate. +* Returns: +* {Coord2D} a cloned instance +*/ +JSM.Coord2D.prototype.Clone = function () +{ + return new JSM.Coord2D (this.x, this.y); +}; + +/** +* Class: Vector2D +* Description: Same as Coord2D. +*/ +JSM.Vector2D = JSM.Coord2D; + +/** +* Class: PolarCoord +* Description: Represents a 2D polar coordinate. +* Parameters: +* radius {number} the first component +* angle {number} the second component +*/ +JSM.PolarCoord = function (radius, angle) +{ + this.radius = radius; + this.angle = angle; +}; + +/** +* Function: PolarCoord.Set +* Description: Sets the coordinate. +* Parameters: +* radius {number} the first component +* angle {number} the second component +*/ +JSM.PolarCoord.prototype.Set = function (radius, angle) +{ + this.radius = radius; + this.angle = angle; +}; + +/** +* Function: PolarCoord.ToString +* Description: Converts the coordinate values to string. +* Returns: +* {string} the string representation of the coordinate +*/ +JSM.PolarCoord.prototype.ToString = function () +{ + return ('(' + this.radius + ', ' + this.angle + ')'); +}; + +/** +* Function: PolarCoord.Clone +* Description: Clones the coordinate. +* Returns: +* {PolarCoord} a cloned instance +*/ +JSM.PolarCoord.prototype.Clone = function () +{ + return new JSM.PolarCoord (this.radius, this.angle); +}; diff --git a/src/geometry/coordutils2d.js b/src/geometry/coordutils2d.js index 335f9b3f..415690bf 100644 --- a/src/geometry/coordutils2d.js +++ b/src/geometry/coordutils2d.js @@ -24,35 +24,6 @@ JSM.CoordToArray2D = function (coord) return [coord.x, coord.y]; }; -/** -* Function: CoordIsEqual2D -* Description: Determines if the given coordinates are equal. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* Returns: -* {boolean} the result -*/ -JSM.CoordIsEqual2D = function (a, b) -{ - return JSM.IsEqual (a.x, b.x) && JSM.IsEqual (a.y, b.y); -}; - -/** -* Function: CoordIsEqual2DWithEps -* Description: Determines if the given coordinates are equal. Uses the given epsilon for comparison. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* eps {number} the epsilon value -* Returns: -* {boolean} the result -*/ -JSM.CoordIsEqual2DWithEps = function (a, b, eps) -{ - return JSM.IsEqualWithEps (a.x, b.x, eps) && JSM.IsEqualWithEps (a.y, b.y, eps); -}; - /** * Function: CoordAdd2D * Description: Adds two coordinates. @@ -81,25 +52,6 @@ JSM.CoordSub2D = function (a, b) return new JSM.Coord2D (a.x - b.x, a.y - b.y, a.z - b.z); }; -/** -* Function: CoordDistance2D -* Description: Calculates the distance of two coordinates. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* Returns: -* {number} the result -*/ -JSM.CoordDistance2D = function (a, b) -{ - var x1 = a.x; - var y1 = a.y; - var x2 = b.x; - var y2 = b.y; - - return Math.sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); -}; - /** * Function: MidCoord2D * Description: Calculates the coordinate in the middle of two coordinates. @@ -114,73 +66,6 @@ JSM.MidCoord2D = function (a, b) return new JSM.Coord2D ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0); }; -/** -* Function: VectorMultiply2D -* Description: Multiplies a vector with a scalar. -* Parameters: -* vector {Vector2D} the vector -* scalar {number} the scalar -* Returns: -* {Vector2D} the result -*/ -JSM.VectorMultiply2D = function (vector, scalar) -{ - var result = new JSM.Vector2D (0.0, 0.0, 0.0); - result.x = vector.x * scalar; - result.y = vector.y * scalar; - return result; -}; - -/** -* Function: VectorLength2D -* Description: Calculates length of a vector. -* Parameters: -* vector {Vector2D} the vector -* Returns: -* {number} the result -*/ -JSM.VectorLength2D = function (vector) -{ - var x = vector.x; - var y = vector.y; - - return Math.sqrt (x * x + y * y); -}; - -/** -* Function: VectorNormalize2D -* Description: Normalize a vector. -* Parameters: -* vector {Vector2D} the vector -* Returns: -* {Vector2D} the result -*/ -JSM.VectorNormalize2D = function (vector) -{ - var length = JSM.VectorLength2D (vector); - var result = new JSM.Vector2D (0.0, 0.0); - if (JSM.IsGreater (length, 0.0)) { - result = JSM.VectorMultiply2D (vector, 1.0 / length); - } - return result; -}; - -/** -* Function: VectorSetLength2D -* Description: Sets the length of a vector. -* Parameters: -* vector {Vector2D} the vector -* length {number} the length -* Returns: -* {Vector2D} the result -*/ -JSM.VectorSetLength2D = function (vector, length) -{ - var ratio = length / JSM.VectorLength2D (vector); - var result = JSM.VectorMultiply2D (vector, ratio); - return result; -}; - /** * Function: CoordOffset2D * Description: Offsets a coordinate. @@ -193,7 +78,7 @@ JSM.VectorSetLength2D = function (vector, length) */ JSM.CoordOffset2D = function (coord, direction, distance) { - var normal = JSM.VectorNormalize2D (direction); + var normal = direction.Clone ().Normalize (); var result = new JSM.Coord2D (0.0, 0.0); result.x = coord.x + normal.x * distance; result.y = coord.y + normal.y * distance; diff --git a/src/geometry/polygonutils.js b/src/geometry/polygonutils.js index 82ab8cb0..5b5ff0ce 100644 --- a/src/geometry/polygonutils.js +++ b/src/geometry/polygonutils.js @@ -208,11 +208,11 @@ JSM.CoordPolygonPosition2D = function (coord, polygon) if (ssp === 'SectorsIntersectsOnePoint') { intersections++; } else if (ssp === 'SectorsIntersectsEndPoint') { - if (JSM.CoordIsEqual2D (intersection, sector.beg)) { + if (intersection.IsEqual (sector.beg)) { if (JSM.IsGreater (sector.beg.y, sector.end.y)) { intersections++; } - } else if (JSM.CoordIsEqual2D (intersection, sector.end)) { + } else if (intersection.IsEqual (sector.end)) { if (JSM.IsLower (sector.beg.y, sector.end.y)) { intersections++; } diff --git a/src/geometry/sector.js b/src/geometry/sector.js index 78b63987..ef552936 100644 --- a/src/geometry/sector.js +++ b/src/geometry/sector.js @@ -32,7 +32,7 @@ JSM.Sector2D.prototype.Set = function (beg, end) */ JSM.Sector2D.prototype.GetLength = function () { - return JSM.CoordDistance2D (this.beg, this.end); + return this.beg.DistanceTo (this.end); }; /** diff --git a/src/geometry/sectorutils.js b/src/geometry/sectorutils.js index 9c509192..863472a8 100644 --- a/src/geometry/sectorutils.js +++ b/src/geometry/sectorutils.js @@ -18,7 +18,7 @@ JSM.CoordSectorPosition2D = function (coord, sector) var length = sector.GetLength (); if (JSM.IsZero (length)) { - if (JSM.CoordIsEqual2D (coord, sector.beg)) { + if (coord.IsEqual (sector.beg)) { return 'CoordOnSectorEndCoord'; } @@ -76,8 +76,8 @@ JSM.ProjectCoordToSector2D = function (coord, sector) return end; } - var dir = JSM.CoordSub2D (end, beg); - var result = JSM.CoordAdd2D (beg, JSM.VectorMultiply2D (dir, u)); + var dir = JSM.CoordSub2D (end, beg).MultiplyScalar (u); + var result = JSM.CoordAdd2D (beg, dir); return result; }; diff --git a/src/viewer/spriteviewer.js b/src/viewer/spriteviewer.js index 4ea8441b..09386d24 100644 --- a/src/viewer/spriteviewer.js +++ b/src/viewer/spriteviewer.js @@ -90,7 +90,7 @@ JSM.SpriteViewer.prototype.NearestPointUnderPosition = function (maxDistance, x, var i, projected, distance; for (i = 0; i < this.projected.length; i++) { projected = this.projected[i]; - distance = JSM.CoordDistance2D (new JSM.Coord2D (projected.position.x, projected.position.y), position); + distance = position.DistanceTo (new JSM.Coord2D (projected.position.x, projected.position.y)); if (JSM.IsLower (distance, maxDistance) && JSM.IsLower (distance, minDistance)) { minIndex = projected.originalIndex; minDistance = distance; diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index 5c071493..d3ebcb29 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -7,6 +7,7 @@ unitTest.AddSourceFile ('../../src/core/timer.js'); unitTest.AddSourceFile ('../../src/core/algorithm.js'); unitTest.AddSourceFile ('../../src/core/async.js'); unitTest.AddSourceFile ('../../src/core/check.js'); +unitTest.AddSourceFile ('../../src/geometry/coord2d.js'); unitTest.AddSourceFile ('../../src/geometry/coord.js'); unitTest.AddSourceFile ('../../src/geometry/determinant.js'); unitTest.AddSourceFile ('../../src/geometry/coordutils2d.js'); diff --git a/test/unittest/tests/extras.js b/test/unittest/tests/extras.js index 39b00a0c..55aa65ec 100644 --- a/test/unittest/tests/extras.js +++ b/test/unittest/tests/extras.js @@ -11,7 +11,7 @@ extrasSuite.AddTest ('BezierCurveTest', function (test) test.Assert (result.length == output.length); var i; for (i = 0; i < result.length; i++) { - test.Assert (JSM.CoordIsEqual2D (result[i], output[i])); + test.Assert (result[i].IsEqual (output[i])); } } diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index ca053706..edc1bc9a 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -6,40 +6,45 @@ var generalSuite = unitTest.AddTestSuite ('GeometryGeneral'); generalSuite.AddTest ('Vector2DTest', function (test) { var coord1 = new JSM.Coord2D (1.0, 0.0); var coord2 = new JSM.Coord2D (0.0, 1.0); - test.Assert (JSM.CoordIsEqual2D (JSM.CoordAdd2D (coord1, coord2), new JSM.Coord2D (1, 1))); - test.Assert (JSM.IsEqual (JSM.CoordDistance2D (coord1, coord2), Math.sqrt (2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.MidCoord2D (coord1, coord2), new JSM.Coord2D (0.5, 0.5))); - var coord3 = JSM.VectorMultiply2D (coord1, 10); - test.Assert (JSM.CoordIsEqual2D (coord3, new JSM.Coord2D (10, 0))); - test.Assert (JSM.IsEqual (JSM.VectorLength2D (coord3), 10.0)); - var coord4 = JSM.VectorNormalize2D (coord3, 10); - test.Assert (JSM.CoordIsEqual2D (coord4, new JSM.Coord2D (1, 0))); - test.Assert (JSM.IsEqual (JSM.VectorLength2D (coord4), 1.0)); - var coord5 = JSM.VectorSetLength2D (coord3, 5); - test.Assert (JSM.CoordIsEqual2D (coord5, new JSM.Coord2D (5, 0))); - test.Assert (JSM.IsEqual (JSM.VectorLength2D (coord5), 5.0)); + test.Assert (JSM.CoordAdd2D (coord1, coord2).IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (JSM.IsEqual (coord1.DistanceTo (coord2), Math.sqrt (2.0))); + test.Assert (JSM.MidCoord2D (coord1, coord2).IsEqual (new JSM.Coord2D (0.5, 0.5))); + var coord3 = coord1.Clone ().MultiplyScalar (10); + test.Assert (coord3.IsEqual (new JSM.Coord2D (10, 0))); + test.Assert (JSM.IsEqual (coord3.Length (), 10.0)); + var coord4 = coord3.Clone ().Normalize (); + test.Assert (coord3.IsEqual (new JSM.Coord2D (10, 0))); + test.Assert (coord4.IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (JSM.IsEqual (coord4.Length (), 1.0)); + var coord5 = coord3.Clone ().SetLength (5); + test.Assert (coord3.IsEqual (new JSM.Coord2D (10, 0))); + test.Assert (coord5.IsEqual (new JSM.Coord2D (5, 0))); + test.Assert (JSM.IsEqual (coord5.Length (), 5.0)); var coord6 = JSM.CoordOffset2D (coord1, coord2, 3.0); - test.Assert (JSM.CoordIsEqual2D (coord6, new JSM.Coord2D (1, 3))); + test.Assert (coord6.IsEqual (new JSM.Coord2D (1, 3))); + var coord7 = coord3.Normalize (); + test.Assert (coord3.IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (coord7.IsEqual (new JSM.Coord2D (1, 0))); var origo = new JSM.Coord2D (0.0, 0.0); var rotated = JSM.CoordRotate2D (coord1, Math.PI / 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (0, 1))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (0, 1))); var rotated = JSM.CoordRotate2D (coord1, Math.PI, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (-1, 0))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, 0))); var rotated = JSM.CoordRotate2D (coord1, Math.PI * 3.0 / 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (0, -1))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (0, -1))); var rotated = JSM.CoordRotate2D (coord1, Math.PI * 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (1, 0))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (1, 0))); var origo = new JSM.Coord2D (-1.0, 0.0); var rotated = JSM.CoordRotate2D (coord1, Math.PI / 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (-1, 2))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, 2))); var rotated = JSM.CoordRotate2D (coord1, Math.PI, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (-3, 0))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (-3, 0))); var rotated = JSM.CoordRotate2D (coord1, Math.PI * 3.0 / 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (-1, -2))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, -2))); var rotated = JSM.CoordRotate2D (coord1, Math.PI * 2.0, origo); - test.Assert (JSM.CoordIsEqual2D (rotated, new JSM.Coord2D (1, 0))); + test.Assert (rotated.IsEqual (new JSM.Coord2D (1, 0))); }); generalSuite.AddTest ('VectorTest', function (test) { @@ -47,9 +52,9 @@ generalSuite.AddTest ('VectorTest', function (test) { var coord2d2 = new JSM.Coord2D (3, 4); var coord2d3 = new JSM.Coord2D (1, 6); - test.Assert (JSM.CoordIsEqual2D (coord2d1, new JSM.Coord2D (1, 2))); - test.Assert (JSM.CoordIsEqual2D (JSM.MidCoord2D (coord2d1, coord2d2), new JSM.Coord2D (2, 3))); - test.Assert (JSM.IsEqual (JSM.CoordDistance2D (coord2d1, coord2d2), 2.8284271247)); + test.Assert (coord2d1.IsEqual (new JSM.Coord2D (1, 2))); + test.Assert (JSM.MidCoord2D (coord2d1, coord2d2).IsEqual (new JSM.Coord2D (2, 3))); + test.Assert (JSM.IsEqual (coord2d1.DistanceTo (coord2d2), 2.8284271247)); test.Assert (JSM.CoordTurnType2D (coord2d1, coord2d2, coord2d3) == 'CounterClockwise'); var coord1 = new JSM.Coord (1, 2, 3); @@ -110,7 +115,7 @@ generalSuite.AddTest ('VectorTest', function (test) { var normal = new JSM.Coord (0.0, 1.0, 0.0); var origo = new JSM.Coord (0.0, 0.0, 0.0); var coord2D = JSM.GetCoord2DFromCoord (coord, origo, normal); - test.Assert (JSM.CoordIsEqual2D (coord2D, new JSM.Coord (1.0, -3.0))); + test.Assert (coord2D.IsEqual (new JSM.Coord (1.0, -3.0))); var coords = [ new JSM.Coord (0.0, 0.0, 0.0), @@ -192,10 +197,10 @@ generalSuite.AddTest ('VectorTest', function (test) { test.Assert (JSM.IsEqual (JSM.CoordSignedDistance (coord1, coord3, JSM.CoordSub (coord1, coord3)), -1.0)); var coord = new JSM.Coord2D (1.0, 2.0); - test.Assert (!JSM.CoordIsEqual2DWithEps (coord, new JSM.Coord2D (1.0, 3.0), 0.1)); - test.Assert (!JSM.CoordIsEqual2DWithEps (coord, new JSM.Coord2D (2.0, 2.0), 0.1)); - test.Assert (JSM.CoordIsEqual2DWithEps (coord, new JSM.Coord2D (1.0, 3.0), 1.1)); - test.Assert (JSM.CoordIsEqual2DWithEps (coord, new JSM.Coord2D (2.0, 2.0), 1.1)); + test.Assert (!coord.IsEqualWithEps (new JSM.Coord2D (1.0, 3.0), 0.1)); + test.Assert (!coord.IsEqualWithEps (new JSM.Coord2D (2.0, 2.0), 0.1)); + test.Assert (coord.IsEqualWithEps (new JSM.Coord2D (1.0, 3.0), 1.1)); + test.Assert (coord.IsEqualWithEps (new JSM.Coord2D (2.0, 2.0), 1.1)); var coord = new JSM.Coord (1.0, 2.0, 3.0); test.Assert (!JSM.CoordIsEqualWithEps (coord, new JSM.Coord (1.0, 2.0, 4.0), 0.1)); @@ -335,12 +340,12 @@ generalSuite.AddTest ('SphericalTest', function (test) { }); generalSuite.AddTest ('CircleTest', function (test) { - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 0.0 * JSM.DegRad), new JSM.Coord2D (1.0, 0.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 90.0 * JSM.DegRad), new JSM.Coord2D (0.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 180.0 * JSM.DegRad), new JSM.Coord2D (-1.0, 0.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 270.0 * JSM.DegRad), new JSM.Coord2D (0.0, -1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 360.0 * JSM.DegRad), new JSM.Coord2D (1.0, 0.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.PolarToCartesian (1.0, 450.0 * JSM.DegRad), new JSM.Coord2D (0.0, 1.0))); + test.Assert (JSM.PolarToCartesian (1.0, 0.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (1.0, 0.0))); + test.Assert (JSM.PolarToCartesian (1.0, 90.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (0.0, 1.0))); + test.Assert (JSM.PolarToCartesian (1.0, 180.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (-1.0, 0.0))); + test.Assert (JSM.PolarToCartesian (1.0, 270.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (0.0, -1.0))); + test.Assert (JSM.PolarToCartesian (1.0, 360.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (1.0, 0.0))); + test.Assert (JSM.PolarToCartesian (1.0, 450.0 * JSM.DegRad).IsEqual (new JSM.Coord2D (0.0, 1.0))); var unitRadius = 2.0 * 1.0 * Math.PI; test.Assert (JSM.IsEqual (JSM.GetArcLengthFromAngle (1.0, 0.0 * JSM.DegRad), 0.0)); @@ -637,12 +642,12 @@ generalSuite.AddTest ('SectorTest', function (test) { var end = new JSM.Coord2D (3.0, 4.0); var sector = new JSM.Sector2D (beg, end); - test.Assert (JSM.CoordIsEqual2D (sector.beg, new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (sector.end, new JSM.Coord2D (3.0, 4.0))); + test.Assert (sector.beg.IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector.end.IsEqual (new JSM.Coord2D (3.0, 4.0))); sector.Set (end, beg); - test.Assert (JSM.CoordIsEqual2D (sector.beg, new JSM.Coord2D (3.0, 4.0))); - test.Assert (JSM.CoordIsEqual2D (sector.end, new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector.beg.IsEqual (new JSM.Coord2D (3.0, 4.0))); + test.Assert (sector.end.IsEqual (new JSM.Coord2D (1.0, 2.0))); var beg = new JSM.Coord (1.0, 2.0, 3.0); var end = new JSM.Coord (4.0, 5.0, 6.0); @@ -814,35 +819,35 @@ generalSuite.AddTest ('ProjectCoordToSector2DTest', function (test) var sector3 = new JSM.Sector2D (new JSM.Coord2D (1.0, 1.0), new JSM.Coord2D (3.0, 1.0)); var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector1), new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector1), new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.001), sector1), new JSM.Coord2D (1.0, 2.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.001), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector2), new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (7.0, 5.0), sector2), new JSM.Coord2D (4.0, 3.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (-2.0, 2.0), sector2), new JSM.Coord2D (1, 2))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 2.0), sector2), new JSM.Coord2D (1.9, 2.3))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 2.5), sector2), new JSM.Coord2D (2.95, 2.65))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 3.0), sector2), new JSM.Coord2D (2.2, 2.4))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 3.0), sector2), new JSM.Coord2D (3.1, 2.7))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector2), new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 3.0), sector2), new JSM.Coord2D (4.0, 3.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.5), sector2), new JSM.Coord2D (2.5, 2.5))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.25), sector2), new JSM.Coord2D (1.75, 2.25))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.501), sector2), new JSM.Coord2D (2.5003, 2.5001))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.26), sector2), new JSM.Coord2D (1.753, 2.251))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector2).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (7.0, 5.0), sector2).IsEqual (new JSM.Coord2D (4.0, 3.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (-2.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1, 2))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1.9, 2.3))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 2.5), sector2).IsEqual (new JSM.Coord2D (2.95, 2.65))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 3.0), sector2).IsEqual (new JSM.Coord2D (2.2, 2.4))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 3.0), sector2).IsEqual (new JSM.Coord2D (3.1, 2.7))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 3.0), sector2).IsEqual (new JSM.Coord2D (4.0, 3.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.5), sector2).IsEqual (new JSM.Coord2D (2.5, 2.5))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.25), sector2).IsEqual (new JSM.Coord2D (1.75, 2.25))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.501), sector2).IsEqual (new JSM.Coord2D (2.5003, 2.5001))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.26), sector2).IsEqual (new JSM.Coord2D (1.753, 2.251))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 1.0), sector3), new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.001, 1.0), sector3), new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 1.0), sector3), new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.999, 1.0), sector3), new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 1.0), sector3), new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 1.0), sector3), new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.1, 1.0), sector3), new JSM.Coord2D (1.1, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 0.0), sector3), new JSM.Coord2D (2.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.123456789, 1.0), sector3), new JSM.Coord2D (1.123456789, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.001, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.999, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.1, 1.0), sector3).IsEqual (new JSM.Coord2D (1.1, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 0.0), sector3).IsEqual (new JSM.Coord2D (2.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.123456789, 1.0), sector3).IsEqual (new JSM.Coord2D (1.123456789, 1.0))); - test.Assert (JSM.CoordIsEqual2D (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector4), new JSM.Coord2D (0.0, 1.0))); + test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector4).IsEqual (new JSM.Coord2D (0.0, 1.0))); }); generalSuite.AddTest ('SectorSectorPositionTest', function (test) @@ -865,9 +870,9 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 0.0, 1.0)) == 'SectorsDontIntersects'); test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 1.0, 0.0)) == 'SectorsDontIntersects'); test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.CoordIsEqual2D (intersection, new JSM.Coord2D (1.0, 1.0))); + test.Assert (intersection.IsEqual (new JSM.Coord2D (1.0, 1.0))); test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.CoordIsEqual2D (intersection, new JSM.Coord2D (3.0, 1.0))); + test.Assert (intersection.IsEqual (new JSM.Coord2D (3.0, 1.0))); test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 1.0, 3.0, 1.0)) == 'SectorsIntersectsCoincident'); test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (3.0, 1.0, 1.0, 1.0)) == 'SectorsIntersectsCoincident'); @@ -911,7 +916,7 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) generalSuite.AddTest ('BoxTest', function (test) { var box = new JSM.Box2D (new JSM.Coord2D (0.0, 0.0), new JSM.Coord2D (1.0, 1.0)); - test.Assert (JSM.CoordIsEqual2D (box.GetCenter (), new JSM.Coord2D (0.5, 0.5))); + test.Assert (box.GetCenter ().IsEqual (new JSM.Coord2D (0.5, 0.5))); var box = new JSM.Box (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 1.0, 1.0)); test.Assert (JSM.CoordIsEqual (box.GetCenter (), new JSM.Coord (0.5, 0.5, 0.5))); @@ -1581,9 +1586,9 @@ polygonSuite.AddTest ('ContourPolygon2DTest', function (test) test.Assert (polygon.VertexCount (1) == 3); test.Assert (polygon.VertexCount (2) == 3); - test.Assert (JSM.CoordIsEqual2D (polygon.GetVertex (0, 1), new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (polygon.GetVertex (1, 1), new JSM.Coord2D (2, 0))); - test.Assert (JSM.CoordIsEqual2D (polygon.GetVertex (2, 1), new JSM.Coord2D (3, 0))); + test.Assert (polygon.GetVertex (0, 1).IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (polygon.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); + test.Assert (polygon.GetVertex (2, 1).IsEqual (new JSM.Coord2D (3, 0))); var cloned = polygon.Clone (); test.Assert (cloned.ContourCount () == 3); @@ -1591,13 +1596,13 @@ polygonSuite.AddTest ('ContourPolygon2DTest', function (test) test.Assert (cloned.VertexCount (1) == 3); test.Assert (cloned.VertexCount (2) == 3); - test.Assert (JSM.CoordIsEqual2D (cloned.GetVertex (0, 1), new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (cloned.GetVertex (1, 1), new JSM.Coord2D (2, 0))); - test.Assert (JSM.CoordIsEqual2D (cloned.GetVertex (2, 1), new JSM.Coord2D (3, 0))); + test.Assert (cloned.GetVertex (0, 1).IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (cloned.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); + test.Assert (cloned.GetVertex (2, 1).IsEqual (new JSM.Coord2D (3, 0))); cloned.SetVertex (1, 1, 5, 6); - test.Assert (JSM.CoordIsEqual2D (polygon.GetVertex (1, 1), new JSM.Coord2D (2, 0))); - test.Assert (JSM.CoordIsEqual2D (cloned.GetVertex (1, 1), new JSM.Coord2D (5, 6))); + test.Assert (polygon.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); + test.Assert (cloned.GetVertex (1, 1).IsEqual (new JSM.Coord2D (5, 6))); polygon.Clear (); test.Assert (polygon.ContourCount () == 0); diff --git a/test/unittest/tests/modeler.js b/test/unittest/tests/modeler.js index 22421bd3..be49c53c 100644 --- a/test/unittest/tests/modeler.js +++ b/test/unittest/tests/modeler.js @@ -1451,20 +1451,20 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) var textureCoords = JSM.CalculateBodyTextureCoords (body); test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); body.SetPlanarTextureProjection (new JSM.Coord (0.2, 0.0, 0.2), new JSM.Coord (0.0, 0.0, 1.0), new JSM.Coord (0.0, -1.0, 0.0)); textureCoords = JSM.CalculateBodyTextureCoords (body); test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (-0.2, -0.2))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (-0.2, 0.8))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (0.8, 0.8))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0.8, -0.2))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (-0.2, -0.2))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (-0.2, 0.8))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (0.8, 0.8))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0.8, -0.2))); body.SetPlanarTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0)); @@ -1478,15 +1478,15 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) test.Assert (textureCoords[0].length == 4); test.Assert (textureCoords[1].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][1], new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][2], new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][3], new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[1][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[1][1].IsEqual (new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[1][2].IsEqual (new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[1][3].IsEqual (new JSM.Coord2D (0, 0))); var body = new JSM.Body (); body.AddVertex (new JSM.BodyVertex (new JSM.Coord (0.0, 0.0, 0.0))); @@ -1502,10 +1502,10 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); body.SetPlanarTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (10.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, -20.0)); @@ -1513,10 +1513,10 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); body.SetPlanarTextureProjection (new JSM.Coord (0.2, 0.2, 1.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, -1.0)); @@ -1524,10 +1524,10 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (-0.2, -0.2))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (0.8, -0.2))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (0.8, 0.8))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (-0.2, 0.8))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (-0.2, -0.2))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (0.8, -0.2))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (0.8, 0.8))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (-0.2, 0.8))); body.SetPlanarTextureProjection (new JSM.Coord (0.2, 0.3, 1.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, -1.0)); @@ -1535,10 +1535,10 @@ textureSuite.AddTest ('BodyPlanarTextureCoordTest', function (test) test.Assert (textureCoords.length == 1); test.Assert (textureCoords[0].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (-0.2, -0.3))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (0.8, -0.3))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (0.8, 0.7))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (-0.2, 0.7))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (-0.2, -0.3))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (0.8, -0.3))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (0.8, 0.7))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (-0.2, 0.7))); }); textureSuite.AddTest ('BodyCubicTextureCoordTest', function (test) @@ -1566,20 +1566,20 @@ textureSuite.AddTest ('BodyCubicTextureCoordTest', function (test) test.Assert (textureCoords[1].length == 4); test.Assert (textureCoords[2].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][1], new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][3], new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[1][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[1][1].IsEqual (new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[1][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[1][3].IsEqual (new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[2][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[2][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[2][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[2][3].IsEqual (new JSM.Coord2D (0, 1))); body.SetCubicTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (10.0, 0.0, 0.0), new JSM.Coord (0.0, 12.0, 0.0), new JSM.Coord (0.0, 0.0, 30.0)); @@ -1589,20 +1589,20 @@ textureSuite.AddTest ('BodyCubicTextureCoordTest', function (test) test.Assert (textureCoords[1].length == 4); test.Assert (textureCoords[2].length == 4); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][1], new JSM.Coord2D (0, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][3], new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[1][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[1][1].IsEqual (new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[1][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[1][3].IsEqual (new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][0], new JSM.Coord2D (0, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][1], new JSM.Coord2D (1, 0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][2], new JSM.Coord2D (1, 1))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][3], new JSM.Coord2D (0, 1))); + test.Assert (textureCoords[2][0].IsEqual (new JSM.Coord2D (0, 0))); + test.Assert (textureCoords[2][1].IsEqual (new JSM.Coord2D (1, 0))); + test.Assert (textureCoords[2][2].IsEqual (new JSM.Coord2D (1, 1))); + test.Assert (textureCoords[2][3].IsEqual (new JSM.Coord2D (0, 1))); }); textureSuite.AddTest ('BodyCylindricalTextureCoordTest', function (test) @@ -1621,17 +1621,17 @@ textureSuite.AddTest ('BodyCylindricalTextureCoordTest', function (test) test.Assert (textureCoords[5].length == 4); var radius = 2.0 * Math.PI; - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (radius, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][1], new JSM.Coord2D (radius * 5.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][2], new JSM.Coord2D (radius * 5.0 / 6.0, 0.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][3], new JSM.Coord2D (radius, 0.0))); - - test.Assert (JSM.CoordIsEqual2D (textureCoords[0][0], new JSM.Coord2D (radius * 6.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[1][0], new JSM.Coord2D (radius * 5.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[2][0], new JSM.Coord2D (radius * 4.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[3][0], new JSM.Coord2D (radius * 3.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[4][0], new JSM.Coord2D (radius * 2.0 / 6.0, 1.0))); - test.Assert (JSM.CoordIsEqual2D (textureCoords[5][0], new JSM.Coord2D (radius * 1.0 / 6.0, 1.0))); + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (radius, 1.0))); + test.Assert (textureCoords[0][1].IsEqual (new JSM.Coord2D (radius * 5.0 / 6.0, 1.0))); + test.Assert (textureCoords[0][2].IsEqual (new JSM.Coord2D (radius * 5.0 / 6.0, 0.0))); + test.Assert (textureCoords[0][3].IsEqual (new JSM.Coord2D (radius, 0.0))); + + test.Assert (textureCoords[0][0].IsEqual (new JSM.Coord2D (radius * 6.0 / 6.0, 1.0))); + test.Assert (textureCoords[1][0].IsEqual (new JSM.Coord2D (radius * 5.0 / 6.0, 1.0))); + test.Assert (textureCoords[2][0].IsEqual (new JSM.Coord2D (radius * 4.0 / 6.0, 1.0))); + test.Assert (textureCoords[3][0].IsEqual (new JSM.Coord2D (radius * 3.0 / 6.0, 1.0))); + test.Assert (textureCoords[4][0].IsEqual (new JSM.Coord2D (radius * 2.0 / 6.0, 1.0))); + test.Assert (textureCoords[5][0].IsEqual (new JSM.Coord2D (radius * 1.0 / 6.0, 1.0))); }); var utilsSuite = unitTest.AddTestSuite ('ModelerUtils'); diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index dc4cee6b..388604d0 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 48d6de85..9979a4b0 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index 1693788c..4ec7de2b 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index 63c211a7..c7cff6df 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index 457ffe72..0c4c5ab2 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 55e1b826..81216275 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -15,6 +15,7 @@ + diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index 3c5448f7..5f523199 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -15,6 +15,7 @@ + diff --git a/tools/files.txt b/tools/files.txt index 57066e4e..c33b37cf 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -3,6 +3,7 @@ ../src/core/algorithm.js ../src/core/async.js ../src/core/check.js +../src/geometry/coord2d.js ../src/geometry/coord.js ../src/geometry/determinant.js ../src/geometry/coordutils2d.js From 8b41d2c0119bd46eb8c827bec3c1c31053d13e28 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 16 Jul 2015 20:09:38 +0200 Subject: [PATCH 08/27] Create class member functions from utility functions. --- build/jsmodeler.js | 522 +++++------ build/jsmodeler.viewer.js | 2 +- documentation/demo/include/shapegenerators.js | 8 +- documentation/jsmdoc/include/jsmdoc.css | 6 + documentation/jsmdoc/include/jsmdoc.json | 732 ++++++--------- documentation/jsmdoc/index.html | 62 +- sandbox/3dsdump.html | 3 +- sandbox/bezier.html | 3 +- sandbox/beziercurve.html | 3 +- sandbox/bspline.html | 3 +- sandbox/charts.html | 3 +- sandbox/contourbody.html | 145 --- sandbox/contourbody.js | 152 --- sandbox/convexhull.html | 3 +- sandbox/coplanar.html | 3 +- sandbox/csg.html | 3 +- sandbox/csg2.html | 3 +- sandbox/curvedprism.html | 3 +- sandbox/docimages.html | 3 +- sandbox/doublesided.html | 3 +- sandbox/githublogo.html | 3 +- sandbox/heightmap.html | 3 +- sandbox/hiddenline.html | 3 +- sandbox/importer.html | 3 +- sandbox/jsonimport.html | 3 +- sandbox/jsonimporttexture.html | 3 +- sandbox/minimal.html | 3 +- sandbox/minimal2.html | 3 +- sandbox/octree.html | 3 +- sandbox/pointcloud.html | 3 +- sandbox/pointcloudjson.html | 3 +- sandbox/print.html | 3 +- sandbox/prismwithhole.html | 3 +- sandbox/randommat.html | 3 +- sandbox/renderer.html | 3 +- sandbox/revolved.html | 3 +- sandbox/smartbuilder.html | 3 +- sandbox/smartbuilder2.html | 3 +- sandbox/snippets/spherical.txt | 10 +- sandbox/solids.html | 3 +- sandbox/specular.html | 3 +- sandbox/svgonthefly.html | 3 +- sandbox/svgtomodel.html | 3 +- sandbox/svgtomodeltexture.html | 3 +- sandbox/tasks.html | 3 +- sandbox/texture.html | 3 +- sandbox/tictactoecanvas.html | 3 +- sandbox/triangulate.html | 3 +- sandbox/triangulatewithhole.html | 3 +- sandbox/tube.html | 7 +- sandbox/undermouse.html | 3 +- sandbox/viewer.html | 3 +- src/core/jsm.js | 195 ---- src/extras/curves.js | 2 +- src/extras/drawing.js | 2 +- src/extras/painter.js | 8 +- src/extras/solidgenerator.js | 8 +- src/extras/subdivision.js | 22 +- src/extras/svgtomodel.js | 4 +- src/geometry/convexhull.js | 2 +- src/geometry/coord.js | 257 ++++- src/geometry/coord2d.js | 135 ++- src/geometry/coordsystem.js | 157 ++++ src/geometry/coordsystemutils.js | 35 - src/geometry/coordutils.js | 496 +--------- src/geometry/coordutils2d.js | 189 ---- src/geometry/definitions.js | 223 +++++ src/geometry/lineutils.js | 23 +- src/geometry/matrix.js | 10 +- src/geometry/octree.js | 5 +- src/geometry/planeutils.js | 23 +- src/geometry/polygonutils.js | 41 +- src/geometry/ray.js | 4 +- src/geometry/sector.js | 2 +- src/geometry/sectorutils.js | 17 +- src/geometry/transformationutils.js | 4 +- src/geometry/utilities.js | 4 +- src/import/importerstl.js | 4 +- src/modeler/body.js | 10 +- src/modeler/bodyutils.js | 23 +- src/modeler/cututils.js | 6 +- src/modeler/generator.js | 62 +- src/modeler/rayutils.js | 5 +- src/modeler/textureutils.js | 20 +- src/modeler/trianglebody.js | 6 +- src/renderer/renderer.js | 2 +- src/three/threeviewer.js | 2 +- src/viewer/navigation.js | 48 +- src/viewer/pointcloudviewer.js | 2 +- src/viewer/softwareviewer.js | 2 +- src/viewer/spriteviewer.js | 2 +- src/viewer/viewer.js | 2 +- test/unittest/jsmodelertest.js | 3 +- test/unittest/tests/geometry.js | 886 ++++++++---------- test/unittest/tests/modeler.js | 303 +++--- test/viewertest/cameratest.html | 3 +- test/viewertest/csgtest.html | 3 +- test/viewertest/importtest.html | 3 +- test/viewertest/svgtomodeltest.html | 3 +- test/viewertest/texturetest.html | 3 +- test/viewertest/viewertest.html | 3 +- test/viewertest/viewertypes.html | 3 +- tools/documentation/jsmdoc/jsmdoc.py | 98 +- .../test/reference/testdocumentation.json | 24 + tools/documentation/test/runtest.py | 4 +- tools/documentation/test/testfiles.txt | 1 + .../test/testsource/module2/testfile5.js | 29 + tools/files.txt | 3 +- 108 files changed, 2335 insertions(+), 2873 deletions(-) delete mode 100644 sandbox/contourbody.html delete mode 100644 sandbox/contourbody.js delete mode 100644 src/geometry/coordsystemutils.js delete mode 100644 src/geometry/coordutils2d.js create mode 100644 src/geometry/definitions.js create mode 100644 tools/documentation/test/testsource/module2/testfile5.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index bcbb7e89..f6600d7a 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,136 +1,135 @@ -/* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=37};JSM.Eps=1E-8;JSM.Inf=9999999999;JSM.RadDeg=57.29577951308232;JSM.DegRad=0.017453292519943;JSM.IsZero=function(a){return Math.abs(a)JSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)=a&&(this.current=1E3*(this.frames/c),this.start=b,this.frames=0);return parseInt(this.current,10)}; -JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;ca.length||void 0===b||null===b)){var c,d;for(c=0;ca?0:Math.sqrt(a)}var l=JSM.CoordDistance(a,b),k=JSM.CoordDistance(b,c),m=JSM.CoordDistance(c,a);a=JSM.CoordDistance(a,h);b=JSM.CoordDistance(b,h);h=JSM.CoordDistance(c,h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=JSM.VectorMultiply(d,k);e=JSM.VectorMultiply(e,m);f=JSM.VectorMultiply(f,l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);return JSM.VectorMultiply(f, -1/c)};JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d};JSM.CartesianToSpherical=function(a,b,c){var d=new JSM.SphericalCoord(0,0,0);d.radius=Math.sqrt(a*a+b*b+c*c);if(JSM.IsZero(d.radius))return d;d.theta=Math.acos(c/d.radius);d.phi=Math.atan2(b,a);return d};JSM.SphericalToCartesianWithOrigo=function(a,b){var c=JSM.SphericalToCartesian(a.radius,a.theta,a.phi);return JSM.CoordAdd(c,b)}; -JSM.CartesianToSphericalWithOrigo=function(a,b){var c=JSM.CoordSub(a,b);return JSM.CartesianToSpherical(c.x,c.y,c.z)};JSM.MoveCoordOnSphere=function(a,b,c,d){a=JSM.CartesianToSphericalWithOrigo(a,b);a.theta+=c;a.phi+=d;return JSM.SphericalToCartesianWithOrigo(a,b)};JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return JSM.GetVectorsAngle(a,b)*c}; -JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c};JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],v=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*s;r[2]=c*g+d*m+e*q+f*v;r[3]=c*l+d*n+e*t+f*u;return r}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],v=a[14],u=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*r+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=t*r+s*x+v*L+u*N;F[13]=t*w+s*A+v*H+u*O;F[14]=t*y+s*B+v*C+u*J;F[15]=t*z+s*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*h-c*f)*(n*a-p*s)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*s-n*q)+(d*l-e*g)*(k*t-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var v=b*h-c*f,u=b*g-d*f,r=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*t-m*q,A=k*s-n*q,B=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,C=v*H-u*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(t*z-s*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(s*r-q*z-a*u)/C;E[7]=(k*z-n*r+p* -u)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-t*r+a*v)/C;E[11]=(m*r-k*y-p*v)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(t*u-q*w-s*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=JSM.VectorNormalize(a);a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d* -(1-b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.AsyncRunTask=function(a,b,c,d,e){function f(g){var h=a();b.OnProcess(g,e);h&&gJSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(g);b=b.DistanceTo(g);g=c.DistanceTo(g);c=h(l,k,m);if(JSM.IsZero(c))return d;l=h(l,a,b);k=h(k,b,g);m=h(m,a,g);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=a[1],h=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],u=a[14],v=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*g+d*k+e*p+f*s;r[2]=c*h+d*m+e*q+f*u;r[3]=c*l+d*n+e*t+f*v;return r}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],u=a[14],v=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=g*r+h*x+l*L+k*N;F[5]=g*w+h*A+l*H+k*O;F[6]=g*y+h*B+l*C+k*J;F[7]=g*z+h*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ +p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=t*r+s*x+u*L+v*N;F[13]=t*w+s*A+u*H+v*O;F[14]=t*y+s*B+u*C+v*J;F[15]=t*z+s*K+u*E+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*g-c*f)*(n*a-p*s)-(b*h-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*h-d*g)*(k*a-p*q)-(c*l-e*g)*(k*s-n*q)+(d*l-e*h)*(k*t-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var u=b*g-c*f,v=b*h-d*f,r=b*l-e*f,w=c*h-d*g,y=c*l-e*g,z=d*l-e*h,x=k*t-m*q,A=k*s-n*q,B=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,C=u*H-v*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(g*H-h*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(t*z-s*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(h*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(s*r-q*z-a*v)/C;E[7]=(k*z-n*r+p* +v)/C;E[8]=(f*L-g*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-t*r+a*u)/C;E[11]=(m*r-k*y-p*u)/C;E[12]=(g*A-f*K-h*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(t*v-q*w-s*u)/C;E[15]=(k*w-m*v+n*u)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,g=e*e,h=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(g+h)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=g+(f+h)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=h+(f+g)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(g+h)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=g+(f+h)*b;k[6]=e*d*(1- +b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=h+(f+g)*b;k[11]=0;k[12]=(m*(g+h)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+h)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+g)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,g=c+c,h=d+d;a=b*f;var l=b*g,b=b*h,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h,h=[];h[0]=1-(k+d);h[1]=l+e;h[2]=b-g;h[3]=0;h[4]=l-e;h[5]=1-(a+d);h[6]=c+f;h[7]=0;h[8]=b+g;h[9]=c-f;h[10]=1-(a+k);h[11]=0;h[12]=0;h[13]=0;h[14]=0;h[15]=1;return h};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; -JSM.MatrixView=function(a,b,c){if(JSM.CoordIsEqual(a,b))return JSM.MatrixIdentity();var d=[];b=JSM.VectorNormalize(JSM.CoordSub(a,b));c=JSM.VectorNormalize(JSM.VectorCross(c,b));var e=JSM.VectorNormalize(JSM.VectorCross(b,c));d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; +JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSystemToDirectionVectors=function(a){return new JSM.CoordSystem(a.origo,JSM.CoordSub(a.e1,a.origo),JSM.CoordSub(a.e2,a.origo),JSM.CoordSub(a.e3,a.origo))}; -JSM.CoordSystemToAbsoluteCoords=function(a){return new JSM.CoordSystem(a.origo,JSM.CoordAdd(a.e1,a.origo),JSM.CoordAdd(a.e2,a.origo),JSM.CoordAdd(a.e3,a.origo))};JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())}; -JSM.Sector=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return JSM.CoordDistance(this.beg,this.end)};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())}; -JSM.CoordSectorPosition2D=function(a,b){var c=a.x,d=a.y,e=b.beg.x,f=b.beg.y,h=b.end.x,g=b.end.y,l=b.GetLength();if(JSM.IsZero(l))return a.IsEqual(b.beg)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";l=((c-e)*(h-e)+(d-f)*(g-f))/(l*l);if(JSM.IsLower(l,0)||JSM.IsGreater(l,1))return"CoordOutsideOfSector";f+=l*(g-f);return!JSM.IsEqual(e+l*(h-e),c)||!JSM.IsEqual(f,d)?"CoordOutsideOfSector":JSM.IsEqual(l,0)||JSM.IsEqual(l,1)?"CoordOnSectorEndCoord":"CoordInsideOfSector"}; -JSM.ProjectCoordToSector2D=function(a,b){var c=a.x,d=a.y,e=b.beg,f=b.end,h=e.x,g=e.y,l=f.x,k=f.y,m=(l-h)*(l-h)+(k-g)*(k-g);if(JSM.IsZero(m))return e;c=((l-h)*(c-h)+(k-g)*(d-g))/m;if(JSM.IsLower(c,0))return e;if(JSM.IsGreater(c,1))return f;f=JSM.CoordSub2D(f,e).MultiplyScalar(c);return JSM.CoordAdd2D(e,f)}; -JSM.CoordSectorPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=b.beg,h=JSM.CoordSub(b.end,b.beg),g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return JSM.CoordIsEqual(f,a)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";c=((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q;f=JSM.CoordAdd(f,JSM.VectorMultiply(h,c));f=JSM.CoordDistance(a,f);return JSM.IsZero(f)?JSM.IsLower(c,0)||JSM.IsGreater(c,1)?"CoordOutsideOfSector":JSM.IsEqual(c,0)||JSM.IsEqual(c,1)?"CoordOnSectorEndCoord": +JSM.CoordSystemToAbsoluteCoords=function(a){return new JSM.CoordSystem(a.origo,JSM.CoordAdd(a.e1,a.origo),JSM.CoordAdd(a.e2,a.origo),JSM.CoordAdd(a.e3,a.origo))};JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c};JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a}; +JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d};JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return JSM.GetVectorsAngle(a,b)*c};JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c};JSM.Sector2D=function(a,b){this.beg=a;this.end=b}; +JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; +JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())}; +JSM.CoordSectorPosition2D=function(a,b){var c=a.x,d=a.y,e=b.beg.x,f=b.beg.y,g=b.end.x,h=b.end.y,l=b.GetLength();if(JSM.IsZero(l))return a.IsEqual(b.beg)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";l=((c-e)*(g-e)+(d-f)*(h-f))/(l*l);if(JSM.IsLower(l,0)||JSM.IsGreater(l,1))return"CoordOutsideOfSector";f+=l*(h-f);return!JSM.IsEqual(e+l*(g-e),c)||!JSM.IsEqual(f,d)?"CoordOutsideOfSector":JSM.IsEqual(l,0)||JSM.IsEqual(l,1)?"CoordOnSectorEndCoord":"CoordInsideOfSector"}; +JSM.ProjectCoordToSector2D=function(a,b){var c=a.x,d=a.y,e=b.beg,f=b.end,g=e.x,h=e.y,l=f.x,k=f.y,m=(l-g)*(l-g)+(k-h)*(k-h);if(JSM.IsZero(m))return e;c=((l-g)*(c-g)+(k-h)*(d-h))/m;if(JSM.IsLower(c,0))return e;if(JSM.IsGreater(c,1))return f;f=JSM.CoordSub2D(f,e);f.MultiplyScalar(c);return JSM.CoordAdd2D(e,f)}; +JSM.CoordSectorPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=b.beg,g=JSM.CoordSub(b.end,b.beg),h=f.x,l=f.y,k=f.z,m=f.x+g.x,n=f.y+g.y,p=f.z+g.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return f.IsEqual(a)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";c=((m-h)*(c-h)+(n-l)*(d-l)+(p-k)*(e-k))/q;g=g.Clone().MultiplyScalar(c);f=JSM.CoordAdd(f,g);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.IsLower(c,0)||JSM.IsGreater(c,1)?"CoordOutsideOfSector":JSM.IsEqual(c,0)||JSM.IsEqual(c,1)?"CoordOnSectorEndCoord": "CoordInsideOfSector":"CoordOutsideOfSector"}; -JSM.SectorSectorPosition2D=function(a,b,c){var d=a.beg.x,e=a.beg.y,f=a.end.x,h=a.end.y,g=b.beg.x,l=b.beg.y,k=b.end.x,m=b.end.y,n=(k-g)*(e-l)-(m-l)*(d-g),p=(f-d)*(e-l)-(h-e)*(d-g);if(JSM.IsZero(n)&&JSM.IsZero(p))return c=JSM.CoordSectorPosition2D(a.beg,b),d=JSM.CoordSectorPosition2D(a.end,b),e=JSM.CoordSectorPosition2D(b.beg,a),a=JSM.CoordSectorPosition2D(b.end,a),"CoordInsideOfSector"===c||("CoordInsideOfSector"===d||"CoordInsideOfSector"===e||"CoordInsideOfSector"===a)||"CoordOnSectorEndCoord"=== -c&&"CoordOnSectorEndCoord"===d&&"CoordOnSectorEndCoord"===e&&"CoordOnSectorEndCoord"===a?"SectorsIntersectsCoincident":"CoordOnSectorEndCoord"===c||"CoordOnSectorEndCoord"===d||"CoordOnSectorEndCoord"===e||"CoordOnSectorEndCoord"===a?"SectorsIntersectsEndPoint":"SectorsDontIntersects";a=(m-l)*(f-d)-(k-g)*(h-e);if(JSM.IsZero(a))return"SectorsDontIntersects";n/=a;p/=a;if(JSM.IsLower(n,0)||JSM.IsGreater(n,1)||JSM.IsLower(p,0)||JSM.IsGreater(p,1))return"SectorsDontIntersects";void 0!==c&&(c.x=d+n*(f- -d),c.y=e+n*(h-e));return JSM.IsEqual(n,0)||JSM.IsEqual(n,1)||JSM.IsEqual(p,0)||JSM.IsEqual(p,1)?"SectorsIntersectsEndPoint":"SectorsIntersectsOnePoint"};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=JSM.CoordDistance(a.beg,a.end)/b,f=0,h;for(h=0;h<=b;h++)c.push(JSM.CoordOffset(a.beg,d,f)),f+=e};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; +JSM.SectorSectorPosition2D=function(a,b,c){var d=a.beg.x,e=a.beg.y,f=a.end.x,g=a.end.y,h=b.beg.x,l=b.beg.y,k=b.end.x,m=b.end.y,n=(k-h)*(e-l)-(m-l)*(d-h),p=(f-d)*(e-l)-(g-e)*(d-h);if(JSM.IsZero(n)&&JSM.IsZero(p))return c=JSM.CoordSectorPosition2D(a.beg,b),d=JSM.CoordSectorPosition2D(a.end,b),e=JSM.CoordSectorPosition2D(b.beg,a),a=JSM.CoordSectorPosition2D(b.end,a),"CoordInsideOfSector"===c||("CoordInsideOfSector"===d||"CoordInsideOfSector"===e||"CoordInsideOfSector"===a)||"CoordOnSectorEndCoord"=== +c&&"CoordOnSectorEndCoord"===d&&"CoordOnSectorEndCoord"===e&&"CoordOnSectorEndCoord"===a?"SectorsIntersectsCoincident":"CoordOnSectorEndCoord"===c||"CoordOnSectorEndCoord"===d||"CoordOnSectorEndCoord"===e||"CoordOnSectorEndCoord"===a?"SectorsIntersectsEndPoint":"SectorsDontIntersects";a=(m-l)*(f-d)-(k-h)*(g-e);if(JSM.IsZero(a))return"SectorsDontIntersects";n/=a;p/=a;if(JSM.IsLower(n,0)||JSM.IsGreater(n,1)||JSM.IsLower(p,0)||JSM.IsGreater(p,1))return"SectorsDontIntersects";void 0!==c&&(c.x=d+n*(f- +d),c.y=e+n*(g-e));return JSM.IsEqual(n,0)||JSM.IsEqual(n,1)||JSM.IsEqual(p,0)||JSM.IsEqual(p,1)?"SectorsIntersectsEndPoint":"SectorsIntersectsOnePoint"};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,g,h;for(g=0;g<=b;g++)h=a.beg.Clone().Offset(d,f),c.push(h),f+=e};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())}; JSM.CoordLinePosition2D=function(a,b){var c=b.start,d=b.direction,c=d.x*(a.y-c.y)-d.y*(a.x-c.x);return JSM.IsPositive(c)?"CoordAtLineLeft":JSM.IsNegative(c)?"CoordAtLineRight":"CoordOnLine"}; -JSM.CoordLinePosition=function(a,b,c){var d=a.x,e=a.y,f=a.z,h=b.start;b=b.direction;var g=h.x,l=h.y,k=h.z,m=h.x+b.x,n=h.y+b.y,p=h.z+b.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==c&&c.Set(h.x,h.y,h.z),JSM.CoordIsEqual(h,a)?"CoordOnLine":"CoordOutsideOfLine";d=JSM.CoordAdd(h,JSM.VectorMultiply(b,((m-g)*(d-g)+(n-l)*(e-l)+(p-k)*(f-k))/q));void 0!==c&&c.Set(d.x,d.y,d.z);a=JSM.CoordDistance(a,d);return JSM.IsZero(a)?"CoordOnLine":"CoordOutsideOfLine"}; -JSM.ProjectCoordToLine=function(a,b){var c=new JSM.Coord(0,0,0),d=a.x,e=a.y,f=a.z,h=b.start,g=b.direction,l=h.x,k=h.y,m=h.z,n=h.x+g.x,p=h.y+g.y,q=h.z+g.z,t=(n-l)*(n-l)+(p-k)*(p-k)+(q-m)*(q-m);if(JSM.IsZero(t))return c.Set(h.x,h.y,h.z),c;d=JSM.CoordAdd(h,JSM.VectorMultiply(g,((n-l)*(d-l)+(p-k)*(e-k)+(q-m)*(f-m))/t));c.Set(d.x,d.y,d.z);return c}; -JSM.LineLineClosestPoint=function(a,b,c,d){function e(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var f=JSM.VectorNormalize(a.direction),h=a.start,f=JSM.CoordAdd(h,f);a=JSM.VectorNormalize(b.direction);b=b.start;var g=JSM.CoordAdd(b,a),l=[h,f,b,g],k=e(l,1,0,1,0),m=e(l,0,2,1,0),g=e(l,0,2,3,2),n=e(l,3,2,1,0),l=e(l,3,2,3,2),k=k*l-n*n;if(JSM.IsEqual(k,0))return!1;m=(g*n-m*l)/k;g=(g+m*n)/l;void 0!==c&&(f=JSM.VectorNormalize(JSM.CoordSub(f, -h)),h=JSM.CoordAdd(h,JSM.VectorMultiply(f,m)),c.Set(h.x,h.y,h.z));void 0!==d&&(c=JSM.CoordAdd(b,JSM.VectorMultiply(a,g)),d.Set(c.x,c.y,c.z));return!0};JSM.LineLinePosition=function(a,b,c){var d=new JSM.Coord(0,0,0),e=new JSM.Coord(0,0,0);return!JSM.LineLineClosestPoint(a,b,d,e)?"LinesIntersectsCoincident":JSM.CoordIsEqual(d,e)?(void 0!==c&&c.Set(d.x,d.y,d.z),"LinesIntersectsOnePoint"):"LinesDontIntersects"};JSM.Box2D=function(a,b){this.min=a;this.max=b}; -JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)}; +JSM.CoordLinePosition=function(a,b,c){var d=a.x,e=a.y,f=a.z,g=b.start;b=b.direction;var h=g.x,l=g.y,k=g.z,m=g.x+b.x,n=g.y+b.y,p=g.z+b.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==c&&c.Set(g.x,g.y,g.z),g.IsEqual(a)?"CoordOnLine":"CoordOutsideOfLine";d=b.Clone().MultiplyScalar(((m-h)*(d-h)+(n-l)*(e-l)+(p-k)*(f-k))/q);g=JSM.CoordAdd(g,d);void 0!==c&&c.Set(g.x,g.y,g.z);a=a.DistanceTo(g);return JSM.IsZero(a)?"CoordOnLine":"CoordOutsideOfLine"}; +JSM.ProjectCoordToLine=function(a,b){var c=new JSM.Coord(0,0,0),d=a.x,e=a.y,f=a.z,g=b.start,h=b.direction,l=g.x,k=g.y,m=g.z,n=g.x+h.x,p=g.y+h.y,q=g.z+h.z,t=(n-l)*(n-l)+(p-k)*(p-k)+(q-m)*(q-m);if(JSM.IsZero(t))return c.Set(g.x,g.y,g.z),c;d=h.Clone().MultiplyScalar(((n-l)*(d-l)+(p-k)*(e-k)+(q-m)*(f-m))/t);g=JSM.CoordAdd(g,d);c.Set(g.x,g.y,g.z);return c}; +JSM.LineLineClosestPoint=function(a,b,c,d){function e(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var f=a.direction.Clone().Normalize(),g=a.start,h=JSM.CoordAdd(g,f);a=b.direction.Clone().Normalize();b=b.start;var l=JSM.CoordAdd(b,a),k=[g,h,b,l],m=e(k,1,0,1,0),n=e(k,0,2,1,0),h=e(k,0,2,3,2),l=e(k,3,2,1,0),k=e(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==c&&(f.MultiplyScalar(n),f=JSM.CoordAdd(g, +f),c.Set(f.x,f.y,f.z));void 0!==d&&(a.MultiplyScalar(h),c=JSM.CoordAdd(b,a),d.Set(c.x,c.y,c.z));return!0};JSM.LineLinePosition=function(a,b,c){var d=new JSM.Coord(0,0,0),e=new JSM.Coord(0,0,0);return!JSM.LineLineClosestPoint(a,b,d,e)?"LinesIntersectsCoincident":d.IsEqual(e)?(void 0!==c&&c.Set(d.x,d.y,d.z),"LinesIntersectsOnePoint"):"LinesDontIntersects"};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b}; +JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)}; JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())};JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)}; JSM.IsCoordInBox=function(a,b){return JSM.IsLower(a.x,b.min.x)||JSM.IsLower(a.y,b.min.y)||JSM.IsLower(a.z,b.min.z)||JSM.IsGreater(a.x,b.max.x)||JSM.IsGreater(a.y,b.max.y)||JSM.IsGreater(a.z,b.max.z)?!1:!0};JSM.Sphere=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.Set=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.GetCenter=function(){return this.center};JSM.Sphere.prototype.GetRadius=function(){return this.radius}; JSM.Sphere.prototype.Clone=function(){return new JSM.Sphere(this.center.Clone(),this.radius)};JSM.Transformation=function(){this.matrix=JSM.MatrixIdentity()};JSM.Transformation.prototype.GetMatrix=function(){return this.matrix};JSM.Transformation.prototype.SetMatrix=function(a){this.matrix=a};JSM.Transformation.prototype.Append=function(a){this.matrix=JSM.MatrixMultiply(this.matrix,a.matrix)};JSM.Transformation.prototype.Apply=function(a){return JSM.ApplyTransformation(this.matrix,a)}; -JSM.Transformation.prototype.Clone=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixClone(this.matrix);return a};JSM.IdentityTransformation=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixIdentity();return a};JSM.TranslationTransformation=function(a){var b=new JSM.Transformation;b.matrix=JSM.MatrixTranslation(a.x,a.y,a.z);return b};JSM.OffsetTransformation=function(a,b){var c=JSM.VectorNormalize(a),c=JSM.VectorMultiply(c,b);return JSM.TranslationTransformation(c)}; +JSM.Transformation.prototype.Clone=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixClone(this.matrix);return a};JSM.IdentityTransformation=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixIdentity();return a};JSM.TranslationTransformation=function(a){var b=new JSM.Transformation;b.matrix=JSM.MatrixTranslation(a.x,a.y,a.z);return b};JSM.OffsetTransformation=function(a,b){var c=a.Clone().Normalize().Clone().MultiplyScalar(b);return JSM.TranslationTransformation(c)}; JSM.RotationTransformation=function(a,b,c){var d=new JSM.Transformation;d.matrix=JSM.MatrixRotation(a,b,c);return d};JSM.RotationXTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationX(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationXTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationY(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationYTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)}; -JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)};JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=JSM.VectorNormalize(b),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; +JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)};JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; JSM.CoordPlanePosition=function(a,b){var c=b.a*a.x+b.b*a.y+b.c*a.z+b.d;return JSM.IsPositive(c)?"CoordInFrontOfPlane":JSM.IsNegative(c)?"CoordAtBackOfPlane":"CoordOnPlane"}; -JSM.LinePlanePosition=function(a,b,c){var d=JSM.VectorNormalize(a.direction),e=a.start.x,f=a.start.y,h=a.start.z,g=b.a,l=b.b,k=b.c;b=b.d;var m=g*(e-(a.start.x+d.x))+l*(f-(a.start.y+d.y))+k*(h-(a.start.z+d.z));if(JSM.IsZero(m))return"LineParallelToPlane";void 0!==c&&(a=JSM.CoordAdd(a.start,JSM.VectorMultiply(d,(g*e+l*f+k*h+b)/m)),c.Set(a.x,a.y,a.z));return"LineIntersectsPlane"}; -JSM.LinePlaneIntersection=function(a,b){var c=JSM.VectorNormalize(a.direction),d=a.start.x,e=a.start.y,f=a.start.z,h=a.start.x+c.x,g=a.start.y+c.y,l=a.start.z+c.z,k=b.a,m=b.b,n=b.c,p=b.d,q=new JSM.Coord(0,0,0),h=k*(d-h)+m*(e-g)+n*(f-l);return JSM.IsZero(h)?q:q=JSM.CoordAdd(a.start,JSM.VectorMultiply(c,(k*d+m*e+n*f+p)/h))};JSM.CoordPlaneSignedDistance=function(a,b){var c=b.a,d=b.b,e=b.c;return(c*a.x+d*a.y+e*a.z+b.d)/Math.sqrt(c*c+d*d+e*e)}; -JSM.CoordPlaneDistance=function(a,b){return Math.abs(JSM.CoordPlaneSignedDistance(a,b))};JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=JSM.VectorNormalize(b);b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d=JSM.CoordAdd(a,JSM.VectorMultiply(d,(h*b+g*e+l*f+c)/k));a=JSM.CoordDistance(a,d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a}; -JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))};JSM.ProjectCoordToPlane=function(a,b){var c=a.x,d=a.y,e=a.z,f=b.a,h=b.b,g=b.c,l=b.d,k=JSM.CoordPlaneDistance(a,b);JSM.IsGreater(f*c+h*d+g*e+l,0)&&(k=-k);c=JSM.VectorNormalize(new JSM.Coord(f,h,g));return JSM.CoordOffset(a,c,k)}; -JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; -JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;q=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&&(g=c,h=b);k= -[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var h=[],g,l,k;for(g=0;g=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& +(g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var g=[],h,l,k;for(h=0;hb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;c=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; +JSM.Octree.prototype.FindCoordInNode=function(a,b){var c,d;for(c=0;c=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, b.children[7]):null};JSM.Octree.prototype.SplitNode=function(a){var b=this,c=JSM.CreateOctreeChildNodes(a.box,function(c){return b.CreateNewNode(a,c)});if(null===c)return!1;a.children=c;c=a.coords;a.coords=[];var d,e;for(d=0;db.VertexCount())return!1;var d;if(null===a.polygon){d=JSM.CalculateNormal(b.vertices);var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0b.length;)b="0"+b;a=parseInt(b.substr(0,2),16);var c=parseInt(b.substr(2,2),16),b=parseInt(b.substr(4,2),16);return[a,c,b]};JSM.HexColorToNormalizedRGBComponents=function(a){a=JSM.HexColorToRGBComponents(a);return[a[0]/255,a[1]/255,a[2]/255]};JSM.HexColorToRGBColor=function(a){return parseInt("0x"+a,16)}; @@ -139,133 +138,130 @@ JSM.Material=function(a){JSM.CopyObjectProperties(a,this,!0);JSM.CopyObjectPrope JSM.Materials.prototype.AddMaterial=function(a){this.materials.push(a);return this.materials.length-1};JSM.Materials.prototype.GetDefaultMaterial=function(){return this.defaultMaterial};JSM.Materials.prototype.Count=function(){return this.materials.length};JSM.VertInfo=function(){this.edges=[];this.pgons=[]};JSM.EdgeInfo=function(){this.pgon2=this.pgon1=this.vert2=this.vert1=-1};JSM.PolyEdgeInfo=function(){this.index=-1;this.reverse=!1};JSM.PgonInfo=function(){this.verts=[];this.pedges=[]}; JSM.AdjacencyInfo=function(){this.verts=[];this.edges=[];this.pgons=[]};JSM.GetPolyEdgeStartVertex=function(a,b){return a.reverse?b.edges[a.index].vert2:b.edges[a.index].vert1};JSM.GetPolyEdgeEndVertex=function(a,b){return a.reverse?b.edges[a.index].vert1:b.edges[a.index].vert2};JSM.GetAnotherPgonOfEdge=function(a,b){return-1!=a.pgon1&&a.pgon1!=b?a.pgon1:-1!=a.pgon2&&a.pgon2!=b?a.pgon2:-1}; JSM.CalculateBodyVertexToPolygon=function(a){var b=[],c,d;for(c=0;ck;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== -b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=JSM.VectorNormalize(c.e3);if(JSM.VectorsAreCollinear(e,b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];b=new JSM.Line(c.origo,e);var f=JSM.ProjectCoordToLine(a,b);b=JSM.CoordSignedDistance(c.origo,f,e);var h=JSM.VectorNormalize(c.e1);a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=JSM.VectorLength(c.e1);d.x=e*c;d.y=b;return[d,e]}; -JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fk;k++)0===k?m=e:1===k?m=f:2===k&&(m=g),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(h=k,l=n);if(-1===h)return d;b=null;0===h?b=new JSM.CoordSystem(c.origo,f,g,new JSM.Coord(0,0,0)):1===h?b=new JSM.CoordSystem(c.origo,e,g,new JSM.Coord(0,0,0)):2===h&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(JSM.VectorsAreCollinear(e,b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];b=new JSM.Line(c.origo,e);var f=JSM.ProjectCoordToLine(a,b);b=JSM.CoordSignedDistance(c.origo,f,e);var g=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,g,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; +JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,g;for(f=0;fe;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),v.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(v)}}var f=new JSM.Body;(function(){var d; -for(d=0;de;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),u.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(u)}}var f=new JSM.Body;(function(){var d; +for(d=0;dw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, -p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var g,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),g=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, +p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,g,n,p);else if(g=!0,void 0!==c&&c&&(g=!1),q=JSM.CalculateBodyPolygonNormal(a,b),g){g=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e], -c=b.AddNormal(c.x,c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=g(b,p.v0,c,d,f),p.n1=g(b,p.v1,c,d,f),p.n2=g(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= -new JSM.Polygon;for(e=0;eh))if(3==h)f=g.GetVertexIndex(0),h=g.GetVertexIndex(1),k=g.GetVertexIndex(2),b(c,g,f,h,k);else{l= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; -var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=JSM.CoordDistance(d,f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; +JSM.MergeJsonDataMeshes=function(a){function b(a,b,c){function d(a,b,c){var h=b.material,l=c[h];void 0===l&&(a.triangles.push({material:h,parameters:[]}),l=a.triangles.length-1,c[h]=l);a=a.triangles[l].parameters;for(c=0;ck;k++)JSM.IsLower(f[k],b[k])?(g[k]=-1,h[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(g[k]=1,h[k]=c[k],l=!1):g[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==g[k]&&!JSM.IsZero(e[k])?l[k]=(h[k]-f[k])/e[k]:l[k]=-1;g=0;for(k=1;3>k;k++)JSM.IsLower(l[g],l[k])&&(g=k);if(JSM.IsNegative(l[g]))return null; +var m=[0,0,0];for(k=0;3>k;k++)if(g!=k){if(m[k]=f[k]+l[g]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=h[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -273,11 +269,11 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,t,s,v,u,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;v=41728;u=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +JSM.Read3dsFile=function(a,b){var c,d,e,f,g,h,l,k,m,n,p,q,t,s,u,v,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;g=40992;h=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;u=41728;v=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ 255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==h?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ +", "+d+")",3),n.ambient=V(a,b,p)):b==g?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==h?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= W(a,b,p)):b==s?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,l;for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],s;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); -var b,c;for(b=0;bn.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=h(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=h(a,"mtllib"),n=g(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fc;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,g,h,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; -JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=JSM.VectorNormalize(new JSM.Vector(d[0],d[1],d[2]));d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]); -c=e.AddVertex(c[0],c[1],c[2]);d=JSM.VectorNormalize(new JSM.Vector(d[0],d[1],d[2]));d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}});c.Finalize();return JSM.ConvertTriangleModelToJsonData(c)};JSM.ImportFileList=function(){this.isFile=this.descriptors=this.originalList=null}; +JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= +e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}});c.Finalize();return JSM.ConvertTriangleModelToJsonData(c)};JSM.ImportFileList=function(){this.isFile=this.descriptors=this.originalList=null}; JSM.ImportFileList.prototype.InitFromFiles=function(a){this.originalList=a;this.descriptors=[];var b,c;for(b=0;br;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rr;r++)v[r].z=n-c;r=JSM.GeneratePrism(v,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position,l=JSM.CoordAdd(l,JSM.VectorMultiply(k,0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg;g++)k=0===g?h.pgon1:h.pgon2,-1===k&&(k=0===g?h.pgon2:h.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],g,h,l,k;for(l=0;lthis.cameraFarDistanceLimit)return 0;c*=0.1;a||(c*=-1);this.camera.eye=JSM.CoordOffset(this.camera.eye,b,c)};JSM.Navigation.prototype.DrawCallback=function(){void 0!==this.drawCallback&&null!==this.drawCallback&&this.drawCallback()}; -JSM.Navigation.prototype.ResizeCallback=function(){void 0!==this.resizeCallback&&null!==this.resizeCallback&&this.resizeCallback()};JSM.Navigation.prototype.OnMouseDown=function(a){a.preventDefault();this.mouse.Down(a,this.canvas)}; -JSM.Navigation.prototype.OnMouseMove=function(a){a.preventDefault();this.mouse.Move(a,this.canvas);this.mouse.down&&(a=0,1==this.mouse.button?this.cameraEnableOrbit&&(a=0.5,this.Orbit(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()):3==this.mouse.button&&this.cameraEnablePan&&(a=0.001*JSM.CoordDistance(this.camera.eye,this.camera.center),this.Pan(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()))}; +JSM.Navigation.prototype.FitInWindow=function(a,b){var c=JSM.CoordSub(this.camera.center,a);this.camera.center=a;this.camera.eye=JSM.CoordSub(this.camera.eye,c);var c=JSM.CoordSub(this.camera.eye,this.camera.center).Normalize(),d=this.camera.fieldOfView/2;this.canvas.widththis.cameraFarDistanceLimit)return 0;c*=0.1;a||(c*=-1);this.camera.eye.Offset(b,c)};JSM.Navigation.prototype.DrawCallback=function(){void 0!==this.drawCallback&&null!==this.drawCallback&&this.drawCallback()};JSM.Navigation.prototype.ResizeCallback=function(){void 0!==this.resizeCallback&&null!==this.resizeCallback&&this.resizeCallback()}; +JSM.Navigation.prototype.OnMouseDown=function(a){a.preventDefault();this.mouse.Down(a,this.canvas)};JSM.Navigation.prototype.OnMouseMove=function(a){a.preventDefault();this.mouse.Move(a,this.canvas);this.mouse.down&&(a=0,1==this.mouse.button?this.cameraEnableOrbit&&(a=0.5,this.Orbit(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()):3==this.mouse.button&&this.cameraEnablePan&&(a=0.001*this.camera.eye.DistanceTo(this.camera.center),this.Pan(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()))}; JSM.Navigation.prototype.OnMouseUp=function(a){a.preventDefault();this.mouse.Up(a,this.canvas)};JSM.Navigation.prototype.OnMouseOut=function(a){a.preventDefault();this.mouse.Out(a,this.canvas)};JSM.Navigation.prototype.OnMouseWheel=function(a){a.preventDefault();if(this.cameraEnableZoom){null===a&&(a=window.event);var b=0;a.detail?b=-a.detail:a.wheelDelta&&(b=a.wheelDelta/40);this.Zoom(0b.position.z?-1:a.position.z + - - diff --git a/sandbox/bezier.html b/sandbox/bezier.html index 21a65825..0830470b 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index 1a562b71..9972193c 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/bspline.html b/sandbox/bspline.html index 062023c8..dc070d1a 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/charts.html b/sandbox/charts.html index ca64685d..2a184d4a 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/contourbody.html b/sandbox/contourbody.html deleted file mode 100644 index 92ed8a21..00000000 --- a/sandbox/contourbody.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example - - - - - - - - - - diff --git a/sandbox/contourbody.js b/sandbox/contourbody.js deleted file mode 100644 index 76208bb7..00000000 --- a/sandbox/contourbody.js +++ /dev/null @@ -1,152 +0,0 @@ -function AddBodyVertex (body, coord) -{ - var index = body.VertexCount (); - - var i; - for (i = 0; i < body.VertexCount (); i++) { - if (JSM.CoordIsEqual (body.GetVertex (i).position, coord)) { - return i; - } - } - - body.AddVertex (new JSM.BodyVertex (coord)); - return index; -}; - -function CalculateEdgeAngle (body, al) -{ - var edge = al.edges[0]; - var pgon1Normal = JSM.CalculateBodyPolygonNormal (body, edge.pgon1); - var pgon2Normal = JSM.CalculateBodyPolygonNormal (body, edge.pgon2); - var edgeAngle = Math.PI - JSM.GetVectorsAngle (pgon1Normal, pgon2Normal); - return edgeAngle; -} - -function CalculateEdgeLine (body, al, index, edgeAngle, width) -{ - var offset = width / Math.cos (edgeAngle / 2.0); - - var edge = al.edges[index]; - var edgeVert1 = body.GetVertexPosition (edge.vert1); - var edgeVert2 = body.GetVertexPosition (edge.vert2); - var edgeMidCoord = JSM.MidCoord (edgeVert1, edgeVert2); - var edgeOffset = JSM.VectorMultiply (edgeMidCoord, -1); - var edgeOffsetedVert1 = JSM.CoordOffset (edgeVert1, edgeOffset, offset); - var edgeOffsetedVert2 = JSM.CoordOffset (edgeVert2, edgeOffset, offset); - - return new JSM.Line (edgeOffsetedVert1, JSM.VectorNormalize (JSM.CoordSub (edgeOffsetedVert2, edgeOffsetedVert1))); -} - -function CalculateVertexOffsets (body, width) -{ - var al = JSM.CalculateAdjacencyInfo (body); - var edgeAngle = CalculateEdgeAngle (body, al); - - var vert = al.verts[0]; - var vertPosition = body.GetVertexPosition (0); - var edge1Line = CalculateEdgeLine (body, al, vert.edges[0], edgeAngle, width); - var edge2Line = CalculateEdgeLine (body, al, vert.edges[1], edgeAngle, width); - - var vertexOffset = 0.0; - var intersection = new JSM.Coord (0.0, 0.0, 0.0); - if (JSM.LineLinePosition (edge1Line, edge2Line, intersection) == 'LinesIntersectsOnePoint') { - vertexOffset = JSM.CoordDistance (vertPosition, intersection); - } - - return vertexOffset; -} - -function ZOffsetPolygon (polygon, direction, distance) -{ - var result = []; - - var i; - for (i = 0; i < polygon.length; i++) { - result.push (JSM.CoordOffset (polygon[i], direction, distance)); - } - - return result; -}; - -function CalculateOffsetedPolygon (body, polygonIndex, polygonOffset) -{ - var polygon = body.GetPolygon (polygonIndex); - var count = polygon.VertexIndexCount (); - var normal = JSM.CalculateBodyPolygonNormal (body, polygonIndex); - normal = JSM.VectorMultiply (normal, -1); - - var basePolygon = []; - var i; - for (i = 0; i < count; i++) { - basePolygon.push (body.GetVertexPosition (polygon.GetVertexIndex (i))); - } - - var polygon = new JSM.Polygon (); - polygon.vertices = basePolygon; - var offsetedPolygon = JSM.OffsetPolygonContour (polygon, polygonOffset); - return offsetedPolygon.vertices; -}; - -function CalculatePolygonOffsets (body, polygonIndex, width, edgeAngle, desiredAngle) -{ - var offsets = [0.0, 0.0]; - var diffAngle = (edgeAngle - desiredAngle) / 2.0; - offsets[0] = width * Math.cos (diffAngle); - offsets[1] = width * Math.sin (diffAngle); - return offsets; -}; - -function GenerateContourSolid (name, width) -{ - var body = JSM.GenerateSolidWithRadius (name, 1.0); - var originalVertexCount = body.VertexCount (); - - var result = new JSM.Body (); - var i, j; - for (i = 0; i < body.VertexCount (); i++) { - result.AddVertex (body.GetVertex (i).Clone ()); - } - - var vertexCoord, offsetDir, newVertexCoord; - var vertexOffset = CalculateVertexOffsets (body, width); - for (i = 0; i < body.VertexCount (); i++) { - vertexCoord = body.GetVertexPosition (i).Clone (); - offsetDir = JSM.VectorMultiply (vertexCoord, -1); - newVertexCoord = JSM.CoordOffset (vertexCoord, offsetDir, vertexOffset); - result.AddVertex (new JSM.BodyVertex (newVertexCoord)); - } - - var polygon, count, innerPolygon; - var innerVertices, offsetedInnerVertices, index, curr, next, top, ntop; - for (i = 0; i < body.PolygonCount (); i++) { - polygon = body.GetPolygon (i); - count = polygon.VertexIndexCount (); - - innerPolygon = CalculateOffsetedPolygon (body, i, width); - innerVertices = []; - for (j = 0; j < count; j++) { - innerVertices.push (result.VertexCount ()); - result.AddVertex (new JSM.BodyVertex (innerPolygon[j])); - } - - for (j = 0; j < count; j++) { - curr = polygon.GetVertexIndex (j); - next = polygon.GetVertexIndex (j < count - 1 ? j + 1 : 0); - top = innerVertices[j]; - ntop = innerVertices[j < count - 1 ? j + 1 : 0]; - result.AddPolygon (new JSM.BodyPolygon ([curr, next, ntop, top])); - } - - for (j = 0; j < count; j++) { - curr = originalVertexCount + polygon.GetVertexIndex (j); - next = originalVertexCount + polygon.GetVertexIndex (j < count - 1 ? j + 1 : 0); - top = innerVertices[j]; - ntop = innerVertices[j < count - 1 ? j + 1 : 0]; - result.AddPolygon (new JSM.BodyPolygon ([curr, top, ntop, next])); - } - } - if (!JSM.IsSolidBody (result)) { - alert ('not solid'); - } - return result; -}; diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index eb98c30b..e4f50a2f 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 9bc60c07..c6c75502 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/csg.html b/sandbox/csg.html index 35b84840..fcf1b151 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/csg2.html b/sandbox/csg2.html index c7c24106..2f4392f4 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index b1428748..caaccece 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/docimages.html b/sandbox/docimages.html index 2e0b9aea..cadcba10 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index 045a2b7b..6974d3fc 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index 765aa9f8..9c2d04c0 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index f27e4664..d708edbd 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 17d73d37..0ceb7e4b 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/importer.html b/sandbox/importer.html index 1c4207fa..2d68a9a9 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index e1129f24..69127363 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index 12c2f843..967695f4 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/minimal.html b/sandbox/minimal.html index e0491193..f401c559 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index c08f0917..ceb784e0 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/octree.html b/sandbox/octree.html index 2788caae..67c91267 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 83462cf6..77fc2aca 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index 8e53cd08..ae82ed53 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/print.html b/sandbox/print.html index 2c659dea..3b7395ce 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index 80227a0c..82debe0a 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/randommat.html b/sandbox/randommat.html index 5b1d9871..b9e6c017 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/renderer.html b/sandbox/renderer.html index 43f11231..03f3eda5 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/revolved.html b/sandbox/revolved.html index 5056db80..d6fb6517 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index 5207e33c..ac39b262 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index cb4ac29b..380f2b00 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/snippets/spherical.txt b/sandbox/snippets/spherical.txt index 91623e90..24682891 100644 --- a/sandbox/snippets/spherical.txt +++ b/sandbox/snippets/spherical.txt @@ -12,7 +12,7 @@ JSM.CalculateSphericalTextureCoord = function (coord, normal, system) { var result = new JSM.Coord2D (0.0, 0.0); - var e3Direction = JSM.VectorNormalize (system.e3); + var e3Direction = system.e3.Clone ().Normalize (); if (JSM.VectorsAreCollinear (e3Direction, normal)) { result = JSM.CalculateCubicTextureCoord (coord, normal, system); return [result, 0.0]; @@ -20,11 +20,11 @@ JSM.CalculateSphericalTextureCoord = function (coord, normal, system) var baseLine = new JSM.Line (system.origo, e3Direction); var projectedCoord = JSM.ProjectCoordToLine (coord, baseLine); - var radius = JSM.VectorLength (system.e1); + var radius = system.e1.Length (); - if (!JSM.CoordIsEqual (coord, projectedCoord)) { + if (!coord.IsEqual (projectedCoord)) { var coordDirection = JSM.CoordSub (coord, projectedCoord); - var e1Direction = JSM.VectorNormalize (system.e1); + var e1Direction = system.e1.Clone ().Normalize (); var longitudeAngle = JSM.GetVectorsFullAngle (coordDirection, e1Direction, e3Direction); result.x = longitudeAngle * radius; } else { @@ -32,7 +32,7 @@ JSM.CalculateSphericalTextureCoord = function (coord, normal, system) } var projectedDistance = JSM.CoordSignedDistance (system.origo, projectedCoord, e3Direction); - var coordDistance = JSM.CoordDistance (system.origo, coord); + var coordDistance = system.origo.DistanceTo (coord); var latitudeAngle = JSM.ArcCos (projectedDistance / coordDistance); result.y = -latitudeAngle * radius; diff --git a/sandbox/solids.html b/sandbox/solids.html index 10d96d1e..efed404f 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/specular.html b/sandbox/specular.html index 50476385..6ec42acf 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index b8ed3946..d406afd3 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index f57eacfb..ca8def34 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 2cf59e29..acc2cd13 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/tasks.html b/sandbox/tasks.html index e4a7234a..e3f91b8d 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/texture.html b/sandbox/texture.html index 387ee9e1..9ed5f8e5 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index c4362eca..6a52dff5 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -12,14 +12,13 @@ + - - diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index ba9025af..258bfe5d 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/triangulatewithhole.html b/sandbox/triangulatewithhole.html index 07a5933a..778ab729 100644 --- a/sandbox/triangulatewithhole.html +++ b/sandbox/triangulatewithhole.html @@ -14,14 +14,13 @@ + - - diff --git a/sandbox/tube.html b/sandbox/tube.html index 9434d7fe..b834e531 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -13,14 +13,13 @@ + - - @@ -116,10 +115,10 @@ var origo = new JSM.Coord (0.0, 0.0, 0.0); var i, j, circle, currOrigo; for (i = 0; i < 25; i++) { - currOrigo = JSM.CoordRotate (origo, new JSM.Coord (1.0, 0.0, 0.0), -i * 10 * JSM.DegRad, new JSM.Coord (0.0, 8.0, 0.0)); + currOrigo = origo.Clone ().Rotate (new JSM.Coord (1.0, 0.0, 0.0), -i * 10 * JSM.DegRad, new JSM.Coord (0.0, 8.0, 0.0)); circle = JSM.GenerateCirclePoints (i * 0.2, 30, currOrigo); for (j = 0; j < circle.length; j++) { - circle[j] = JSM.CoordRotate (circle[j], new JSM.Coord (1.0, 0.0, 0.0), -i * 10 * JSM.DegRad, currOrigo); + circle[j].Rotate (new JSM.Coord (1.0, 0.0, 0.0), -i * 10 * JSM.DegRad, currOrigo); } polygons.push (circle); } diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index 1f19757a..fea19720 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -13,14 +13,13 @@ + - - diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 48e3cc61..8af1721e 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -13,14 +13,13 @@ + - - diff --git a/src/core/jsm.js b/src/core/jsm.js index f1b7c176..246cefb9 100644 --- a/src/core/jsm.js +++ b/src/core/jsm.js @@ -3,201 +3,6 @@ var JSM = function () { this.subVersion = 37; }; -JSM.Eps = 0.00000001; -JSM.Inf = 9999999999; -JSM.RadDeg = 57.29577951308232; -JSM.DegRad = 0.017453292519943; - -/** -* Function: IsZero -* Description: Determines if the given value is near zero. Uses epsilon for comparison. -* Parameters: -* a {number} the value -* Returns: -* {boolean} the result -*/ -JSM.IsZero = function (a) -{ - return Math.abs (a) < JSM.Eps; -}; - -/** -* Function: IsPositive -* Description: Determines if the given value is positive. Uses epsilon for comparison. -* Parameters: -* a {number} the value -* Returns: -* {boolean} the result -*/ -JSM.IsPositive = function (a) -{ - return a > JSM.Eps; -}; - -/** -* Function: IsNegative -* Description: Determines if the given value is negative. Uses epsilon for comparison. -* Parameters: -* a {number} the value -* Returns: -* {boolean} the result -*/ -JSM.IsNegative = function (a) -{ - return a < -JSM.Eps; -}; - -/** -* Function: IsLower -* Description: Determines if a value is lower than an other. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {boolean} the result -*/ -JSM.IsLower = function (a, b) -{ - return b - a > JSM.Eps; -}; - -/** -* Function: IsGreater -* Description: Determines if a value is greater than an other. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {boolean} the result -*/ -JSM.IsGreater = function (a, b) -{ - return a - b > JSM.Eps; -}; - -/** -* Function: IsEqual -* Description: Determines if two values are equal. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {boolean} the result -*/ -JSM.IsEqual = function (a, b) -{ - return Math.abs (b - a) < JSM.Eps; -}; - -/** -* Function: IsEqualWithEps -* Description: Determines if two values are equal. Uses the given epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* eps {number} epsilon value -* Returns: -* {boolean} the result -*/ -JSM.IsEqualWithEps = function (a, b, eps) -{ - return Math.abs (b - a) < eps; -}; - -/** -* Function: IsLowerOrEqual -* Description: Determines if a value is lower or equal to an other. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {boolean} the result -*/ -JSM.IsLowerOrEqual = function (a, b) -{ - return JSM.IsLower (a, b) || JSM.IsEqual (a, b); -}; - -/** -* Function: IsGreaterOrEqual -* Description: Determines if a value is greater or equal to an other. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {boolean} the result -*/ -JSM.IsGreaterOrEqual = function (a, b) -{ - return JSM.IsGreater (a, b) || JSM.IsEqual (a, b); -}; - -/** -* Function: Minimum -* Description: Returns the minimum of two values. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {number} the result -*/ -JSM.Minimum = function (a, b) -{ - return JSM.IsLower (a, b) ? a : b; -}; - -/** -* Function: Maximum -* Description: Returns the maximum of two values. Uses epsilon for comparison. -* Parameters: -* a {number} first value -* b {number} second value -* Returns: -* {number} the result -*/ -JSM.Maximum = function (a, b) -{ - return JSM.IsGreater (a, b) ? a : b; -}; - -/** -* Function: ArcSin -* Description: Calculates the arcus sinus value. -* Parameters: -* value {number} the value -* Returns: -* {number} the result -*/ -JSM.ArcSin = function (value) -{ - if (JSM.IsGreaterOrEqual (value, 1.0)) { - return Math.PI / 2.0; - } else if (JSM.IsLowerOrEqual (value, -1.0)) { - return - Math.PI / 2.0; - } - - return Math.asin (value); -}; - -/** -* Function: ArcCos -* Description: Calculates the arcus cosinus value. -* Parameters: -* value {number} the value -* Returns: -* {number} the result -*/ -JSM.ArcCos = function (value) -{ - if (JSM.IsGreaterOrEqual (value, 1.0)) { - return 0.0; - } else if (JSM.IsLowerOrEqual (value, -1.0)) { - return Math.PI; - } - - return Math.acos (value); -}; - /** * Function: RandomNumber * Description: Generates a random number between two numbers. diff --git a/src/extras/curves.js b/src/extras/curves.js index cbec80fa..721c2f8a 100644 --- a/src/extras/curves.js +++ b/src/extras/curves.js @@ -240,7 +240,7 @@ JSM.GenerateBezierSurface = function (surfaceControlPoints, xSegmentation, ySegm tmp1 = new JSM.Coord (0.0, 0.0, 0.0); for (j = 0; j <= m; j++) { scalar = JSM.BernsteinPolynomial (i, n, u) * JSM.BernsteinPolynomial (j, m, v); - tmp2 = JSM.VectorMultiply (surfaceControlPoints.GetControlPoint (i, j), scalar); + tmp2 = surfaceControlPoints.GetControlPoint (i, j).Clone ().MultiplyScalar (scalar); tmp1 = JSM.CoordAdd (tmp1, tmp2); } result = JSM.CoordAdd (result, tmp1); diff --git a/src/extras/drawing.js b/src/extras/drawing.js index 443d717d..9850f86f 100644 --- a/src/extras/drawing.js +++ b/src/extras/drawing.js @@ -294,7 +294,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, for (i = 0; i < body.PolygonCount (); i++) { polygon = body.GetPolygon (i); projected = GetProjectedPolygonFromBody (polygon); - if (JSM.PolygonOrientation2D (projected) == 'CounterClockwise') { + if (JSM.PolygonOrientation2D (projected) == JSM.Orientation.CounterClockwise) { materialIndex = polygon.GetMaterialIndex (); color = materials.GetMaterial (materialIndex).diffuse; drawer.DrawPolygon (projected, color, true); diff --git a/src/extras/painter.js b/src/extras/painter.js index 2e8152d7..9e02ef70 100644 --- a/src/extras/painter.js +++ b/src/extras/painter.js @@ -28,13 +28,13 @@ JSM.OrderPolygons = function (body, eye, center) result = JSM.CoordAdd (result, coord); } - result = JSM.VectorMultiply (result, 1.0 / polygon.VertexIndexCount ()); + result.MultiplyScalar (1.0 / polygon.VertexIndexCount ()); return result; } function CalculatePolygonValues () { - var viewDirection = JSM.VectorNormalize (JSM.CoordSub (center, eye)); + var viewDirection = JSM.CoordSub (center, eye).Normalize (); var cameraPlane = JSM.GetPlaneFromCoordAndDirection (eye, viewDirection); var i, j, polygon, coord, distance, minDistance, maxDistance; @@ -64,10 +64,10 @@ JSM.OrderPolygons = function (body, eye, center) polygonCenterDistances.push (polygonCenterDistance); polygonNormal = JSM.CalculateBodyPolygonNormal (body, i); - polygonViewVector = JSM.VectorNormalize (JSM.CoordSub (polygonCenter, eye)); + polygonViewVector = JSM.CoordSub (polygonCenter, eye).Normalize (); polygonDirection = JSM.VectorDot (polygonNormal, polygonViewVector); if (JSM.IsGreaterOrEqual (polygonDirection, 0.0)) { - polygonNormal = JSM.VectorMultiply (polygonNormal, -1); + polygonNormal.MultiplyScalar (-1); } polygonPlane = JSM.GetPlaneFromCoordAndDirection (polygonCenter, polygonNormal); diff --git a/src/extras/solidgenerator.js b/src/extras/solidgenerator.js index e623d7c9..c7e765a9 100644 --- a/src/extras/solidgenerator.js +++ b/src/extras/solidgenerator.js @@ -85,11 +85,11 @@ JSM.GenerateSolidWithRadius = function (solidName, radius) var maxRadius = 0.0; if (equalRadius) { - maxRadius = JSM.VectorLength (result.GetVertexPosition (0)); + maxRadius = result.GetVertexPosition (0).Length (); } else { var currentRadius; for (i = 0; i < result.VertexCount (); i++) { - currentRadius = JSM.VectorLength (result.GetVertexPosition (i)); + currentRadius = result.GetVertexPosition (i).Length (); if (JSM.IsGreater (currentRadius, maxRadius)) { maxRadius = currentRadius; } @@ -101,7 +101,7 @@ JSM.GenerateSolidWithRadius = function (solidName, radius) var vertex; for (i = 0; i < result.VertexCount (); i++) { vertex = result.GetVertex (i); - vertex.SetPosition (JSM.VectorMultiply (vertex.GetPosition (), scale)); + vertex.position.MultiplyScalar (scale); } } @@ -1721,7 +1721,7 @@ JSM.AddCumulatedPolygonToBody = function (body, vertices, height) var centroidCoord = new JSM.Coord (0.0, 0.0, 0.0); var normalVector = new JSM.Vector (0.0, 0.0, 0.0); CalculatePolygonCentroidAndNormal (vertices, centroidCoord, normalVector); - centroidCoord = JSM.CoordOffset (centroidCoord, normalVector, height); + centroidCoord.Offset (normalVector, height); var centroid = body.VertexCount (); JSM.AddVertexToBody (body, centroidCoord.x, centroidCoord.y, centroidCoord.z); diff --git a/src/extras/subdivision.js b/src/extras/subdivision.js index 35fc8633..25dc708c 100644 --- a/src/extras/subdivision.js +++ b/src/extras/subdivision.js @@ -28,7 +28,7 @@ JSM.CatmullClarkSubdivisionOneIteration = function (body) pgonCoord = JSM.CoordAdd (pgonCoord, vertCoord); } - pgonCoord = JSM.VectorMultiply (pgonCoord, 1.0 / pgon.verts.length); + pgonCoord.MultiplyScalar (1.0 / pgon.verts.length); pgonVertices.push (result.AddVertex (new JSM.BodyVertex (pgonCoord))); } } @@ -36,20 +36,20 @@ JSM.CatmullClarkSubdivisionOneIteration = function (body) function AddEdgeVertices () { var edgeVertexWeight = 1.0 / 4.0; - var i, j, edge, edgeCoord, pgonIndex, pgonCoord; + var i, j, edge, edgeCoord1, edgeCoord2, edgeCoord, pgonIndex, pgonCoord; for (i = 0; i < al.edges.length; i++) { edge = al.edges[i]; - edgeCoord = new JSM.Coord (0.0, 0.0, 0.0); - edgeCoord = JSM.CoordAdd (edgeCoord, JSM.VectorMultiply (body.GetVertex (edge.vert1).position, edgeVertexWeight)); - edgeCoord = JSM.CoordAdd (edgeCoord, JSM.VectorMultiply (body.GetVertex (edge.vert2).position, edgeVertexWeight)); + edgeCoord1 = body.GetVertex (edge.vert1).position.Clone ().MultiplyScalar (edgeVertexWeight); + edgeCoord2 = body.GetVertex (edge.vert2).position.Clone ().MultiplyScalar (edgeVertexWeight); + edgeCoord = JSM.CoordAdd (edgeCoord1, edgeCoord2); for (j = 0; j < 2; j++) { pgonIndex = (j === 0 ? edge.pgon1 : edge.pgon2); if (pgonIndex === -1) { pgonIndex = (j === 0 ? edge.pgon2 : edge.pgon1); } - pgonCoord = result.GetVertex (pgonVertices[pgonIndex]).position; - edgeCoord = JSM.CoordAdd (edgeCoord, JSM.VectorMultiply (pgonCoord, edgeVertexWeight)); + pgonCoord = result.GetVertex (pgonVertices[pgonIndex]).position.Clone (); + edgeCoord = JSM.CoordAdd (edgeCoord, pgonCoord.MultiplyScalar (edgeVertexWeight)); } edgeVertices.push (result.AddVertex (new JSM.BodyVertex (edgeCoord))); @@ -85,14 +85,14 @@ JSM.CatmullClarkSubdivisionOneIteration = function (body) pgonVertexWeight = 1.0 / vert.pgons.length; for (j = 0; j < vert.pgons.length; j++) { - currentVertCoord = result.GetVertex (pgonVertices[vert.pgons[j]]).position; - f = JSM.CoordAdd (f, JSM.VectorMultiply (currentVertCoord, pgonVertexWeight)); + currentVertCoord = result.GetVertex (pgonVertices[vert.pgons[j]]).position.Clone (); + f = JSM.CoordAdd (f, currentVertCoord.MultiplyScalar (pgonVertexWeight)); } edgeMidCoordWeight = 1.0 / vert.edges.length; for (j = 0; j < vert.edges.length; j++) { - edgeCoord = edgeMidCoords [vert.edges[j]]; - r = JSM.CoordAdd (r, JSM.VectorMultiply (edgeCoord, edgeMidCoordWeight)); + edgeCoord = edgeMidCoords [vert.edges[j]].Clone (); + r = JSM.CoordAdd (r, edgeCoord.MultiplyScalar (edgeMidCoordWeight)); } n = vert.edges.length; diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index ce500ea7..76f56d07 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -297,7 +297,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var basePolygon = []; var i, coord; - if (orientation == 'Clockwise') { + if (orientation == JSM.Orientation.Clockwise) { for (i = 0; i < polygon.VertexCount (); i++) { coord = polygon.GetVertex (i); basePolygon.push (new JSM.Coord (coord.x, 0.0, -coord.y)); @@ -317,7 +317,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) basePolygon.push (null); var i, coord; - if (orientation == 'CounterClockwise') { + if (orientation == JSM.Orientation.CounterClockwise) { for (i = 0; i < polygon.VertexCount (); i++) { coord = polygon.GetVertex (i); basePolygon.push (new JSM.Coord (coord.x, 0.0, -coord.y)); diff --git a/src/geometry/convexhull.js b/src/geometry/convexhull.js index e9e8cbd8..f9d030d2 100644 --- a/src/geometry/convexhull.js +++ b/src/geometry/convexhull.js @@ -36,7 +36,7 @@ JSM.ConvexHull2D = function (coords) if (current == next) { next = i; } else { - if (JSM.CoordTurnType2D (coords[current], coords[next], coords[i]) == 'Clockwise') { + if (JSM.CoordOrientation2D (coords[current], coords[next], coords[i]) == JSM.Orientation.Clockwise) { next = i; } } diff --git a/src/geometry/coord.js b/src/geometry/coord.js index 2bd00f0d..31427be0 100644 --- a/src/geometry/coord.js +++ b/src/geometry/coord.js @@ -28,6 +28,159 @@ JSM.Coord.prototype.Set = function (x, y, z) this.z = z; }; +/** +* Function: Coord.IsEqual +* Description: Returns if the coordinate is equal with the given one. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {boolean} the result +*/ +JSM.Coord.prototype.IsEqual = function (coord) +{ + return JSM.IsEqual (this.x, coord.x) && JSM.IsEqual (this.y, coord.y) && JSM.IsEqual (this.z, coord.z); +}; + +/** +* Function: Coord.IsEqualWithEps +* Description: Returns if the coordinate is equal with the given one. Uses the given epsilon for comparison. +* Parameters: +* coord {Coord} the coordinate +* eps {number} the epsilon +* Returns: +* {boolean} the result +*/ +JSM.Coord.prototype.IsEqualWithEps = function (coord, eps) +{ + return JSM.IsEqualWithEps (this.x, coord.x, eps) && JSM.IsEqualWithEps (this.y, coord.y, eps) && JSM.IsEqualWithEps (this.z, coord.z, eps); +}; + +/** +* Function: Coord.DistanceTo +* Description: Calculates the coordinate distance to the given one. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {number} the result +*/ +JSM.Coord.prototype.DistanceTo = function (coord) +{ + return Math.sqrt ((coord.x - this.x) * (coord.x - this.x) + (coord.y - this.y) * (coord.y - this.y) + (coord.z - this.z) * (coord.z - this.z)); +}; + +/** +* Function: Coord.Length +* Description: Calculates the length of the coordinate vector. +* Returns: +* {number} the result +*/ +JSM.Coord.prototype.Length = function () +{ + return Math.sqrt (this.x * this.x + this.y * this.y + this.z * this.z); +}; + +/** +* Function: Coord.MultiplyScalar +* Description: Multiplies the vector with a scalar. +* Parameters: +* scalar {number} the scalar +* Returns: +* {Coord} this pointer +*/ +JSM.Coord.prototype.MultiplyScalar = function (scalar) +{ + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + return this; +}; + + +/** +* Function: Coord.Normalize +* Description: Normalizes the coordinate vector. +* Returns: +* {Coord} this pointer +*/ +JSM.Coord.prototype.Normalize = function () +{ + var length = this.Length (); + if (JSM.IsPositive (length)) { + this.MultiplyScalar (1.0 / length); + } + return this; +}; + +/** +* Function: Coord.SetLength +* Description: Sets the length of the coordinate vector. +* Parameters: +* length {number} the length +* Returns: +* {Coord} this pointer +*/ +JSM.Coord.prototype.SetLength = function (length) +{ + var thisLength = this.Length (); + if (JSM.IsPositive (thisLength)) { + this.MultiplyScalar (length / thisLength); + } + return this; +}; + +/** +* Function: Coord.Offset +* Description: Offsets the coordinate. +* Parameters: +* direction {Vector} the direction of the offset +* distance {number} the distance of the offset +* Returns: +* {Coord} this pointer +*/ +JSM.Coord.prototype.Offset = function (direction, distance) +{ + var normal = direction.Clone ().Normalize (); + this.x += normal.x * distance; + this.y += normal.y * distance; + this.z += normal.z * distance; + return this; +}; + +/** +* Function: Coord.Rotate +* Description: Rotates the coordinate. +* Parameters: +* axis {Vector} the axis of the rotation +* angle {number} the angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Coord} this pointer +*/ + +JSM.Coord.prototype.Rotate = function (axis, angle, origo) +{ + var normal = axis.Clone ().Normalize (); + + var u = normal.x; + var v = normal.y; + var w = normal.z; + + var x = this.x - origo.x; + var y = this.y - origo.y; + var z = this.z - origo.z; + + var si = Math.sin (angle); + var co = Math.cos (angle); + this.x = - u * (- u * x - v * y - w * z) * (1.0 - co) + x * co + (- w * y + v * z) * si; + this.y = - v * (- u * x - v * y - w * z) * (1.0 - co) + y * co + (w * x - u * z) * si; + this.z = - w * (- u * x - v * y - w * z) * (1.0 - co) + z * co + (- v * x + u * y) * si; + + this.x += origo.x; + this.y += origo.y; + this.z += origo.z; + return this; +}; + /** * Function: Coord.ToString * Description: Converts the coordinate values to string. @@ -57,53 +210,101 @@ JSM.Coord.prototype.Clone = function () JSM.Vector = JSM.Coord; /** -* Class: SphericalCoord -* Description: Represents a 3D spherical coordinate. +* Function: CoordFromArray +* Description: Returns a coordinate from an array of components. * Parameters: -* radius {number} the first component -* theta {number} the second component -* phi {number} the third component +* array {number[3]} the array of components +* Returns: +* {Coord} the result */ -JSM.SphericalCoord = function (radius, theta, phi) +JSM.CoordFromArray = function (array) { - this.radius = radius; - this.theta = theta; - this.phi = phi; + return new JSM.Coord (array[0], array[1], array[2]); }; /** -* Function: SphericalCoord.Set -* Description: Sets the coordinate. +* Function: CoordToArray +* Description: Returns array of components from a coordinate. * Parameters: -* radius {number} the first component -* theta {number} the second component -* phi {number} the third component +* coord {Coord} the coordinate +* Returns: +* array {number[3]} the result */ -JSM.SphericalCoord.prototype.Set = function (radius, theta, phi) +JSM.CoordToArray = function (coord) { - this.radius = radius; - this.theta = theta; - this.phi = phi; + return [coord.x, coord.y, coord.z]; }; /** -* Function: SphericalCoord.ToString -* Description: Converts the coordinate values to string. +* Function: CoordAdd +* Description: Adds two coordinates. +* Parameters: +* a {Coord} the first coordinate +* b {Coord} the second coordinate * Returns: -* {string} the string representation of the coordinate +* {Coord} the result */ -JSM.SphericalCoord.prototype.ToString = function () +JSM.CoordAdd = function (a, b) { - return ('(' + this.radius + ', ' + this.theta + ', ' + this.phi + ')'); + return new JSM.Coord (a.x + b.x, a.y + b.y, a.z + b.z); }; /** -* Function: SphericalCoord.Clone -* Description: Clones the coordinate. +* Function: CoordSub +* Description: Subs two coordinates. +* Parameters: +* a {Coord} the first coordinate +* b {Coord} the second coordinate +* Returns: +* {Coord} the result +*/ +JSM.CoordSub = function (a, b) +{ + return new JSM.Coord (a.x - b.x, a.y - b.y, a.z - b.z); +}; + +/** +* Function: MidCoord +* Description: Calculates the coordinate in the middle of two coordinates. +* Parameters: +* a {Coord} first coordinate +* b {Coord} second coordinate +* Returns: +* {Coord} the result +*/ +JSM.MidCoord = function (a, b) +{ + return new JSM.Coord ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0, (a.z + b.z) / 2.0); +}; + +/** +* Function: VectorDot +* Description: Calculates the dot product of two vectors. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector +* Returns: +* {number} the result +*/ +JSM.VectorDot = function (a, b) +{ + return a.x * b.x + a.y * b.y + a.z * b.z; +}; + +/** +* Function: VectorCross +* Description: Calculates the cross product of two vectors. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector * Returns: -* {SphericalCoord} a cloned instance +* {Vector} the result */ -JSM.SphericalCoord.prototype.Clone = function () +JSM.VectorCross = function (a, b) { - return new JSM.SphericalCoord (this.radius, this.theta, this.phi); + var result = new JSM.Vector (0.0, 0.0, 0.0); + result.x = a.y * b.z - a.z * b.y; + result.y = a.z * b.x - a.x * b.z; + result.z = a.x * b.y - a.y * b.x; + return result; }; diff --git a/src/geometry/coord2d.js b/src/geometry/coord2d.js index 19536b64..bbae0c93 100644 --- a/src/geometry/coord2d.js +++ b/src/geometry/coord2d.js @@ -51,7 +51,6 @@ JSM.Coord2D.prototype.IsEqualWithEps = function (coord, eps) return JSM.IsEqualWithEps (this.x, coord.x, eps) && JSM.IsEqualWithEps (this.y, coord.y, eps); }; - /** * Function: Coord2D.DistanceTo * Description: Calculates the coordinate distance to the given one. @@ -123,6 +122,43 @@ JSM.Coord2D.prototype.SetLength = function (length) return this; }; +/** +* Function: Coord2D.Offset +* Description: Offsets the coordinate. +* Parameters: +* direction {Vector2D} the direction of the offset +* distance {number} the distance of the offset +* Returns: +* {Coord2D} this pointer +*/ +JSM.Coord2D.prototype.Offset = function (direction, distance) +{ + var normal = direction.Clone ().Normalize (); + this.x += normal.x * distance; + this.y += normal.y * distance; + return this; +}; + +/** +* Function: Coord2D.Rotate +* Description: Rotates the coordinate. +* Parameters: +* angle {number} the angle of the rotation +* origo {Coord2D} the origo of the rotation +* Returns: +* {Coord2D} this pointer +*/ +JSM.Coord2D.prototype.Rotate = function (angle, origo) +{ + var x = this.x - origo.x; + var y = this.y - origo.y; + var co = Math.cos (angle); + var si = Math.sin (angle); + this.x = x * co - y * si + origo.x; + this.y = x * si + y * co + origo.y; + return this; +}; + /** * Function: Coord2D.ToString * Description: Converts the coordinate values to string. @@ -152,49 +188,98 @@ JSM.Coord2D.prototype.Clone = function () JSM.Vector2D = JSM.Coord2D; /** -* Class: PolarCoord -* Description: Represents a 2D polar coordinate. +* Function: CoordFromArray2D +* Description: Returns a coordinate from an array of components. * Parameters: -* radius {number} the first component -* angle {number} the second component +* array {number[2]} the array of components +* Returns: +* {Coord2D} the result */ -JSM.PolarCoord = function (radius, angle) +JSM.CoordFromArray2D = function (array) { - this.radius = radius; - this.angle = angle; + return new JSM.Coord2D (array[0], array[1]); }; /** -* Function: PolarCoord.Set -* Description: Sets the coordinate. +* Function: CoordToArray2D +* Description: Returns array of components from a coordinate. * Parameters: -* radius {number} the first component -* angle {number} the second component +* coord {Coord2D} the coordinate +* Returns: +* array {number[2]} the result */ -JSM.PolarCoord.prototype.Set = function (radius, angle) +JSM.CoordToArray2D = function (coord) { - this.radius = radius; - this.angle = angle; + return [coord.x, coord.y]; }; /** -* Function: PolarCoord.ToString -* Description: Converts the coordinate values to string. +* Function: CoordAdd2D +* Description: Adds two coordinates. +* Parameters: +* a {Coord2D} the first coordinate +* b {Coord2D} the second coordinate * Returns: -* {string} the string representation of the coordinate +* {Coord2D} the result */ -JSM.PolarCoord.prototype.ToString = function () +JSM.CoordAdd2D = function (a, b) { - return ('(' + this.radius + ', ' + this.angle + ')'); + return new JSM.Coord2D (a.x + b.x, a.y + b.y); }; /** -* Function: PolarCoord.Clone -* Description: Clones the coordinate. +* Function: CoordSub2D +* Description: Subs two coordinates. +* Parameters: +* a {Coord2D} the first coordinate +* b {Coord2D} the second coordinate * Returns: -* {PolarCoord} a cloned instance +* {Coord2D} the result */ -JSM.PolarCoord.prototype.Clone = function () +JSM.CoordSub2D = function (a, b) { - return new JSM.PolarCoord (this.radius, this.angle); + return new JSM.Coord2D (a.x - b.x, a.y - b.y, a.z - b.z); +}; + +/** +* Function: MidCoord2D +* Description: Calculates the coordinate in the middle of two coordinates. +* Parameters: +* a {Coord2D} first coordinate +* b {Coord2D} second coordinate +* Returns: +* {Coord2D} the result +*/ +JSM.MidCoord2D = function (a, b) +{ + return new JSM.Coord2D ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0); +}; + +/** +* Function: CoordOrientation2D +* Description: Calculates the turn type of three coordinates. +* Parameters: +* a {Coord2D} the first coordinate +* b {Coord2D} the second coordinate +* c {Coord2D} the third coordinate +* Returns: +* {Orientation} the result +*/ +JSM.CoordOrientation2D = function (a, b, c) +{ + var m00 = a.x; + var m01 = a.y; + var m10 = b.x; + var m11 = b.y; + var m20 = c.x; + var m21 = c.y; + + var determinant = m00 * m11 + m01 * m20 + m10 * m21 - m11 * m20 - m01 * m10 - m00 * m21; + if (JSM.IsPositive (determinant)) { + return JSM.Orientation.CounterClockwise; + } else if (JSM.IsNegative (determinant)) { + return JSM.Orientation.Clockwise; + } + + return JSM.Orientation.Invalid; }; diff --git a/src/geometry/coordsystem.js b/src/geometry/coordsystem.js index b446831a..5e43b7f7 100644 --- a/src/geometry/coordsystem.js +++ b/src/geometry/coordsystem.js @@ -42,3 +42,160 @@ JSM.CoordSystem.prototype.Clone = function () { return new JSM.CoordSystem (this.origo.Clone (), this.e1.Clone (), this.e2.Clone (), this.e3.Clone ()); }; + +/** +* Function: CoordSystemToDirectionVectors +* Description: Converts coordinate system vectors to origo relative direction vectors. +* Parameters: +* system {CoordSystem} the coordinate system +* Returns: +* {CoordSystem} the result +*/ +JSM.CoordSystemToDirectionVectors = function (system) +{ + return new JSM.CoordSystem ( + system.origo, + JSM.CoordSub (system.e1, system.origo), + JSM.CoordSub (system.e2, system.origo), + JSM.CoordSub (system.e3, system.origo) + ); +}; + +/** +* Function: CoordSystemToAbsoluteCoords +* Description: Converts coordinate system vectors to absolute coordinates. +* Parameters: +* system {CoordSystem} the coordinate system +* Returns: +* {CoordSystem} the result +*/ +JSM.CoordSystemToAbsoluteCoords = function (system) +{ + return new JSM.CoordSystem ( + system.origo, + JSM.CoordAdd (system.e1, system.origo), + JSM.CoordAdd (system.e2, system.origo), + JSM.CoordAdd (system.e3, system.origo) + ); +}; + +/** +* Function: PolarToCartesian +* Description: Converts a polar coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* theta {number} the angle component +* Returns: +* {Coord2D} the result +*/ +JSM.PolarToCartesian = function (radius, theta) +{ + var result = new JSM.Coord2D (0.0, 0.0); + result.x = radius * Math.cos (theta); + result.y = radius * Math.sin (theta); + return result; +}; + + +/** +* Function: GetArcLengthFromAngle +* Description: Calculates arc length from radius and angle. +* Parameters: +* radius {number} the radius of the circle +* theta {number} the angle of rotation +* Returns: +* {number} the result +*/ +JSM.GetArcLengthFromAngle = function (radius, theta) +{ + return theta * radius; +}; + +/** +* Function: GetAngleFromArcLength +* Description: Calculates angle from arc length. +* Parameters: +* radius {number} the radius of the circle +* arcLength {number} the arc length +* Returns: +* {number} the result +*/ +JSM.GetAngleFromArcLength = function (radius, arcLength) +{ + if (JSM.IsEqual (radius, 0.0)) { + return 0.0; + } + + return arcLength / radius; +}; + +/** +* Function: SphericalToCartesian +* Description: Converts a spherical coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* theta {number} the angle component +* phi {number} the phi component +* Returns: +* {Coord} the result +*/ +JSM.SphericalToCartesian = function (radius, theta, phi) +{ + var result = new JSM.Coord (0.0, 0.0, 0.0); + result.x = radius * Math.sin (theta) * Math.cos (phi); + result.y = radius * Math.sin (theta) * Math.sin (phi); + result.z = radius * Math.cos (theta); + return result; +}; + +/** +* Function: CylindricalToCartesian +* Description: Converts a cylindrical coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* height {number} the height component +* theta {number} the theta component +* Returns: +* {Coord} the result +*/ +JSM.CylindricalToCartesian = function (radius, height, theta) +{ + var result = new JSM.Coord (0.0, 0.0, 0.0); + result.x = radius * Math.cos (theta); + result.y = radius * Math.sin (theta); + result.z = height; + return result; +}; + +/** +* Function: GetArcLength +* Description: Calculates arc length between two vectors. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector +* radius {number} the radius component +* Returns: +* {number} the result +*/ +JSM.GetArcLength = function (a, b, radius) +{ + var angle = JSM.GetVectorsAngle (a, b); + return angle * radius; +}; + +/** +* Function: GetFullArcLength +* Description: Calculates arc length between two vectors with the given normal vector. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector +* radius {number} the radius component +* normal {Vector} the normal vector +* Returns: +* {number} the result +*/ +JSM.GetFullArcLength = function (a, b, radius, normal) +{ + var angle = JSM.GetVectorsFullAngle (a, b, normal); + return angle * radius; +}; diff --git a/src/geometry/coordsystemutils.js b/src/geometry/coordsystemutils.js deleted file mode 100644 index b662d933..00000000 --- a/src/geometry/coordsystemutils.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* Function: CoordSystemToDirectionVectors -* Description: Converts coordinate system vectors to origo relative direction vectors. -* Parameters: -* system {CoordSystem} the coordinate system -* Returns: -* {CoordSystem} the result -*/ -JSM.CoordSystemToDirectionVectors = function (system) -{ - return new JSM.CoordSystem ( - system.origo, - JSM.CoordSub (system.e1, system.origo), - JSM.CoordSub (system.e2, system.origo), - JSM.CoordSub (system.e3, system.origo) - ); -}; - -/** -* Function: CoordSystemToAbsoluteCoords -* Description: Converts coordinate system vectors to absolute coordinates. -* Parameters: -* system {CoordSystem} the coordinate system -* Returns: -* {CoordSystem} the result -*/ -JSM.CoordSystemToAbsoluteCoords = function (system) -{ - return new JSM.CoordSystem ( - system.origo, - JSM.CoordAdd (system.e1, system.origo), - JSM.CoordAdd (system.e2, system.origo), - JSM.CoordAdd (system.e3, system.origo) - ); -}; diff --git a/src/geometry/coordutils.js b/src/geometry/coordutils.js index da7a0db6..7a7c59e5 100644 --- a/src/geometry/coordutils.js +++ b/src/geometry/coordutils.js @@ -1,122 +1,3 @@ -/** -* Function: CoordFromArray -* Description: Returns a coordinate from an array of components. -* Parameters: -* array {number[3]} the array of components -* Returns: -* {Coord} the result -*/ -JSM.CoordFromArray = function (array) -{ - return new JSM.Coord (array[0], array[1], array[2]); -}; - -/** -* Function: CoordToArray -* Description: Returns array of components from a coordinate. -* Parameters: -* coord {Coord} the coordinate -* Returns: -* array {number[3]} the result -*/ -JSM.CoordToArray = function (coord) -{ - return [coord.x, coord.y, coord.z]; -}; - -/** -* Function: CoordIsEqual -* Description: Determines if the given coordinates are equal. -* Parameters: -* a {Coord} first coordinate -* b {Coord} second coordinate -* Returns: -* {boolean} the result -*/ -JSM.CoordIsEqual = function (a, b) -{ - return JSM.IsEqual (a.x, b.x) && JSM.IsEqual (a.y, b.y) && JSM.IsEqual (a.z, b.z); -}; - -/** -* Function: CoordIsEqualWithEps -* Description: Determines if the given coordinates are equal. Uses the given epsilon for comparison. -* Parameters: -* a {Coord} first coordinate -* b {Coord} second coordinate -* eps {number} epsilon value -* Returns: -* {boolean} the result -*/ -JSM.CoordIsEqualWithEps = function (a, b, eps) -{ - return JSM.IsEqualWithEps (a.x, b.x, eps) && JSM.IsEqualWithEps (a.y, b.y, eps) && JSM.IsEqualWithEps (a.z, b.z, eps); -}; - - -/** -* Function: CoordAdd -* Description: Adds two coordinates. -* Parameters: -* a {Coord} the first coordinate -* b {Coord} the second coordinate -* Returns: -* {Coord} the result -*/ -JSM.CoordAdd = function (a, b) -{ - return new JSM.Coord (a.x + b.x, a.y + b.y, a.z + b.z); -}; - -/** -* Function: CoordSub -* Description: Subs two coordinates. -* Parameters: -* a {Coord} the first coordinate -* b {Coord} the second coordinate -* Returns: -* {Coord} the result -*/ -JSM.CoordSub = function (a, b) -{ - return new JSM.Coord (a.x - b.x, a.y - b.y, a.z - b.z); -}; - -/** -* Function: SphericalCoordIsEqual -* Description: Determines if the given coordinates are equal. -* Parameters: -* a {SpericalCoord} first coordinate -* b {SpericalCoord} second coordinate -* Returns: -* {boolean} the result -*/ -JSM.SphericalCoordIsEqual = function (a, b) -{ - return JSM.IsEqual (a.radius, b.radius) && JSM.IsEqual (a.phi, b.phi) && JSM.IsEqual (a.theta, b.theta); -}; - -/** -* Function: CoordDistance -* Description: Calculates the distance of two coordinates. -* Parameters: -* a {Coord} first coordinate -* b {Coord} second coordinate -* Returns: -* {number} the result -*/ -JSM.CoordDistance = function (a, b) -{ - var x1 = a.x; - var y1 = a.y; - var z1 = a.z; - var x2 = b.x; - var y2 = b.y; - var z2 = b.z; - - return Math.sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1)); -}; - /** * Function: CoordSignedDistance * Description: Calculates the distance of two coordinates along a direction vector. @@ -130,7 +11,7 @@ JSM.CoordDistance = function (a, b) JSM.CoordSignedDistance = function (a, b, direction) { var abDirection = JSM.CoordSub (b, a); - var distance = JSM.CoordDistance (a, b); + var distance = a.DistanceTo (b); var angle = JSM.GetVectorsAngle (abDirection, direction); if (JSM.IsPositive (angle)) { @@ -140,177 +21,6 @@ JSM.CoordSignedDistance = function (a, b, direction) return distance; }; -/** -* Function: MidCoord -* Description: Calculates the coordinate in the middle of two coordinates. -* Parameters: -* a {Coord} first coordinate -* b {Coord} second coordinate -* Returns: -* {Coord} the result -*/ -JSM.MidCoord = function (a, b) -{ - return new JSM.Coord ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0, (a.z + b.z) / 2.0); -}; - -/** -* Function: VectorMultiply -* Description: Multiplies a vector with a scalar. -* Parameters: -* vector {Vector} the vector -* scalar {number} the scalar -* Returns: -* {Vector} the result -*/ -JSM.VectorMultiply = function (vector, scalar) -{ - var result = new JSM.Vector (0.0, 0.0, 0.0); - result.x = vector.x * scalar; - result.y = vector.y * scalar; - result.z = vector.z * scalar; - return result; -}; - -/** -* Function: VectorDot -* Description: Calculates the dot product of two vectors. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* Returns: -* {number} the result -*/ -JSM.VectorDot = function (a, b) -{ - return a.x * b.x + a.y * b.y + a.z * b.z; -}; - -/** -* Function: VectorCross -* Description: Calculates the cross product of two vectors. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* Returns: -* {Vector} the result -*/ -JSM.VectorCross = function (a, b) -{ - var result = new JSM.Vector (0.0, 0.0, 0.0); - result.x = a.y * b.z - a.z * b.y; - result.y = a.z * b.x - a.x * b.z; - result.z = a.x * b.y - a.y * b.x; - return result; -}; - -/** -* Function: VectorLength -* Description: Calculates length of a vector. -* Parameters: -* vector {Vector} the vector -* Returns: -* {number} the result -*/ -JSM.VectorLength = function (vector) -{ - var x = vector.x; - var y = vector.y; - var z = vector.z; - - return Math.sqrt (x * x + y * y + z * z); -}; - -/** -* Function: VectorNormalize -* Description: Normalize a vector. -* Parameters: -* vector {Vector} the vector -* Returns: -* {Vector} the result -*/ -JSM.VectorNormalize = function (vector) -{ - var length = JSM.VectorLength (vector); - var result = new JSM.Vector (0.0, 0.0, 0.0); - if (JSM.IsGreater (length, 0.0)) { - result = JSM.VectorMultiply (vector, 1.0 / length); - } - return result; -}; - -/** -* Function: VectorSetLength -* Description: Sets the length of a vector. -* Parameters: -* vector {Vector} the vector -* length {number} the length -* Returns: -* {Vector} the result -*/ -JSM.VectorSetLength = function (vector, length) -{ - var ratio = length / JSM.VectorLength (vector); - var result = JSM.VectorMultiply (vector, ratio); - return result; -}; - - -/** -* Function: CoordOffset -* Description: Offsets a coordinate. -* Parameters: -* coord {Coord} the coordinate -* direction {Vector} the direction of the offset -* distance {number} the distance of the offset -* Returns: -* {Coord} the result -*/ -JSM.CoordOffset = function (coord, direction, distance) -{ - var normal = JSM.VectorNormalize (direction); - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = coord.x + normal.x * distance; - result.y = coord.y + normal.y * distance; - result.z = coord.z + normal.z * distance; - return result; -}; - -/** -* Function: CoordRotate -* Description: Rotates a coordinate. -* Parameters: -* coord {Coord} the coordinate -* axis {Vector} the axis of the rotation -* angle {number} the angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Coord} the result -*/ -JSM.CoordRotate = function (coord, axis, angle, origo) -{ - var offseted = JSM.CoordSub (coord, origo); - var normal = JSM.VectorNormalize (axis); - - var u = normal.x; - var v = normal.y; - var w = normal.z; - - var x = offseted.x; - var y = offseted.y; - var z = offseted.z; - - var si = Math.sin (angle); - var co = Math.cos (angle); - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = - u * (- u * x - v * y - w * z) * (1.0 - co) + x * co + (- w * y + v * z) * si; - result.y = - v * (- u * x - v * y - w * z) * (1.0 - co) + y * co + (w * x - u * z) * si; - result.z = - w * (- u * x - v * y - w * z) * (1.0 - co) + z * co + (- v * x + u * y) * si; - - result = JSM.CoordAdd (result, origo); - return result; -}; - /** * Function: GetVectorsAngle * Description: Calculates the angle of two vectors. @@ -322,9 +32,9 @@ JSM.CoordRotate = function (coord, axis, angle, origo) */ JSM.GetVectorsAngle = function (a, b) { - var aDirection = JSM.VectorNormalize (a); - var bDirection = JSM.VectorNormalize (b); - if (JSM.CoordIsEqual (aDirection, bDirection)) { + var aDirection = a.Clone ().Normalize (); + var bDirection = b.Clone ().Normalize (); + if (aDirection.IsEqual (bDirection)) { return 0.0; } @@ -347,7 +57,7 @@ JSM.GetVectorsFullAngle = function (a, b, normal) var angle = JSM.GetVectorsAngle (a, b); var origo = new JSM.Coord (0.0, 0.0, 0.0); - if (JSM.CoordTurnType (a, origo, b, normal) == 'Clockwise') { + if (JSM.CoordOrientation (a, origo, b, normal) == JSM.Orientation.Clockwise) { angle = 2.0 * Math.PI - angle; } @@ -385,12 +95,12 @@ JSM.GetCoord2DFromCoord = function (coord, origo, normal) var axis = JSM.VectorCross (normal, zNormal); var angle = JSM.GetVectorsAngle (normal, zNormal); - var rotated = JSM.CoordRotate (coord, axis, angle, origo); + var rotated = coord.Clone ().Rotate (axis, angle, origo); return new JSM.Coord2D (rotated.x, rotated.y); }; /** -* Function: CoordTurnType +* Function: CoordOrientation * Description: Calculates the turn type of three coordinates. * Parameters: * a {Coord} the first coordinate @@ -398,27 +108,27 @@ JSM.GetCoord2DFromCoord = function (coord, origo, normal) * c {Coord} the third coordinate * normal {Vector} normal vector for calculation * Returns: -* {string} 'CounterClockwise', 'Clockwise', or 'Collinear' +* {Orientation} the result */ -JSM.CoordTurnType = function (a, b, c, normal) +JSM.CoordOrientation = function (a, b, c, normal) { var origo = new JSM.Coord (0.0, 0.0, 0.0); var a2 = JSM.GetCoord2DFromCoord (a, origo, normal); var b2 = JSM.GetCoord2DFromCoord (b, origo, normal); var c2 = JSM.GetCoord2DFromCoord (c, origo, normal); - var turnType = JSM.CoordTurnType2D (a2, b2, c2); + var orientation = JSM.CoordOrientation2D (a2, b2, c2); var zNormal = new JSM.Vector (0.0, 0.0, 1.0); var angle = JSM.GetVectorsAngle (normal, zNormal); if (JSM.IsEqual (angle, Math.PI)) { - if (turnType === 'CounterClockwise') { - turnType = 'Clockwise'; - } else if (turnType === 'Clockwise') { - turnType = 'CounterClockwise'; + if (orientation == JSM.Orientation.CounterClockwise) { + orientation = JSM.Orientation.Clockwise; + } else if (orientation == JSM.Orientation.Clockwise) { + orientation = JSM.Orientation.CounterClockwise; } } - return turnType; + return orientation; }; /** @@ -438,7 +148,7 @@ JSM.CalculateCentroid = function (coords) for (i = 0; i < count; i++) { centroid = JSM.CoordAdd (centroid, coords[i]); } - centroid = JSM.VectorMultiply (centroid, 1.0 / count); + centroid.MultiplyScalar (1.0 / count); } return centroid; @@ -464,8 +174,8 @@ JSM.CalculateTriangleNormal = function (v0, v1, v2) normal.y = (v.z * w.x - v.x * w.z); normal.z = (v.x * w.y - v.y * w.x); - var normalized = JSM.VectorNormalize (normal); - return normalized; + normal.Normalize (); + return normal; }; /** @@ -496,8 +206,8 @@ JSM.CalculateNormal = function (coords) } } - var normalized = JSM.VectorNormalize (normal); - return normalized; + normal.Normalize (); + return normal; }; /** @@ -522,13 +232,13 @@ JSM.BarycentricInterpolation = function (vertex0, vertex1, vertex2, value0, valu return Math.sqrt (areaSquare); } - var edge0 = JSM.CoordDistance (vertex0, vertex1); - var edge1 = JSM.CoordDistance (vertex1, vertex2); - var edge2 = JSM.CoordDistance (vertex2, vertex0); + var edge0 = vertex0.DistanceTo (vertex1); + var edge1 = vertex1.DistanceTo (vertex2); + var edge2 = vertex2.DistanceTo (vertex0); - var distance0 = JSM.CoordDistance (vertex0, position); - var distance1 = JSM.CoordDistance (vertex1, position); - var distance2 = JSM.CoordDistance (vertex2, position); + var distance0 = vertex0.DistanceTo (position); + var distance1 = vertex1.DistanceTo (position); + var distance2 = vertex2.DistanceTo (position); var area = GetTriangleArea (edge0, edge1, edge2); if (JSM.IsZero (area)) { @@ -539,154 +249,10 @@ JSM.BarycentricInterpolation = function (vertex0, vertex1, vertex2, value0, valu var area1 = GetTriangleArea (edge1, distance1, distance2); var area2 = GetTriangleArea (edge2, distance0, distance2); - var interpolated0 = JSM.VectorMultiply (value0, area1); - var interpolated1 = JSM.VectorMultiply (value1, area2); - var interpolated2 = JSM.VectorMultiply (value2, area0); + var interpolated0 = value0.Clone ().MultiplyScalar (area1); + var interpolated1 = value1.Clone ().MultiplyScalar (area2); + var interpolated2 = value2.Clone ().MultiplyScalar (area0); var interpolated = JSM.CoordAdd (JSM.CoordAdd (interpolated0, interpolated1), interpolated2); - return JSM.VectorMultiply (interpolated, 1.0 / area); -}; - -/** -* Function: SphericalToCartesian -* Description: Converts a spherical coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* theta {number} the angle component -* phi {number} the phi component -* Returns: -* {Coord} the result -*/ -JSM.SphericalToCartesian = function (radius, theta, phi) -{ - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = radius * Math.sin (theta) * Math.cos (phi); - result.y = radius * Math.sin (theta) * Math.sin (phi); - result.z = radius * Math.cos (theta); - return result; -}; - -/** -* Function: CartesianToSpherical -* Description: Converts a cartesian coordinate to a spherical coordinate. -* Parameters: -* x {number} the x component -* y {number} the y component -* z {number} the z component -* Returns: -* {SphericalCoord} the result -*/ -JSM.CartesianToSpherical = function (x, y, z) -{ - var result = new JSM.SphericalCoord (0.0, 0.0, 0.0); - result.radius = Math.sqrt (x * x + y * y + z * z); - if (JSM.IsZero (result.radius)) { - return result; - } - result.theta = Math.acos (z / result.radius); - result.phi = Math.atan2 (y, x); - return result; -}; - -/** -* Function: SphericalToCartesianWithOrigo -* Description: Converts a spherical coordinate to a cartesian coordinate with the given origo. -* Parameters: -* spherical {SphericalCoord} the coordinate -* origo {Coord} the origo -* Returns: -* {Coord} the result -*/ -JSM.SphericalToCartesianWithOrigo = function (spherical, origo) -{ - var cartesian = JSM.SphericalToCartesian (spherical.radius, spherical.theta, spherical.phi); - var offseted = JSM.CoordAdd (cartesian, origo); - return offseted; -}; - -/** -* Function: CartesianToSphericalWithOrigo -* Description: Converts a cartesian coordinate to a spherical coordinate with the given origo. -* Parameters: -* cartesian {Coord} the coordinate -* origo {Coord} the origo -* Returns: -* {SphericalCoord} the result -*/ -JSM.CartesianToSphericalWithOrigo = function (cartesian, origo) -{ - var offseted = JSM.CoordSub (cartesian, origo); - var spherical = JSM.CartesianToSpherical (offseted.x, offseted.y, offseted.z); - return spherical; -}; - -/** -* Function: MoveCoordOnSphere -* Description: Moves a coordinate on a surface of a sphere with the given angles. -* Parameters: -* coord {Coord} the coordinate -* origo {Coord} the origo -* thetaAngle {number} the theta angle -* phiAngle {number} the phi angle -* Returns: -* {Coord} the result -*/ -JSM.MoveCoordOnSphere = function (coord, origo, thetaAngle, phiAngle) -{ - var spherical = JSM.CartesianToSphericalWithOrigo (coord, origo); - spherical.theta += thetaAngle; - spherical.phi += phiAngle; - var cartesian = JSM.SphericalToCartesianWithOrigo (spherical, origo); - return cartesian; -}; - -/** -* Function: CylindricalToCartesian -* Description: Converts a cylindrical coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* height {number} the height component -* theta {number} the theta component -* Returns: -* {Coord} the result -*/ -JSM.CylindricalToCartesian = function (radius, height, theta) -{ - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = radius * Math.cos (theta); - result.y = radius * Math.sin (theta); - result.z = height; - return result; -}; - -/** -* Function: GetArcLength -* Description: Calculates arc length between two vectors. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* radius {number} the radius component -* Returns: -* {number} the result -*/ -JSM.GetArcLength = function (a, b, radius) -{ - var angle = JSM.GetVectorsAngle (a, b); - return angle * radius; -}; - -/** -* Function: GetFullArcLength -* Description: Calculates arc length between two vectors with the given normal vector. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* radius {number} the radius component -* normal {Vector} the normal vector -* Returns: -* {number} the result -*/ -JSM.GetFullArcLength = function (a, b, radius, normal) -{ - var angle = JSM.GetVectorsFullAngle (a, b, normal); - return angle * radius; + interpolated.MultiplyScalar (1.0 / area); + return interpolated; }; diff --git a/src/geometry/coordutils2d.js b/src/geometry/coordutils2d.js deleted file mode 100644 index 415690bf..00000000 --- a/src/geometry/coordutils2d.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* Function: CoordFromArray2D -* Description: Returns a coordinate from an array of components. -* Parameters: -* array {number[2]} the array of components -* Returns: -* {Coord2D} the result -*/ -JSM.CoordFromArray2D = function (array) -{ - return new JSM.Coord2D (array[0], array[1]); -}; - -/** -* Function: CoordToArray2D -* Description: Returns array of components from a coordinate. -* Parameters: -* coord {Coord2D} the coordinate -* Returns: -* array {number[2]} the result -*/ -JSM.CoordToArray2D = function (coord) -{ - return [coord.x, coord.y]; -}; - -/** -* Function: CoordAdd2D -* Description: Adds two coordinates. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* Returns: -* {Coord2D} the result -*/ -JSM.CoordAdd2D = function (a, b) -{ - return new JSM.Coord2D (a.x + b.x, a.y + b.y); -}; - -/** -* Function: CoordSub2D -* Description: Subs two coordinates. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* Returns: -* {Coord2D} the result -*/ -JSM.CoordSub2D = function (a, b) -{ - return new JSM.Coord2D (a.x - b.x, a.y - b.y, a.z - b.z); -}; - -/** -* Function: MidCoord2D -* Description: Calculates the coordinate in the middle of two coordinates. -* Parameters: -* a {Coord2D} first coordinate -* b {Coord2D} second coordinate -* Returns: -* {Coord2D} the result -*/ -JSM.MidCoord2D = function (a, b) -{ - return new JSM.Coord2D ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0); -}; - -/** -* Function: CoordOffset2D -* Description: Offsets a coordinate. -* Parameters: -* coord {Coord2D} the coordinate -* direction {Vector2D} the direction of the offset -* distance {number} the distance of the offset -* Returns: -* {Coord2D} the result -*/ -JSM.CoordOffset2D = function (coord, direction, distance) -{ - var normal = direction.Clone ().Normalize (); - var result = new JSM.Coord2D (0.0, 0.0); - result.x = coord.x + normal.x * distance; - result.y = coord.y + normal.y * distance; - return result; -}; - -/** -* Function: CoordRotate2D -* Description: Rotates a coordinate. -* Parameters: -* coord {Coord2D} the coordinate -* angle {number} the angle of the rotation -* origo {Coord2D} the origo of the rotation -* Returns: -* {Coord} the result -*/ -JSM.CoordRotate2D = function (coord, angle, origo) -{ - var offseted = JSM.CoordSub2D (coord, origo); - var result = new JSM.Coord2D (); - var co = Math.cos (angle); - var si = Math.sin (angle); - result.x = offseted.x * co - offseted.y * si; - result.y = offseted.x * si + offseted.y * co; - result = JSM.CoordAdd2D (result, origo); - return result; -}; - -/** -* Function: PolarToCartesian -* Description: Converts a polar coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* theta {number} the angle component -* Returns: -* {Coord2D} the result -*/ -JSM.PolarToCartesian = function (radius, theta) -{ - var result = new JSM.Coord2D (0.0, 0.0); - result.x = radius * Math.cos (theta); - result.y = radius * Math.sin (theta); - return result; -}; - -/** -* Function: GetArcLengthFromAngle -* Description: Calculates arc length from radius and angle. -* Parameters: -* radius {number} the radius of the circle -* theta {number} the angle of rotation -* Returns: -* {number} the result -*/ -JSM.GetArcLengthFromAngle = function (radius, theta) -{ - return theta * radius; -}; - -/** -* Function: GetAngleFromArcLength -* Description: Calculates angle from arc length. -* Parameters: -* radius {number} the radius of the circle -* arcLength {number} the arc length -* Returns: -* {number} the result -*/ -JSM.GetAngleFromArcLength = function (radius, arcLength) -{ - if (JSM.IsEqual (radius, 0.0)) { - return 0.0; - } - - return arcLength / radius; -}; - -/** -* Function: CoordTurnType2D -* Description: Calculates the turn type of three coordinates. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* c {Coord2D} the third coordinate -* Returns: -* {string} 'CounterClockwise', 'Clockwise', or 'Collinear' -*/ -JSM.CoordTurnType2D = function (a, b, c) -{ - var m00 = a.x; - var m01 = a.y; - var m02 = 1.0; - var m10 = b.x; - var m11 = b.y; - var m12 = 1.0; - var m20 = c.x; - var m21 = c.y; - var m22 = 1.0; - - var determinant = JSM.MatrixDeterminant3x3 (m00, m01, m02, m10, m11, m12, m20, m21, m22); - if (JSM.IsPositive (determinant)) { - return 'CounterClockwise'; - } else if (JSM.IsNegative (determinant)) { - return 'Clockwise'; - } else { - return 'Collinear'; - } -}; diff --git a/src/geometry/definitions.js b/src/geometry/definitions.js new file mode 100644 index 00000000..f530a92e --- /dev/null +++ b/src/geometry/definitions.js @@ -0,0 +1,223 @@ + +JSM.Eps = 0.00000001; +JSM.Inf = 9999999999; +JSM.RadDeg = 57.29577951308232; +JSM.DegRad = 0.017453292519943; + +/** +* Function: IsZero +* Description: Determines if the given value is near zero. Uses epsilon for comparison. +* Parameters: +* a {number} the value +* Returns: +* {boolean} the result +*/ +JSM.IsZero = function (a) +{ + return Math.abs (a) < JSM.Eps; +}; + +/** +* Function: IsPositive +* Description: Determines if the given value is positive. Uses epsilon for comparison. +* Parameters: +* a {number} the value +* Returns: +* {boolean} the result +*/ +JSM.IsPositive = function (a) +{ + return a > JSM.Eps; +}; + +/** +* Function: IsNegative +* Description: Determines if the given value is negative. Uses epsilon for comparison. +* Parameters: +* a {number} the value +* Returns: +* {boolean} the result +*/ +JSM.IsNegative = function (a) +{ + return a < -JSM.Eps; +}; + +/** +* Function: IsLower +* Description: Determines if a value is lower than an other. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {boolean} the result +*/ +JSM.IsLower = function (a, b) +{ + return b - a > JSM.Eps; +}; + +/** +* Function: IsGreater +* Description: Determines if a value is greater than an other. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {boolean} the result +*/ +JSM.IsGreater = function (a, b) +{ + return a - b > JSM.Eps; +}; + +/** +* Function: IsEqual +* Description: Determines if two values are equal. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {boolean} the result +*/ +JSM.IsEqual = function (a, b) +{ + return Math.abs (b - a) < JSM.Eps; +}; + +/** +* Function: IsEqualWithEps +* Description: Determines if two values are equal. Uses the given epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* eps {number} epsilon value +* Returns: +* {boolean} the result +*/ +JSM.IsEqualWithEps = function (a, b, eps) +{ + return Math.abs (b - a) < eps; +}; + +/** +* Function: IsLowerOrEqual +* Description: Determines if a value is lower or equal to an other. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {boolean} the result +*/ +JSM.IsLowerOrEqual = function (a, b) +{ + return JSM.IsLower (a, b) || JSM.IsEqual (a, b); +}; + +/** +* Function: IsGreaterOrEqual +* Description: Determines if a value is greater or equal to an other. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {boolean} the result +*/ +JSM.IsGreaterOrEqual = function (a, b) +{ + return JSM.IsGreater (a, b) || JSM.IsEqual (a, b); +}; + +/** +* Function: Minimum +* Description: Returns the minimum of two values. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {number} the result +*/ +JSM.Minimum = function (a, b) +{ + return JSM.IsLower (a, b) ? a : b; +}; + +/** +* Function: Maximum +* Description: Returns the maximum of two values. Uses epsilon for comparison. +* Parameters: +* a {number} first value +* b {number} second value +* Returns: +* {number} the result +*/ +JSM.Maximum = function (a, b) +{ + return JSM.IsGreater (a, b) ? a : b; +}; + +/** +* Function: ArcSin +* Description: Calculates the arcus sinus value. +* Parameters: +* value {number} the value +* Returns: +* {number} the result +*/ +JSM.ArcSin = function (value) +{ + if (JSM.IsGreaterOrEqual (value, 1.0)) { + return Math.PI / 2.0; + } else if (JSM.IsLowerOrEqual (value, -1.0)) { + return - Math.PI / 2.0; + } + + return Math.asin (value); +}; + +/** +* Function: ArcCos +* Description: Calculates the arcus cosinus value. +* Parameters: +* value {number} the value +* Returns: +* {number} the result +*/ +JSM.ArcCos = function (value) +{ + if (JSM.IsGreaterOrEqual (value, 1.0)) { + return 0.0; + } else if (JSM.IsLowerOrEqual (value, -1.0)) { + return Math.PI; + } + + return Math.acos (value); +}; + +/** +* Enum: Orientation +* Description: Orientation of coordinates. +* Values: +* {Invalid} invalid orientation or collinear +* {CounterClockwise} counter clockwise orientation +* {Clockwise} clockwise orientation +*/ +JSM.Orientation = { + Invalid : 0, + CounterClockwise : 1, + Clockwise : 2 +}; + +/** +* Enum: Complexity +* Description: Complexity of polygon. +* Values: +* {Invalid} invalid polygon +* {Convex} convex polygon +* {Concave} concave polygon +*/ +JSM.Complexity = { + Invalid : 0, + Convex : 1, + Concave : 2 +}; diff --git a/src/geometry/lineutils.js b/src/geometry/lineutils.js index 0d4d011f..73b73bfa 100644 --- a/src/geometry/lineutils.js +++ b/src/geometry/lineutils.js @@ -56,7 +56,7 @@ JSM.CoordLinePosition = function (coord, line, projected) projected.Set (a.x, a.y, a.z); } - if (JSM.CoordIsEqual (a, coord)) { + if (a.IsEqual (coord)) { return 'CoordOnLine'; } @@ -64,12 +64,13 @@ JSM.CoordLinePosition = function (coord, line, projected) } var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var c = JSM.CoordAdd (a, JSM.VectorMultiply (b, u)); + var bu = b.Clone ().MultiplyScalar (u); + var c = JSM.CoordAdd (a, bu); if (projected !== undefined) { projected.Set (c.x, c.y, c.z); } - var distance = JSM.CoordDistance (coord, c); + var distance = coord.DistanceTo (c); if (JSM.IsZero (distance)) { return 'CoordOnLine'; } @@ -111,7 +112,8 @@ JSM.ProjectCoordToLine = function (coord, line) } var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var c = JSM.CoordAdd (a, JSM.VectorMultiply (b, u)); + var bu = b.Clone ().MultiplyScalar (u); + var c = JSM.CoordAdd (a, bu); result.Set (c.x, c.y, c.z); return result; @@ -136,11 +138,11 @@ JSM.LineLineClosestPoint = function (aLine, bLine, aClosestPoint, bClosestPoint) return result; } - var aDir = JSM.VectorNormalize (aLine.direction); + var aDir = aLine.direction.Clone ().Normalize (); var aStart = aLine.start; var aEnd = JSM.CoordAdd (aStart, aDir); - var bDir = JSM.VectorNormalize (bLine.direction); + var bDir = bLine.direction.Clone ().Normalize (); var bStart = bLine.start; var bEnd = JSM.CoordAdd (bStart, bDir); @@ -161,13 +163,14 @@ JSM.LineLineClosestPoint = function (aLine, bLine, aClosestPoint, bClosestPoint) var mub = (d0232 + mua * d3210) / d3232; if (aClosestPoint !== undefined) { - aDir = JSM.VectorNormalize (JSM.CoordSub (aEnd, aStart)); - var aClosest = JSM.CoordAdd (aStart, JSM.VectorMultiply (aDir, mua)); + aDir.MultiplyScalar (mua); + var aClosest = JSM.CoordAdd (aStart, aDir); aClosestPoint.Set (aClosest.x, aClosest.y, aClosest.z); } if (bClosestPoint !== undefined) { - var bClosest = JSM.CoordAdd (bStart, JSM.VectorMultiply (bDir, mub)); + bDir.MultiplyScalar (mub); + var bClosest = JSM.CoordAdd (bStart, bDir); bClosestPoint.Set (bClosest.x, bClosest.y, bClosest.z); } @@ -192,7 +195,7 @@ JSM.LineLinePosition = function (aLine, bLine, intersection) return 'LinesIntersectsCoincident'; } - if (JSM.CoordIsEqual (aClosestPoint, bClosestPoint)) { + if (aClosestPoint.IsEqual (bClosestPoint)) { if (intersection !== undefined) { intersection.Set (aClosestPoint.x, aClosestPoint.y, aClosestPoint.z); } diff --git a/src/geometry/matrix.js b/src/geometry/matrix.js index fccfe421..32d6175b 100644 --- a/src/geometry/matrix.js +++ b/src/geometry/matrix.js @@ -346,7 +346,7 @@ JSM.MatrixTranslation = function (x, y, z) */ JSM.MatrixRotation = function (axis, angle, origo) { - var normal = JSM.VectorNormalize (axis); + var normal = axis.Clone ().Normalize (); var u = normal.x; var v = normal.y; @@ -563,15 +563,15 @@ JSM.MatrixRotationZ = function (angle) */ JSM.MatrixView = function (eye, center, up) { - if (JSM.CoordIsEqual (eye, center)) { + if (eye.IsEqual (center)) { return JSM.MatrixIdentity (); } var result = []; - var d = JSM.VectorNormalize (JSM.CoordSub (eye, center)); - var v = JSM.VectorNormalize (JSM.VectorCross (up, d)); - var u = JSM.VectorNormalize (JSM.VectorCross (d, v)); + var d = JSM.CoordSub (eye, center).Normalize (); + var v = JSM.VectorCross (up, d).Normalize (); + var u = JSM.VectorCross (d, v).Normalize (); result[0] = v.x; result[1] = u.x; diff --git a/src/geometry/octree.js b/src/geometry/octree.js index c4b332e8..8a620287 100644 --- a/src/geometry/octree.js +++ b/src/geometry/octree.js @@ -43,7 +43,8 @@ JSM.CreateOctreeChildNodes = function (originalBox, createNodeCallback) { function CreateNode (originalBox, createNodeCallback, dirX, dirY, dirZ) { - var size = JSM.VectorMultiply (originalBox.GetSize (), 0.5); + var size = originalBox.GetSize ().Clone (); + size.MultiplyScalar (0.5); var min = new JSM.Coord ( originalBox.min.x + dirX * size.x, originalBox.min.y + dirY * size.y, @@ -137,7 +138,7 @@ JSM.Octree.prototype.FindCoordInNode = function (coord, node) var i, current; for (i = 0; i < node.coords.length; i++) { current = node.coords[i]; - if (JSM.CoordIsEqual (coord, this.coords[current])) { + if (coord.IsEqual (this.coords[current])) { return current; } } diff --git a/src/geometry/planeutils.js b/src/geometry/planeutils.js index 702903d4..b743c7b7 100644 --- a/src/geometry/planeutils.js +++ b/src/geometry/planeutils.js @@ -10,7 +10,7 @@ JSM.GetPlaneFromCoordAndDirection = function (coord, direction) { var plane = new JSM.Plane (); - var normal = JSM.VectorNormalize (direction); + var normal = direction.Clone ().Normalize (); var pa = normal.x; var pb = normal.y; var pc = normal.z; @@ -82,7 +82,7 @@ JSM.CoordPlanePosition = function (coord, plane) */ JSM.LinePlanePosition = function (line, plane, intersection) { - var direction = JSM.VectorNormalize (line.direction); + var direction = line.direction.Clone ().Normalize (); var x1 = line.start.x; var y1 = line.start.y; @@ -104,7 +104,8 @@ JSM.LinePlanePosition = function (line, plane, intersection) var u = (a * x1 + b * y1 + c * z1 + d) / denom; if (intersection !== undefined) { - var i = JSM.CoordAdd (line.start, JSM.VectorMultiply (direction, u)); + direction.MultiplyScalar (u); + var i = JSM.CoordAdd (line.start, direction); intersection.Set (i.x, i.y, i.z); } @@ -122,7 +123,7 @@ JSM.LinePlanePosition = function (line, plane, intersection) */ JSM.LinePlaneIntersection = function (line, plane) { - var direction = JSM.VectorNormalize (line.direction); + var direction = line.direction.Clone ().Normalize (); var x1 = line.start.x; var y1 = line.start.y; @@ -144,7 +145,8 @@ JSM.LinePlaneIntersection = function (line, plane) } var u = (a * x1 + b * y1 + c * z1 + d) / denom; - result = JSM.CoordAdd (line.start, JSM.VectorMultiply (direction, u)); + direction.MultiplyScalar (u); + result = JSM.CoordAdd (line.start, direction); return result; }; @@ -198,7 +200,7 @@ JSM.CoordPlaneDistance = function (coord, plane) */ JSM.CoordPlaneSignedDirectionalDistance = function (coord, direction, plane) { - var normal = JSM.VectorNormalize (direction); + var normal = direction.Clone ().Normalize (); var x1 = coord.x; var y1 = coord.y; @@ -219,8 +221,9 @@ JSM.CoordPlaneSignedDirectionalDistance = function (coord, direction, plane) } var u = (a * x1 + b * y1 + c * z1 + d) / denom; - var intersection = JSM.CoordAdd (coord, JSM.VectorMultiply (normal, u)); - var distance = JSM.CoordDistance (coord, intersection); + normal.MultiplyScalar (u); + var intersection = JSM.CoordAdd (coord, normal); + var distance = coord.DistanceTo (intersection); var s = a * x1 + b * y1 + c * z1 + d; if (JSM.IsNegative (s)) { distance = -distance; @@ -270,8 +273,8 @@ JSM.ProjectCoordToPlane = function (coord, plane) distance = -distance; } - var normal = JSM.VectorNormalize (new JSM.Coord (a, b, c)); - var result = JSM.CoordOffset (coord, normal, distance); + var normal = new JSM.Coord (a, b, c).Normalize (); + var result = coord.Clone ().Offset (normal, distance); return result; }; diff --git a/src/geometry/polygonutils.js b/src/geometry/polygonutils.js index 5b5ff0ce..05b969c5 100644 --- a/src/geometry/polygonutils.js +++ b/src/geometry/polygonutils.js @@ -64,18 +64,18 @@ JSM.PolygonArea2D = function (polygon) * Parameters: * polygon {Polygon2D} the polygon * Returns: -* {string} 'CounterClockwise', 'Clockwise', or 'Invalid' +* {Orientation} the result */ JSM.PolygonOrientation2D = function (polygon) { var signedArea = JSM.PolygonSignedArea2D (polygon); if (JSM.IsPositive (signedArea)) { - return 'CounterClockwise'; + return JSM.Orientation.CounterClockwise; } else if (JSM.IsNegative (signedArea)) { - return 'Clockwise'; + return JSM.Orientation.Clockwise; } - return 'Invalid'; + return JSM.Orientation.Invalid; }; /** @@ -107,7 +107,7 @@ JSM.ChangePolygonOrientation2D = function (polygon) JSM.CreateCCWPolygonFromVertices = function (vertices) { var polygon = JSM.CreatePolygonFromVertices (vertices); - if (JSM.PolygonOrientation2D (polygon) != 'CounterClockwise') { + if (JSM.PolygonOrientation2D (polygon) != JSM.Orientation.CounterClockwise) { JSM.ChangePolygonOrientation2D (polygon); } return polygon; @@ -119,7 +119,7 @@ JSM.CreateCCWPolygonFromVertices = function (vertices) * Parameters: * polygon {Polygon2D} the polygon * Returns: -* {string} 'Concave', 'Convex', or 'Invalid' +* {Complexity} the result */ JSM.PolygonComplexity2D = function (polygon) { @@ -129,7 +129,7 @@ JSM.PolygonComplexity2D = function (polygon) var count = polygon.VertexCount (); var i, prevIndex, currIndex, nextIndex; - var prev, curr, next, turnType; + var prev, curr, next, orientation; for (i = 0; i < count; i++) { prevIndex = (i === 0 ? count - 1 : i - 1); currIndex = i; @@ -139,23 +139,23 @@ JSM.PolygonComplexity2D = function (polygon) curr = polygon.GetVertex (currIndex); next = polygon.GetVertex (nextIndex); - turnType = JSM.CoordTurnType2D (prev, curr, next); - if (turnType === 'CounterClockwise') { + orientation = JSM.CoordOrientation2D (prev, curr, next); + if (orientation == JSM.Orientation.CounterClockwise) { hasCounterClockwiseVertex = true; - } else if (turnType === 'Clockwise') { + } else if (orientation == JSM.Orientation.Clockwise) { hasClockWiseVertex = true; } if (hasCounterClockwiseVertex && hasClockWiseVertex) { - return 'Concave'; + return JSM.Complexity.Concave; } } if (!hasCounterClockwiseVertex && !hasClockWiseVertex) { - return 'Invalid'; + return JSM.Complexity.Invalid; } - return 'Convex'; + return JSM.Complexity.Convex; }; /** @@ -544,7 +544,7 @@ JSM.PolygonTriangulate2D = function (polygon) continue; } - if (orientation === 'CounterClockwise') { + if (orientation == JSM.Orientation.CounterClockwise) { result.push (resultPolygon); } else { resultTriangle = []; @@ -622,11 +622,11 @@ JSM.PolygonTriangulate2D = function (polygon) var complexity = JSM.PolygonComplexity2D (workPolygon); var orientation = JSM.PolygonOrientation2D (workPolygon); - if (complexity === 'Invalid' || orientation === 'Invalid') { + if (complexity == JSM.Complexity.Invalid || orientation == JSM.Orientation.Invalid) { return []; } - if (orientation !== 'CounterClockwise') { + if (orientation !== JSM.Orientation.CounterClockwise) { var i1, i2, tmp; for (i = 0; i < count / 2; i++) { i1 = i; @@ -637,7 +637,7 @@ JSM.PolygonTriangulate2D = function (polygon) } } - if (complexity === 'Convex') { + if (complexity == JSM.Complexity.Convex) { var triangle; for (i = 0; i < count - 2; i++) { triangle = []; @@ -818,13 +818,14 @@ JSM.OffsetPolygonContour = function (polygon, width) prevDir = JSM.CoordSub (prevVertex, currVertex); nextDir = JSM.CoordSub (nextVertex, currVertex); angle = JSM.GetVectorsAngle (prevDir, nextDir) / 2.0; - if (JSM.CoordTurnType (prevVertex, currVertex, nextVertex, normal) === 'Clockwise') { + if (JSM.CoordOrientation (prevVertex, currVertex, nextVertex, normal) == JSM.Orientation.Clockwise) { angle = Math.PI - angle; } distance = width / Math.sin (angle); - offsetedCoord = JSM.CoordOffset (currVertex, nextDir, distance); - offsetedCoord = JSM.CoordRotate (offsetedCoord, normal, angle, currVertex); + offsetedCoord = currVertex.Clone (); + offsetedCoord.Offset (nextDir, distance); + offsetedCoord.Rotate (normal, angle, currVertex); result.AddVertex (offsetedCoord.x, offsetedCoord.y, offsetedCoord.z); } diff --git a/src/geometry/ray.js b/src/geometry/ray.js index 984b1b8c..a3bc871d 100644 --- a/src/geometry/ray.js +++ b/src/geometry/ray.js @@ -9,7 +9,7 @@ JSM.Ray = function (origin, direction, length) { this.origin = origin; - this.direction = JSM.VectorNormalize (direction); + this.direction = direction.Normalize (); this.length = length; }; @@ -24,7 +24,7 @@ JSM.Ray = function (origin, direction, length) JSM.Ray.prototype.Set = function (origin, direction, length) { this.origin = origin; - this.direction = JSM.VectorNormalize (direction); + this.direction = direction.Normalize (); this.length = length; }; diff --git a/src/geometry/sector.js b/src/geometry/sector.js index ef552936..4590657a 100644 --- a/src/geometry/sector.js +++ b/src/geometry/sector.js @@ -81,7 +81,7 @@ JSM.Sector.prototype.Set = function (beg, end) */ JSM.Sector.prototype.GetLength = function () { - return JSM.CoordDistance (this.beg, this.end); + return this.beg.DistanceTo (this.end); }; /** diff --git a/src/geometry/sectorutils.js b/src/geometry/sectorutils.js index 863472a8..0a8984df 100644 --- a/src/geometry/sectorutils.js +++ b/src/geometry/sectorutils.js @@ -76,7 +76,8 @@ JSM.ProjectCoordToSector2D = function (coord, sector) return end; } - var dir = JSM.CoordSub2D (end, beg).MultiplyScalar (u); + var dir = JSM.CoordSub2D (end, beg); + dir.MultiplyScalar (u); var result = JSM.CoordAdd2D (beg, dir); return result; }; @@ -108,15 +109,16 @@ JSM.CoordSectorPosition = function (coord, sector) var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); if (JSM.IsZero (denom)) { - if (JSM.CoordIsEqual (a, coord)) { + if (a.IsEqual (coord)) { return 'CoordOnSectorEndCoord'; } return 'CoordOutsideOfSector'; } var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var c = JSM.CoordAdd (a, JSM.VectorMultiply (b, u)); - var distance = JSM.CoordDistance (coord, c); + var bu = b.Clone ().MultiplyScalar (u); + var c = JSM.CoordAdd (a, bu); + var distance = coord.DistanceTo (c); if (JSM.IsZero (distance)) { if (JSM.IsLower (u, 0.0) || JSM.IsGreater (u, 1.0)) { return 'CoordOutsideOfSector'; @@ -213,13 +215,14 @@ JSM.SectorSectorPosition2D = function (aSector, bSector, intersection) JSM.GetSectorSegmentation = function (sector, segmentation, coords) { var direction = JSM.CoordSub (sector.end, sector.beg); - var length = JSM.CoordDistance (sector.beg, sector.end); + var length = sector.beg.DistanceTo (sector.end); var step = length / segmentation; var distance = 0.0; - var i; + var i, offseted; for (i = 0; i <= segmentation; i++) { - coords.push (JSM.CoordOffset (sector.beg, direction, distance)); + offseted = sector.beg.Clone ().Offset (direction, distance); + coords.push (offseted); distance += step; } }; diff --git a/src/geometry/transformationutils.js b/src/geometry/transformationutils.js index b1f6356f..b94ed15d 100644 --- a/src/geometry/transformationutils.js +++ b/src/geometry/transformationutils.js @@ -37,8 +37,8 @@ JSM.TranslationTransformation = function (translation) */ JSM.OffsetTransformation = function (direction, distance) { - var normal = JSM.VectorNormalize (direction); - var translation = JSM.VectorMultiply (normal, distance); + var normal = direction.Clone ().Normalize (); + var translation = normal.Clone ().MultiplyScalar (distance); return JSM.TranslationTransformation (translation); }; diff --git a/src/geometry/utilities.js b/src/geometry/utilities.js index f584bac8..49dcaa0d 100644 --- a/src/geometry/utilities.js +++ b/src/geometry/utilities.js @@ -90,14 +90,14 @@ JSM.GetRuledMesh = function (aCoords, bCoords, segmentation, vertices, polygons) var i, j; for (i = 0; i <= lineSegmentation; i++) { directions.push (JSM.CoordSub (bCoords[i], aCoords[i])); - lengths.push (JSM.CoordDistance (aCoords[i], bCoords[i])); + lengths.push (aCoords[i].DistanceTo (bCoords[i])); } var step, coord; for (i = 0; i <= lineSegmentation; i++) { step = lengths[i] / meshSegmentation; for (j = 0; j <= meshSegmentation; j++) { - coord = JSM.CoordOffset (aCoords[i], directions[i], step * j); + coord = aCoords[i].Clone ().Offset (directions[i], step * j); vertices.push (coord); } } diff --git a/src/import/importerstl.js b/src/import/importerstl.js index 1727abd2..fb1fbb93 100644 --- a/src/import/importerstl.js +++ b/src/import/importerstl.js @@ -150,7 +150,7 @@ JSM.ConvertStlToJsonData = function (arrayBuffer, stringBuffer) var v0Index = currentBody.AddVertex (v0[0], v0[1], v0[2]); var v1Index = currentBody.AddVertex (v1[0], v1[1], v1[2]); var v2Index = currentBody.AddVertex (v2[0], v2[1], v2[2]); - var triangleNormal = JSM.VectorNormalize (new JSM.Vector (normal[0], normal[1], normal[2])); + var triangleNormal = new JSM.Vector (normal[0], normal[1], normal[2]).Normalize (); var normalIndex = currentBody.AddNormal (triangleNormal.x, triangleNormal.y, triangleNormal.z); currentBody.AddTriangle (v0Index, v1Index, v2Index, normalIndex, normalIndex, normalIndex); } @@ -161,7 +161,7 @@ JSM.ConvertStlToJsonData = function (arrayBuffer, stringBuffer) var v0Index = currentBody.AddVertex (v0[0], v0[1], v0[2]); var v1Index = currentBody.AddVertex (v1[0], v1[1], v1[2]); var v2Index = currentBody.AddVertex (v2[0], v2[1], v2[2]); - var triangleNormal = JSM.VectorNormalize (new JSM.Vector (normal[0], normal[1], normal[2])); + var triangleNormal = new JSM.Vector (normal[0], normal[1], normal[2]).Normalize (); var normalIndex = currentBody.AddNormal (triangleNormal.x, triangleNormal.y, triangleNormal.z); currentBody.AddTriangle (v0Index, v1Index, v2Index, normalIndex, normalIndex, normalIndex); } diff --git a/src/modeler/body.js b/src/modeler/body.js index 5b6a41e4..13f45863 100644 --- a/src/modeler/body.js +++ b/src/modeler/body.js @@ -452,8 +452,8 @@ JSM.Body.prototype.SetCylindricalTextureProjection = function (origo, radius, xD this.SetTextureProjectionType ('Cylindrical'); this.SetTextureProjectionCoords (new JSM.CoordSystem ( origo, - JSM.VectorSetLength (xDirection, radius), - JSM.VectorSetLength (JSM.VectorCross (zDirection, xDirection), radius), + xDirection.Clone ().SetLength (radius), + JSM.VectorCross (zDirection, xDirection).SetLength (radius), zDirection )); }; @@ -531,7 +531,7 @@ JSM.Body.prototype.GetBoundingSphere = function () var i, current; for (i = 0; i < this.vertices.length; i++) { - current = JSM.CoordDistance (center, this.vertices[i].position); + current = center.DistanceTo (this.vertices[i].position); if (JSM.IsGreater (current, radius)) { radius = current; } @@ -547,8 +547,8 @@ JSM.Body.prototype.GetBoundingSphere = function () */ JSM.Body.prototype.OffsetToOrigo = function () { - var center = this.GetCenter (); - center = JSM.VectorMultiply (center, -1.0); + var center = this.GetCenter ().Clone (); + center.MultiplyScalar (-1.0); var i; for (i = 0; i < this.vertices.length; i++) { diff --git a/src/modeler/bodyutils.js b/src/modeler/bodyutils.js index 94db0ac6..93889972 100644 --- a/src/modeler/bodyutils.js +++ b/src/modeler/bodyutils.js @@ -54,8 +54,8 @@ JSM.CalculateBodyPolygonNormal = function (body, index) } } - var normalized = JSM.VectorNormalize (normal); - return normalized; + normal.Normalize (); + return normal; }; /** @@ -117,8 +117,8 @@ JSM.CalculateBodyVertexNormals = function (body) } } - average = JSM.VectorMultiply (average, 1.0 / count); - average = JSM.VectorNormalize (average); + average.MultiplyScalar (1.0 / count); + average.Normalize (); result[i].push (average); } } else { @@ -164,25 +164,22 @@ JSM.MakeBodyInsideOut = function (body) */ JSM.SoftMoveBodyVertex = function (body, index, radius, direction, distance) { - var referenceCoord = body.GetVertex (index).position; + var referenceCoord = body.GetVertexPosition (index).Clone (); var eps = 0.00001; var a = distance; var b = 0.0; var c = JSM.GetGaussianCParameter (radius, a, b, eps); - var i, x, currentDistance, newDistance, currentCoord; + var i, currentDistance, newDistance; for (i = 0; i < body.VertexCount (); i++) { - currentDistance = JSM.CoordDistance (referenceCoord, body.GetVertex (i).position); + currentDistance = referenceCoord.DistanceTo (body.GetVertex (i).position); if (JSM.IsGreater (currentDistance, radius)) { continue; } - x = currentDistance; - newDistance = JSM.GetGaussianValue (x, distance, b, c); - - currentCoord = body.GetVertex (i).position; - body.GetVertex (i).position = JSM.CoordOffset (currentCoord, direction, newDistance); + newDistance = JSM.GetGaussianValue (currentDistance, distance, b, c); + body.GetVertexPosition (i).Offset (direction, newDistance); } }; @@ -206,7 +203,7 @@ JSM.CalculatePolygonCentroid = function (body, index) result = JSM.CoordAdd (result, body.GetVertexPosition (polygon.GetVertexIndex (i))); } - result = JSM.VectorMultiply (result, 1.0 / count); + result.MultiplyScalar (1.0 / count); return result; }; diff --git a/src/modeler/cututils.js b/src/modeler/cututils.js index 642c08f6..7a3bec9e 100644 --- a/src/modeler/cututils.js +++ b/src/modeler/cututils.js @@ -19,7 +19,7 @@ JSM.CutBodyByPlane = function (body, plane) function AddIntersectionVertex (from, to) { - direction = JSM.VectorNormalize (JSM.CoordSub (polygon[to], polygon[from])); + direction = JSM.CoordSub (polygon[to], polygon[from]).Normalize (); line = new JSM.Line (polygon[from], direction); intersection = JSM.LinePlaneIntersection (line, plane); rawResult.push (new JSM.Coord (intersection.x, intersection.y, intersection.z)); @@ -89,7 +89,7 @@ JSM.CutBodyByPlane = function (body, plane) for (i = 0; i < rawResult.length; i++) { currentVertex = rawResult[i]; lastVertex = result[result.length - 1]; - if (i === 0 || !JSM.CoordIsEqual (lastVertex, currentVertex)) { + if (i === 0 || !lastVertex.IsEqual (currentVertex)) { result.push (new JSM.Coord (currentVertex.x, currentVertex.y, currentVertex.z)); if (hasIndexTable) { currentIndex = rawIndexTable[i]; @@ -117,7 +117,7 @@ JSM.CutBodyByPlane = function (body, plane) var i; for (i = originalVertexCount; i < result.VertexCount (); i++) { - if (JSM.CoordIsEqual (result.GetVertexPosition (i), vertex)) { + if (vertex.IsEqual (result.GetVertexPosition (i))) { index = i; break; } diff --git a/src/modeler/generator.js b/src/modeler/generator.js index b1099a9c..0c1b383b 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -492,19 +492,19 @@ JSM.GenerateTriangulatedSphere = function (radius, iterations, isCurved) var result = GenerateIcosahedron (); - var currentRadius = JSM.VectorLength (result.GetVertexPosition (0)); + var currentRadius = result.GetVertexPosition (0).Length (); var scale = radius / currentRadius; var i, j, vertex; for (i = 0; i < result.VertexCount (); i++) { vertex = result.GetVertex (i); - vertex.SetPosition (JSM.VectorMultiply (vertex.GetPosition (), scale)); + vertex.position.MultiplyScalar (scale); } var iteration, oldVertexCoord, oldBody, adjacencyInfo; var currentEdge, edgeVertexIndices; var currentPgon, polygonVertexIndices; - var midCoord, edgeCoord, currentPolyEdge; + var edgeCoord, currentPolyEdge; for (iteration = 0; iteration < iterations; iteration++) { oldBody = result; @@ -518,9 +518,8 @@ JSM.GenerateTriangulatedSphere = function (radius, iterations, isCurved) edgeVertexIndices = []; for (i = 0; i < adjacencyInfo.edges.length; i++) { currentEdge = adjacencyInfo.edges[i]; - midCoord = JSM.MidCoord (oldBody.GetVertexPosition (currentEdge.vert1), oldBody.GetVertexPosition (currentEdge.vert2)); - edgeCoord = JSM.VectorMultiply (JSM.VectorNormalize (midCoord), radius); - edgeVertexIndices.push (result.AddVertex (new JSM.BodyVertex (edgeCoord))); + edgeCoord = JSM.MidCoord (oldBody.GetVertexPosition (currentEdge.vert1), oldBody.GetVertexPosition (currentEdge.vert2)); + edgeVertexIndices.push (result.AddVertex (new JSM.BodyVertex (edgeCoord.SetLength (radius)))); } for (i = 0; i < adjacencyInfo.pgons.length; i++) { @@ -796,7 +795,7 @@ JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom) var i; for (i = 0; i < count; i++) { result.AddVertex (new JSM.BodyVertex (basePolygon[i])); - result.AddVertex (new JSM.BodyVertex (JSM.CoordOffset (basePolygon[i], direction, height))); + result.AddVertex (new JSM.BodyVertex (basePolygon[i].Clone ().Offset (direction, height))); } var current, next; @@ -820,9 +819,9 @@ JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom) result.AddPolygon (bottomPolygon); } - var firstDirection = JSM.VectorNormalize (JSM.CoordSub (basePolygon[1], basePolygon[0])); + var firstDirection = JSM.CoordSub (basePolygon[1], basePolygon[0]).Normalize (); var origo = new JSM.Coord (basePolygon[0].x, basePolygon[0].y, basePolygon[0].z); - var e3 = JSM.VectorNormalize (direction); + var e3 = direction.Clone ().Normalize (); var e2 = JSM.VectorCross (e3, firstDirection); var e1 = JSM.VectorCross (e2, e3); @@ -883,7 +882,7 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd for (i = 0; i < basePolygon.length; i++) { if (basePolygon[i] !== null) { result.AddVertex (new JSM.BodyVertex (basePolygon[i])); - result.AddVertex (new JSM.BodyVertex (JSM.CoordOffset (basePolygon[i], direction, height))); + result.AddVertex (new JSM.BodyVertex (basePolygon[i].Clone ().Offset (direction, height))); } } } @@ -979,9 +978,9 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd AddTopBottomPolygons (); } - var firstDirection = JSM.VectorNormalize (JSM.CoordSub (basePolygon[1], basePolygon[0])); + var firstDirection = JSM.CoordSub (basePolygon[1], basePolygon[0]).Normalize (); var origo = new JSM.Coord (basePolygon[0].x, basePolygon[0].y, basePolygon[0].z); - var e3 = JSM.VectorNormalize (direction); + var e3 = direction.Clone ().Normalize (); var e2 = JSM.VectorCross (e3, firstDirection); var e1 = JSM.VectorCross (e2, e3); @@ -1056,12 +1055,12 @@ JSM.GeneratePrismShell = function (basePolygon, direction, height, width, withTo var offseted; for (i = 0; i < count; i++) { - offseted = JSM.CoordOffset (basePolygon[i], direction, height); + offseted = basePolygon[i].Clone ().Offset (direction, height); result.AddVertex (new JSM.BodyVertex (offseted)); } for (i = 0; i < count; i++) { - offseted = JSM.CoordOffset (innerBasePolygon[i], direction, height); + offseted = innerBasePolygon[i].Clone ().Offset (direction, height); result.AddVertex (new JSM.BodyVertex (offseted)); } @@ -1094,9 +1093,9 @@ JSM.GeneratePrismShell = function (basePolygon, direction, height, width, withTo } } - var firstDirection = JSM.VectorNormalize (JSM.CoordSub (basePolygon[1], basePolygon[0])); + var firstDirection = JSM.CoordSub (basePolygon[1], basePolygon[0]).Normalize (); var origo = new JSM.Coord (basePolygon[0].x, basePolygon[0].y, basePolygon[0].z); - var e3 = JSM.VectorNormalize (direction); + var e3 = direction.Clone ().Normalize (); var e2 = JSM.VectorCross (e3, firstDirection); var e1 = JSM.VectorCross (e2, e3); @@ -1181,7 +1180,7 @@ JSM.GenerateLineShell = function (basePolyLine, direction, height, width, withSt nextDir = JSM.CoordSub (basePolyLine[next], basePolyLine[curr]); prevDir = JSM.CoordSub (basePolyLine[prev], basePolyLine[curr]); angle = JSM.GetVectorsAngle (nextDir, prevDir) / 2.0; - if (JSM.CoordTurnType (basePolyLine[prev], basePolyLine[curr], basePolyLine[next], direction) === 'Clockwise') { + if (JSM.CoordOrientation (basePolyLine[prev], basePolyLine[curr], basePolyLine[next], direction) == JSM.Orientation.Clockwise) { angle = Math.PI - angle; } } @@ -1203,8 +1202,9 @@ JSM.GenerateLineShell = function (basePolyLine, direction, height, width, withSt angle = angles[curr]; distance = width / Math.sin (angle); - innerCoord = JSM.CoordOffset (basePolyLine[curr], offsetDirection, distance); - innerCoord = JSM.CoordRotate (innerCoord, normal, -(Math.PI - angle), basePolyLine[curr]); + innerCoord = basePolyLine[curr].Clone (); + innerCoord.Offset (offsetDirection, distance); + innerCoord.Rotate (normal, -(Math.PI - angle), basePolyLine[curr]); innerBasePolyLine.push (innerCoord); } @@ -1218,12 +1218,12 @@ JSM.GenerateLineShell = function (basePolyLine, direction, height, width, withSt var offseted; for (i = 0; i < count; i++) { - offseted = JSM.CoordOffset (basePolyLine[i], direction, height); + offseted = basePolyLine[i].Clone ().Offset (direction, height); result.AddVertex (new JSM.BodyVertex (offseted)); } for (i = 0; i < count; i++) { - offseted = JSM.CoordOffset (innerBasePolyLine[i], direction, height); + offseted = innerBasePolyLine[i].Clone ().Offset (direction, height); result.AddVertex (new JSM.BodyVertex (offseted)); } @@ -1262,9 +1262,9 @@ JSM.GenerateLineShell = function (basePolyLine, direction, height, width, withSt } } - var firstDirection = JSM.VectorNormalize (JSM.CoordSub (basePolyLine[1], basePolyLine[0])); + var firstDirection = JSM.CoordSub (basePolyLine[1], basePolyLine[0]).Normalize (); var origo = new JSM.Coord (basePolyLine[0].x, basePolyLine[0].y, basePolyLine[0].z); - var e3 = JSM.VectorNormalize (direction); + var e3 = direction.Clone ().Normalize (); var e2 = JSM.VectorCross (e3, firstDirection); var e1 = JSM.VectorCross (e2, e3); @@ -1308,7 +1308,7 @@ JSM.GenerateTorus = function (outerRadius, innerRadius, outerSegmentation, inner var j, rotated; for (i = 0; i < outerSegmentation; i++) { for (j = 0; j < innerSegmentation; j++) { - rotated = JSM.CoordRotate (circle[j], axisDir, i * step, origo); + rotated = circle[j].Clone ().Rotate (axisDir, i * step, origo); result.AddVertex (new JSM.BodyVertex (rotated)); } } @@ -1383,7 +1383,7 @@ JSM.GeneratePolyTorus = function (basePolygon, outerRadius, outerSegmentation, i var j, rotated; for (i = 0; i < outerSegmentation; i++) { for (j = 0; j < innerSegmentation; j++) { - rotated = JSM.CoordRotate (circle[j], axisDir, i * step, origo); + rotated = circle[j].Clone ().Rotate (axisDir, i * step, origo); result.AddVertex (new JSM.BodyVertex (rotated)); } } @@ -1678,7 +1678,7 @@ JSM.GenerateRevolved = function (polyLine, axis, angle, segmentation, withTopAnd continue; } - rotated = JSM.CoordRotate (polyLine[i], axisDir, j * step, axis.beg); + rotated = polyLine[i].Clone ().Rotate (axisDir, j * step, axis.beg); result.AddVertex (new JSM.BodyVertex (rotated)); } } @@ -1730,22 +1730,22 @@ JSM.GenerateRevolved = function (polyLine, axis, angle, segmentation, withTopAnd result.AddPolygon (bottomPolygon); } - var axisLine = new JSM.Line (axis.beg, JSM.VectorNormalize (axisDir)); + var axisNormalDir = axisDir.Clone ().Normalize (); + var axisLine = new JSM.Line (axis.beg, axisNormalDir); var avgRadius = 0.0; var projected; for (i = 0; i < count; i++) { projected = JSM.ProjectCoordToLine (polyLine[i], axisLine); - avgRadius = avgRadius + JSM.CoordDistance (projected, polyLine[i]); + avgRadius = avgRadius + projected.DistanceTo (polyLine[i]); } avgRadius = avgRadius / count; var origo = new JSM.Coord (axis.beg.x, axis.beg.y, axis.beg.z); - var cylinderNormal = JSM.VectorNormalize (axisDir); var baseLine = new JSM.Line (origo, axisDir); var projectedToBaseLine = JSM.ProjectCoordToLine (polyLine[0], baseLine); - var xDirection = JSM.VectorNormalize (JSM.CoordSub (polyLine[0], projectedToBaseLine)); + var xDirection = JSM.CoordSub (polyLine[0], projectedToBaseLine).Normalize (); - result.SetCylindricalTextureProjection (origo, avgRadius, xDirection, cylinderNormal); + result.SetCylindricalTextureProjection (origo, avgRadius, xDirection, axisNormalDir); return result; }; diff --git a/src/modeler/rayutils.js b/src/modeler/rayutils.js index 884a93fd..e38a5928 100644 --- a/src/modeler/rayutils.js +++ b/src/modeler/rayutils.js @@ -49,8 +49,9 @@ JSM.RayTriangleIntersection = function (ray, v0, v1, v2) return null; } + var scaledDirection = rayDirection.Clone ().MultiplyScalar (distance); var intersection = { - position : JSM.CoordAdd (rayOrigin, JSM.VectorMultiply (rayDirection, distance)), + position : JSM.CoordAdd (rayOrigin, scaledDirection), distance : distance }; return intersection; @@ -135,7 +136,7 @@ JSM.RayBoxIntersection = function (ray, min, max) } var intersectionCoord = JSM.CoordFromArray (xCoord); - var distance = JSM.CoordDistance (rayOriginVec, intersectionCoord); + var distance = rayOriginVec.DistanceTo (intersectionCoord); if (ray.IsLengthReached (distance)) { return null; } diff --git a/src/modeler/textureutils.js b/src/modeler/textureutils.js index cc79bf9a..d186e602 100644 --- a/src/modeler/textureutils.js +++ b/src/modeler/textureutils.js @@ -11,8 +11,8 @@ JSM.CalculatePlanarTextureCoord = function (coord, system) { var result = new JSM.Coord2D (0.0, 0.0); - var e1 = JSM.VectorNormalize (system.e1); - var e2 = JSM.VectorNormalize (system.e2); + var e1 = system.e1.Clone ().Normalize (); + var e2 = system.e2.Clone ().Normalize (); var e3 = JSM.VectorCross (system.e1, system.e2); var xyPlane = JSM.GetPlaneFromCoordAndDirection (system.origo, e3); @@ -40,9 +40,9 @@ JSM.CalculateCubicTextureCoord = function (coord, normal, system) { var result = new JSM.Coord2D (0.0, 0.0); - var e1 = JSM.VectorNormalize (system.e1); - var e2 = JSM.VectorNormalize (system.e2); - var e3 = JSM.VectorNormalize (system.e3); + var e1 = system.e1.Clone ().Normalize (); + var e2 = system.e2.Clone ().Normalize (); + var e3 = system.e3.Clone ().Normalize (); var correctPlane = -1; var maxProduct = 0.0; @@ -113,7 +113,7 @@ JSM.CalculateCylindricalTextureCoord = function (coord, normal, system) { var result = new JSM.Coord2D (0.0, 0.0); - var e3Direction = JSM.VectorNormalize (system.e3); + var e3Direction = system.e3.Clone ().Normalize (); if (JSM.VectorsAreCollinear (e3Direction, normal)) { result = JSM.CalculateCubicTextureCoord (coord, normal, system); return [result, 0.0]; @@ -123,10 +123,10 @@ JSM.CalculateCylindricalTextureCoord = function (coord, normal, system) var projectedCoord = JSM.ProjectCoordToLine (coord, baseLine); var projectedDistance = JSM.CoordSignedDistance (system.origo, projectedCoord, e3Direction); - var e1Direction = JSM.VectorNormalize (system.e1); + var e1Direction = system.e1.Clone ().Normalize (); var coordDirection = JSM.CoordSub (coord, projectedCoord); var angle = JSM.GetVectorsFullAngle (coordDirection, e1Direction, e3Direction); - var radius = JSM.VectorLength (system.e1); + var radius = system.e1.Length (); result.x = angle * radius; result.y = projectedDistance; @@ -208,7 +208,7 @@ JSM.CalculatePolygonCylindricalTextureCoords = function (body, index, normal) angles.push (textureValues[1]); } - var e3Direction = JSM.VectorNormalize (system.e3); + var e3Direction = system.e3.Clone ().Normalize (); if (JSM.VectorsAreCollinear (e3Direction, normal)) { return result; } @@ -227,7 +227,7 @@ JSM.CalculatePolygonCylindricalTextureCoords = function (body, index, normal) } if (needRepair) { - var radius = JSM.VectorLength (system.e1); + var radius = system.e1.Length (); for (i = 0; i < angles.length; i++) { if (JSM.IsLower (angles[i], Math.PI)) { result[i].x = radius * (angles[i] + 2.0 * Math.PI); diff --git a/src/modeler/trianglebody.js b/src/modeler/trianglebody.js index 49dc9031..0655d6da 100644 --- a/src/modeler/trianglebody.js +++ b/src/modeler/trianglebody.js @@ -310,7 +310,7 @@ JSM.TriangleBody.prototype.GetBoundingSphere = function () var i, current; for (i = 0; i < this.vertices.length; i++) { - current = JSM.CoordDistance (center, this.vertices[i]); + current = center.DistanceTo (this.vertices[i]); if (JSM.IsGreater (current, radius)) { radius = current; } @@ -349,8 +349,8 @@ JSM.TriangleBody.prototype.Finalize = function (model) } } - averageNormal = JSM.VectorMultiply (averageNormal, 1.0 / averageCount); - averageNormal = JSM.VectorNormalize (averageNormal); + averageNormal.MultiplyScalar (1.0 / averageCount); + averageNormal.Normalize (); return body.AddNormal (averageNormal.x, averageNormal.y, averageNormal.z); } diff --git a/src/renderer/renderer.js b/src/renderer/renderer.js index af6aaa46..0b94920d 100644 --- a/src/renderer/renderer.js +++ b/src/renderer/renderer.js @@ -447,7 +447,7 @@ JSM.Renderer.prototype.Render = function () var lightAmbient = JSM.HexColorToNormalizedRGBComponents (this.light.ambient); var lightDiffuse = JSM.HexColorToNormalizedRGBComponents (this.light.diffuse); var lightSpecular = JSM.HexColorToNormalizedRGBComponents (this.light.specular); - this.light.direction = JSM.VectorNormalize (JSM.CoordSub (this.camera.center, this.camera.eye)); + this.light.direction = JSM.CoordSub (this.camera.center, this.camera.eye).Normalize (); var i, ambientColor, diffuseColor, specularColor, shininess; var currentGeometry, currentVertexBuffer, currentNormalBuffer, currentUVBuffer; diff --git a/src/three/threeviewer.js b/src/three/threeviewer.js index 17b9ae0f..1148738e 100644 --- a/src/three/threeviewer.js +++ b/src/three/threeviewer.js @@ -359,7 +359,7 @@ JSM.ThreeViewer.prototype.GetBoundingSphere = function () for (j = 0; j < geometry.vertices.length; j++) { coord = geometry.vertices[j].clone (); coord.add (current.position); - distance = JSM.CoordDistance (center, new JSM.Coord (coord.x, coord.y, coord.z)); + distance = center.DistanceTo (new JSM.Coord (coord.x, coord.y, coord.z)); if (JSM.IsGreater (distance, radius)) { radius = distance; } diff --git a/src/viewer/navigation.js b/src/viewer/navigation.js index f8496390..17f5d1eb 100644 --- a/src/viewer/navigation.js +++ b/src/viewer/navigation.js @@ -105,14 +105,14 @@ JSM.Navigation.prototype.FitInWindow = function (center, radius) this.camera.center = center; this.camera.eye = JSM.CoordSub (this.camera.eye, offsetToOrigo); - var centerEyeDirection = JSM.VectorNormalize (JSM.CoordSub (this.camera.eye, this.camera.center)); + var centerEyeDirection = JSM.CoordSub (this.camera.eye, this.camera.center).Normalize (); var fieldOfView = this.camera.fieldOfView / 2.0; if (this.canvas.width < this.canvas.height) { fieldOfView = fieldOfView * this.canvas.width / this.canvas.height; } var distance = radius / Math.sin (fieldOfView * JSM.DegRad); - this.camera.eye = JSM.CoordOffset (this.camera.center, centerEyeDirection, distance); + this.camera.eye = this.camera.center.Clone ().Offset (centerEyeDirection, distance); this.orbitCenter = this.camera.center.Clone (); }; @@ -121,30 +121,30 @@ JSM.Navigation.prototype.Orbit = function (angleX, angleY) var radAngleX = angleX * JSM.DegRad; var radAngleY = angleY * JSM.DegRad; - var viewDirection = JSM.VectorNormalize (JSM.CoordSub (this.camera.center, this.camera.eye)); - var horizontalDirection = JSM.VectorNormalize (JSM.VectorCross (viewDirection, this.camera.up)); - var differentCenter = !JSM.CoordIsEqual (this.orbitCenter, this.camera.center); + var viewDirection = JSM.CoordSub (this.camera.center, this.camera.eye).Normalize (); + var horizontalDirection = JSM.VectorCross (viewDirection, this.camera.up).Normalize (); + var differentCenter = !this.orbitCenter.IsEqual (this.camera.center); if (this.cameraFixUp) { var originalAngle = JSM.GetVectorsAngle (viewDirection, this.camera.up); var newAngle = originalAngle + radAngleY; if (JSM.IsGreater (newAngle, 0.0) && JSM.IsLower (newAngle, Math.PI)) { - this.camera.eye = JSM.CoordRotate (this.camera.eye, horizontalDirection, -radAngleY, this.orbitCenter); + this.camera.eye.Rotate (horizontalDirection, -radAngleY, this.orbitCenter); if (differentCenter) { - this.camera.center = JSM.CoordRotate (this.camera.center, horizontalDirection, -radAngleY, this.orbitCenter); + this.camera.center.Rotate (horizontalDirection, -radAngleY, this.orbitCenter); } } - this.camera.eye = JSM.CoordRotate (this.camera.eye, this.camera.up, -radAngleX, this.orbitCenter); + this.camera.eye.Rotate (this.camera.up, -radAngleX, this.orbitCenter); if (differentCenter) { - this.camera.center = JSM.CoordRotate (this.camera.center, this.camera.up, -radAngleX, this.orbitCenter); + this.camera.center.Rotate (this.camera.up, -radAngleX, this.orbitCenter); } } else { - var verticalDirection = JSM.VectorNormalize (JSM.VectorCross (horizontalDirection, viewDirection)); - this.camera.eye = JSM.CoordRotate (this.camera.eye, horizontalDirection, -radAngleY, this.orbitCenter); - this.camera.eye = JSM.CoordRotate (this.camera.eye, verticalDirection, -radAngleX, this.orbitCenter); + var verticalDirection = JSM.VectorCross (horizontalDirection, viewDirection).Normalize (); + this.camera.eye.Rotate (horizontalDirection, -radAngleY, this.orbitCenter); + this.camera.eye.Rotate (verticalDirection, -radAngleX, this.orbitCenter); if (differentCenter) { - this.camera.center = JSM.CoordRotate (this.camera.center, horizontalDirection, -radAngleY, this.orbitCenter); - this.camera.center = JSM.CoordRotate (this.camera.center, verticalDirection, -radAngleX, this.orbitCenter); + this.camera.center.Rotate (horizontalDirection, -radAngleY, this.orbitCenter); + this.camera.center.Rotate (verticalDirection, -radAngleX, this.orbitCenter); } this.camera.up = verticalDirection; } @@ -152,21 +152,21 @@ JSM.Navigation.prototype.Orbit = function (angleX, angleY) JSM.Navigation.prototype.Pan = function (moveX, moveY) { - var viewDirection = JSM.VectorNormalize (JSM.CoordSub (this.camera.center, this.camera.eye)); - var horizontalDirection = JSM.VectorNormalize (JSM.VectorCross (viewDirection, this.camera.up)); - var verticalDirection = JSM.VectorNormalize (JSM.VectorCross (horizontalDirection, viewDirection)); + var viewDirection = JSM.CoordSub (this.camera.center, this.camera.eye).Normalize (); + var horizontalDirection = JSM.VectorCross (viewDirection, this.camera.up).Normalize (); + var verticalDirection = JSM.VectorCross (horizontalDirection, viewDirection).Normalize (); - this.camera.eye = JSM.CoordOffset (this.camera.eye, horizontalDirection, -moveX); - this.camera.center = JSM.CoordOffset (this.camera.center, horizontalDirection, -moveX); + this.camera.eye.Offset (horizontalDirection, -moveX); + this.camera.center.Offset (horizontalDirection, -moveX); - this.camera.eye = JSM.CoordOffset (this.camera.eye, verticalDirection, moveY); - this.camera.center = JSM.CoordOffset (this.camera.center, verticalDirection, moveY); + this.camera.eye.Offset (verticalDirection, moveY); + this.camera.center.Offset (verticalDirection, moveY); }; JSM.Navigation.prototype.Zoom = function (zoomIn) { var direction = JSM.CoordSub (this.camera.center, this.camera.eye); - var distance = JSM.VectorLength (direction); + var distance = direction.Length (); if (zoomIn && distance < this.cameraNearDistanceLimit) { return 0; } else if (!zoomIn && distance > this.cameraFarDistanceLimit) { @@ -178,7 +178,7 @@ JSM.Navigation.prototype.Zoom = function (zoomIn) move = move * -1.0; } - this.camera.eye = JSM.CoordOffset (this.camera.eye, direction, move); + this.camera.eye.Offset (direction, move); }; JSM.Navigation.prototype.DrawCallback = function () @@ -223,7 +223,7 @@ JSM.Navigation.prototype.OnMouseMove = function (event) return; } - var eyeCenterDistance = JSM.CoordDistance (this.camera.eye, this.camera.center); + var eyeCenterDistance = this.camera.eye.DistanceTo (this.camera.center); ratio = 0.001 * eyeCenterDistance; this.Pan (this.mouse.diffX * ratio, this.mouse.diffY * ratio); this.DrawCallback (); diff --git a/src/viewer/pointcloudviewer.js b/src/viewer/pointcloudviewer.js index b83a686c..84252a65 100644 --- a/src/viewer/pointcloudviewer.js +++ b/src/viewer/pointcloudviewer.js @@ -101,7 +101,7 @@ JSM.PointCloudViewer.prototype.GetBoundingSphere = function () points = this.renderer.points[i].pointArray; for (j = 0; j < points.length; j = j + 3) { point = new JSM.Coord (points[j], points[j + 1], points[j + 2]); - distance = JSM.CoordDistance (center, point); + distance = center.DistanceTo (point); if (JSM.IsGreater (distance, radius)) { radius = distance; } diff --git a/src/viewer/softwareviewer.js b/src/viewer/softwareviewer.js index dbf791bf..6cbbd133 100644 --- a/src/viewer/softwareviewer.js +++ b/src/viewer/softwareviewer.js @@ -113,7 +113,7 @@ JSM.SoftwareViewer.prototype.GetBoundingSphere = function () body = this.bodies[i][0]; for (j = 0; j < body.VertexCount (); j++) { vertex = body.GetVertex (j); - distance = JSM.CoordDistance (center, vertex.position); + distance = center.DistanceTo (vertex.position); if (JSM.IsGreater (distance, radius)) { radius = distance; } diff --git a/src/viewer/spriteviewer.js b/src/viewer/spriteviewer.js index 09386d24..93ae7389 100644 --- a/src/viewer/spriteviewer.js +++ b/src/viewer/spriteviewer.js @@ -150,7 +150,7 @@ JSM.SpriteViewer.prototype.GetBoundingSphere = function () var i, coord, distance; for (i = 0; i < this.points.length; i++) { coord = this.points[i]; - distance = JSM.CoordDistance (center, coord); + distance = center.DistanceTo (coord); if (JSM.IsGreater (distance, radius)) { radius = distance; } diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index a095bd8f..33b9321a 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -98,7 +98,7 @@ JSM.Viewer.prototype.GetBoundingSphere = function () geometry = this.renderer.geometries[i]; for (j = 0; j < geometry.VertexCount (); j = j + 1) { vertex = geometry.GetTransformedVertex (j); - distance = JSM.CoordDistance (center, vertex); + distance = center.DistanceTo (vertex); if (JSM.IsGreater (distance, radius)) { radius = distance; } diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index d3ebcb29..ce643c41 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -7,14 +7,13 @@ unitTest.AddSourceFile ('../../src/core/timer.js'); unitTest.AddSourceFile ('../../src/core/algorithm.js'); unitTest.AddSourceFile ('../../src/core/async.js'); unitTest.AddSourceFile ('../../src/core/check.js'); +unitTest.AddSourceFile ('../../src/geometry/definitions.js'); unitTest.AddSourceFile ('../../src/geometry/coord2d.js'); unitTest.AddSourceFile ('../../src/geometry/coord.js'); unitTest.AddSourceFile ('../../src/geometry/determinant.js'); -unitTest.AddSourceFile ('../../src/geometry/coordutils2d.js'); unitTest.AddSourceFile ('../../src/geometry/coordutils.js'); unitTest.AddSourceFile ('../../src/geometry/matrix.js'); unitTest.AddSourceFile ('../../src/geometry/coordsystem.js'); -unitTest.AddSourceFile ('../../src/geometry/coordsystemutils.js'); unitTest.AddSourceFile ('../../src/geometry/sector.js'); unitTest.AddSourceFile ('../../src/geometry/sectorutils.js'); unitTest.AddSourceFile ('../../src/geometry/line.js'); diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index edc1bc9a..b25faaac 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -20,30 +20,31 @@ generalSuite.AddTest ('Vector2DTest', function (test) { test.Assert (coord3.IsEqual (new JSM.Coord2D (10, 0))); test.Assert (coord5.IsEqual (new JSM.Coord2D (5, 0))); test.Assert (JSM.IsEqual (coord5.Length (), 5.0)); - var coord6 = JSM.CoordOffset2D (coord1, coord2, 3.0); + var coord6 = coord1.Clone ().Offset (coord2, 3.0); + test.Assert (coord1.IsEqual (new JSM.Coord2D (1, 0))); test.Assert (coord6.IsEqual (new JSM.Coord2D (1, 3))); var coord7 = coord3.Normalize (); test.Assert (coord3.IsEqual (new JSM.Coord2D (1, 0))); test.Assert (coord7.IsEqual (new JSM.Coord2D (1, 0))); var origo = new JSM.Coord2D (0.0, 0.0); - var rotated = JSM.CoordRotate2D (coord1, Math.PI / 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI / 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (0, 1))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI, origo); + var rotated = coord1.Clone ().Rotate (Math.PI, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, 0))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI * 3.0 / 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI * 3.0 / 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (0, -1))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI * 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI * 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (1, 0))); var origo = new JSM.Coord2D (-1.0, 0.0); - var rotated = JSM.CoordRotate2D (coord1, Math.PI / 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI / 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, 2))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI, origo); + var rotated = coord1.Clone ().Rotate (Math.PI, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (-3, 0))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI * 3.0 / 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI * 3.0 / 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (-1, -2))); - var rotated = JSM.CoordRotate2D (coord1, Math.PI * 2.0, origo); + var rotated = coord1.Clone ().Rotate (Math.PI * 2.0, origo); test.Assert (rotated.IsEqual (new JSM.Coord2D (1, 0))); }); @@ -55,61 +56,61 @@ generalSuite.AddTest ('VectorTest', function (test) { test.Assert (coord2d1.IsEqual (new JSM.Coord2D (1, 2))); test.Assert (JSM.MidCoord2D (coord2d1, coord2d2).IsEqual (new JSM.Coord2D (2, 3))); test.Assert (JSM.IsEqual (coord2d1.DistanceTo (coord2d2), 2.8284271247)); - test.Assert (JSM.CoordTurnType2D (coord2d1, coord2d2, coord2d3) == 'CounterClockwise'); + test.Assert (JSM.CoordOrientation2D (coord2d1, coord2d2, coord2d3) == JSM.Orientation.CounterClockwise); var coord1 = new JSM.Coord (1, 2, 3); var coord2 = new JSM.Coord (4, 5, 6); - test.Assert (JSM.CoordIsEqual (coord1, new JSM.Coord (1, 2, 3))); - test.Assert (JSM.CoordIsEqual (JSM.MidCoord (coord1, coord2), new JSM.Coord (2.5, 3.5, 4.5))); - test.Assert (JSM.CoordIsEqual (JSM.VectorMultiply (coord1, 3), new JSM.Coord (3, 6, 9))); + test.Assert (coord1.IsEqual (new JSM.Coord (1, 2, 3))); + test.Assert (JSM.MidCoord (coord1, coord2).IsEqual (new JSM.Coord (2.5, 3.5, 4.5))); + test.Assert (coord1.Clone ().MultiplyScalar (3).IsEqual (new JSM.Coord (3, 6, 9))); test.Assert (JSM.IsEqual (JSM.VectorDot (coord1, coord2), 32)); - test.Assert (JSM.CoordIsEqual (JSM.VectorCross (coord1, coord2), new JSM.Coord (-3, 6, -3))); - test.Assert (JSM.IsEqual (JSM.VectorLength (coord1), 3.7416573867)); - test.Assert (JSM.CoordIsEqual (JSM.VectorNormalize (coord1), new JSM.Coord (0.2672612419, 0.5345224838, 0.8017837257))); - test.Assert (JSM.IsEqual (JSM.VectorLength (JSM.VectorSetLength (coord1, 123)), 123)); - test.Assert (JSM.IsEqual (JSM.CoordDistance (coord1, coord2), 5.1961524227)); - test.Assert (JSM.CoordIsEqual (JSM.CoordAdd (coord1, coord2), new JSM.Coord (5, 7, 9))); - test.Assert (JSM.CoordIsEqual (JSM.CoordSub (coord1, coord2), new JSM.Coord (-3, -3, -3))); - test.Assert (JSM.CoordIsEqual (JSM.CoordOffset (coord2, coord1, 5.0), new JSM.Coord (5.3363062095, 7.672612419, 10.0089186285))); - - test.Assert (JSM.CoordIsEqual (JSM.CoordOffset (coord1, new JSM.Coord (1.0, 0.0, 0.0), 5.0), new JSM.Coord (6.0, 2.0, 3.0))); - test.Assert (JSM.CoordIsEqual (JSM.CoordOffset (coord1, new JSM.Coord (0.0, 1.0, 0.0), 5.0), new JSM.Coord (1.0, 7.0, 3.0))); - test.Assert (JSM.CoordIsEqual (JSM.CoordOffset (coord1, new JSM.Coord (0.0, 0.0, 1.0), 5.0), new JSM.Coord (1.0, 2.0, 8.0))); + test.Assert (JSM.VectorCross (coord1, coord2).IsEqual (new JSM.Coord (-3, 6, -3))); + test.Assert (JSM.IsEqual (coord1.Length (), 3.7416573867)); + test.Assert (coord1.Clone ().Normalize ().IsEqual (new JSM.Coord (0.2672612419, 0.5345224838, 0.8017837257))); + test.Assert (JSM.IsEqual (coord1.Clone ().SetLength (123).Length (), 123)); + test.Assert (JSM.IsEqual (coord1.DistanceTo (coord2), 5.1961524227)); + test.Assert (JSM.CoordAdd (coord1, coord2).IsEqual (new JSM.Coord (5, 7, 9))); + test.Assert (JSM.CoordSub (coord1, coord2).IsEqual (new JSM.Coord (-3, -3, -3))); + test.Assert (coord2.Clone ().Offset (coord1, 5.0).IsEqual (new JSM.Coord (5.3363062095, 7.672612419, 10.0089186285))); + + test.Assert (coord1.Clone ().Offset (new JSM.Coord (1.0, 0.0, 0.0), 5.0).IsEqual (new JSM.Coord (6.0, 2.0, 3.0))); + test.Assert (coord1.Clone ().Offset (new JSM.Coord (0.0, 1.0, 0.0), 5.0).IsEqual (new JSM.Coord (1.0, 7.0, 3.0))); + test.Assert (coord1.Clone ().Offset (new JSM.Coord (0.0, 0.0, 1.0), 5.0).IsEqual (new JSM.Coord (1.0, 2.0, 8.0))); var coord = new JSM.Coord (1.0, 1.0, 1.0); var direction = new JSM.Vector (1.0, 0.0, 0.0); - test.Assert (JSM.CoordIsEqual (JSM.CoordOffset (coord, direction, 1.0), new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (coord.Clone ().Offset (direction, 1.0).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); var coord = new JSM.Coord (1.0, 1.0, 1.0); var axis = new JSM.Vector (0.0, 0.0, 1.0); var origo = new JSM.Vector (0.0, 0.0, 0.0); var angle = 90.0 * JSM.DegRad; - test.Assert (JSM.CoordIsEqual (JSM.CoordRotate (coord, axis, angle, origo), new JSM.Coord (-1.0, 1.0, 1.0))); + test.Assert (coord.Clone ().Rotate (axis, angle, origo).IsEqual (new JSM.Coord (-1.0, 1.0, 1.0))); var vector1 = new JSM.Vector (1.0, 0.0, 0.0); var vector2 = new JSM.Vector (0.0, 1.0, 0.0); test.Assert (JSM.IsEqual (JSM.GetVectorsAngle (vector1, vector2), 90.0 * JSM.DegRad)); var vector = new JSM.Vector (1.0, 0.0, 0.0); - test.Assert (JSM.IsEqual (JSM.VectorLength (vector), 1.0)); + test.Assert (JSM.IsEqual (vector.Length (), 1.0)); var vector = new JSM.Vector (1.0, 2.0, 3.0); - var multiplied = JSM.VectorMultiply (vector, 2.0); - test.Assert (JSM.CoordIsEqual (multiplied, new JSM.Coord (2.0, 4.0, 6.0))); + var multiplied = vector.Clone ().MultiplyScalar (2.0); + test.Assert (multiplied.IsEqual (new JSM.Coord (2.0, 4.0, 6.0))); var vector = new JSM.Vector (10.0, 0.0, 0.0); - var normal = JSM.VectorNormalize (vector); - test.Assert (JSM.CoordIsEqual (normal, new JSM.Coord (1.0, 0.0, 0.0))); + var normal = vector.Clone ().Normalize (); + test.Assert (normal.IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); - var another = JSM.VectorSetLength (vector, 5.0); - test.Assert (JSM.CoordIsEqual (another, new JSM.Coord (5.0, 0.0, 0.0))); + var another = vector.Clone ().SetLength (5.0); + test.Assert (another.IsEqual (new JSM.Coord (5.0, 0.0, 0.0))); var cartesian = JSM.SphericalToCartesian (1.0, 0.0, 90.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (cartesian, new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (cartesian.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); var cartesian = JSM.CylindricalToCartesian (1.0, 1.0, 90.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (cartesian, new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (cartesian.IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); var coord = new JSM.Coord (1.0, 2.0, 3.0); var normal = new JSM.Coord (0.0, 1.0, 0.0); @@ -124,9 +125,9 @@ generalSuite.AddTest ('VectorTest', function (test) { new JSM.Coord (0.0, 1.0, 0.0) ]; var normal = JSM.CalculateNormal (coords); - test.Assert (JSM.CoordIsEqual (normal, new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (normal.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); var centroid = JSM.CalculateCentroid (coords); - test.Assert (JSM.CoordIsEqual (centroid, new JSM.Coord (0.5, 0.5, 0.0))); + test.Assert (centroid.IsEqual (new JSM.Coord (0.5, 0.5, 0.0))); var coords2 = [ new JSM.Coord (0.0, 0.0, 0.0), @@ -136,9 +137,9 @@ generalSuite.AddTest ('VectorTest', function (test) { new JSM.Coord (0.0, 1.0, 0.0) ]; var normal2 = JSM.CalculateNormal (coords2); - test.Assert (JSM.CoordIsEqual (normal2, new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (normal2.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); var centroid2 = JSM.CalculateCentroid (coords2); - test.Assert (JSM.CoordIsEqual (centroid2, new JSM.Coord (0.5, 0.5, 0.0))); + test.Assert (centroid2.IsEqual (new JSM.Coord (0.5, 0.5, 0.0))); var coords3 = [ new JSM.Coord (0.0, 1.0, 0.0), @@ -148,9 +149,9 @@ generalSuite.AddTest ('VectorTest', function (test) { new JSM.Coord (0.0, 0.0, 0.0) ]; var normal3 = JSM.CalculateNormal (coords3); - test.Assert (JSM.CoordIsEqual (normal3, new JSM.Coord (0.0, 0.0, -1.0))); + test.Assert (normal3.IsEqual (new JSM.Coord (0.0, 0.0, -1.0))); var centroid3 = JSM.CalculateCentroid (coords3); - test.Assert (JSM.CoordIsEqual (centroid3, new JSM.Coord (0.3, 0.5, 0.0))); + test.Assert (centroid3.IsEqual (new JSM.Coord (0.3, 0.5, 0.0))); var vector1 = new JSM.Vector (1.0, 0.0, 0.0); var vector2 = new JSM.Vector (0.0, 1.0, 0.0); @@ -164,17 +165,17 @@ generalSuite.AddTest ('VectorTest', function (test) { var normal2 = new JSM.Vector (0.0, 0.0, -1.0); var normal3 = new JSM.Vector (0.0, -1.0, -1.0); - test.Assert (JSM.CoordTurnType (coord1, coord2, coord3, normal1) == 'CounterClockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord2, normal1) == 'Clockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord3, normal1) == 'Collinear'); + test.Assert (JSM.CoordOrientation (coord1, coord2, coord3, normal1) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord2, normal1) == JSM.Orientation.Clockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord3, normal1) == JSM.Orientation.Invalid); - test.Assert (JSM.CoordTurnType (coord1, coord2, coord3, normal2) == 'Clockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord2, normal2) == 'CounterClockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord3, normal2) == 'Collinear'); + test.Assert (JSM.CoordOrientation (coord1, coord2, coord3, normal2) == JSM.Orientation.Clockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord2, normal2) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord3, normal2) == JSM.Orientation.Invalid); - test.Assert (JSM.CoordTurnType (coord1, coord2, coord3, normal3) == 'Clockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord2, normal3) == 'CounterClockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord3, normal3) == 'Collinear'); + test.Assert (JSM.CoordOrientation (coord1, coord2, coord3, normal3) == JSM.Orientation.Clockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord2, normal3) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord3, normal3) == JSM.Orientation.Invalid); var coord1 = new JSM.Vector (0.0, 0.0, 0.0); var coord2 = new JSM.Vector (1.0, 0.0, 0.0); @@ -182,13 +183,13 @@ generalSuite.AddTest ('VectorTest', function (test) { var normal1 = new JSM.Vector (0.0, 1.0, 0.0); var normal2 = new JSM.Vector (0.0, -1.0, 0.0); - test.Assert (JSM.CoordTurnType (coord1, coord2, coord3, normal2) == 'CounterClockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord2, normal2) == 'Clockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord3, normal2) == 'Collinear'); + test.Assert (JSM.CoordOrientation (coord1, coord2, coord3, normal2) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord2, normal2) == JSM.Orientation.Clockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord3, normal2) == JSM.Orientation.Invalid); - test.Assert (JSM.CoordTurnType (coord1, coord2, coord3, normal1) == 'Clockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord2, normal1) == 'CounterClockwise'); - test.Assert (JSM.CoordTurnType (coord1, coord3, coord3, normal1) == 'Collinear'); + test.Assert (JSM.CoordOrientation (coord1, coord2, coord3, normal1) == JSM.Orientation.Clockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord2, normal1) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.CoordOrientation (coord1, coord3, coord3, normal1) == JSM.Orientation.Invalid); var coord1 = new JSM.Vector (0.0, 0.0, 0.0); var coord2 = new JSM.Vector (1.0, 0.0, 0.0); @@ -203,23 +204,23 @@ generalSuite.AddTest ('VectorTest', function (test) { test.Assert (coord.IsEqualWithEps (new JSM.Coord2D (2.0, 2.0), 1.1)); var coord = new JSM.Coord (1.0, 2.0, 3.0); - test.Assert (!JSM.CoordIsEqualWithEps (coord, new JSM.Coord (1.0, 2.0, 4.0), 0.1)); - test.Assert (!JSM.CoordIsEqualWithEps (coord, new JSM.Coord (1.0, 3.0, 3.0), 0.1)); - test.Assert (!JSM.CoordIsEqualWithEps (coord, new JSM.Coord (2.0, 2.0, 3.0), 0.1)); - test.Assert (JSM.CoordIsEqualWithEps (coord, new JSM.Coord (1.0, 2.0, 4.0), 1.1)); - test.Assert (JSM.CoordIsEqualWithEps (coord, new JSM.Coord (1.0, 3.0, 3.0), 1.1)); - test.Assert (JSM.CoordIsEqualWithEps (coord, new JSM.Coord (2.0, 2.0, 3.0), 1.1)); + test.Assert (!coord.IsEqualWithEps (new JSM.Coord (1.0, 2.0, 4.0), 0.1)); + test.Assert (!coord.IsEqualWithEps (new JSM.Coord (1.0, 3.0, 3.0), 0.1)); + test.Assert (!coord.IsEqualWithEps (new JSM.Coord (2.0, 2.0, 3.0), 0.1)); + test.Assert (coord.IsEqualWithEps (new JSM.Coord (1.0, 2.0, 4.0), 1.1)); + test.Assert (coord.IsEqualWithEps (new JSM.Coord (1.0, 3.0, 3.0), 1.1)); + test.Assert (coord.IsEqualWithEps (new JSM.Coord (2.0, 2.0, 3.0), 1.1)); }); generalSuite.AddTest ('TriangleNormalTest', function (test) { - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 1.0, 0.0)), new JSM.Vector (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, -1.0, 0.0)), new JSM.Vector (0.0, 0.0, -1.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 1.0, 0.0)).IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, -1.0, 0.0)).IsEqual (new JSM.Vector (0.0, 0.0, -1.0))); - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 1.0, 1.0)), new JSM.Vector (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 1.0, -1.0)), new JSM.Vector (-1.0, 0.0, 0.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 1.0, 1.0)).IsEqual (new JSM.Vector (1.0, 0.0, 0.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 1.0, -1.0)).IsEqual (new JSM.Vector (-1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, -1.0)), new JSM.Vector (0.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 1.0)), new JSM.Vector (0.0, -1.0, 0.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, -1.0)).IsEqual (new JSM.Vector (0.0, 1.0, 0.0))); + test.Assert (JSM.CalculateTriangleNormal (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 1.0)).IsEqual (new JSM.Vector (0.0, -1.0, 0.0))); }); generalSuite.AddTest ('BarycentricInterpolation', function (test) { @@ -231,112 +232,23 @@ generalSuite.AddTest ('BarycentricInterpolation', function (test) { var value2 = new JSM.Coord (1, 1, 0); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (0, 0, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (0, 0, 0))); + test.Assert (result.IsEqual (new JSM.Coord (0, 0, 0))); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (0.6, 0.4, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (0.6, 0.4, 0))); + test.Assert (result.IsEqual (new JSM.Coord (0.6, 0.4, 0))); var value0 = new JSM.Coord (1, 1, 1); var value1 = new JSM.Coord (5, 5, 5); var value2 = new JSM.Coord (100, 100, 100); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (0, 0, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (1, 1, 1))); + test.Assert (result.IsEqual (new JSM.Coord (1, 1, 1))); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (1, 0, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (5, 5, 5))); + test.Assert (result.IsEqual (new JSM.Coord (5, 5, 5))); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (1, 1, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (100, 100, 100))); + test.Assert (result.IsEqual (new JSM.Coord (100, 100, 100))); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (0.5, 0.5, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (50.5, 50.5, 50.5))); + test.Assert (result.IsEqual (new JSM.Coord (50.5, 50.5, 50.5))); var result = JSM.BarycentricInterpolation (vertex0, vertex1, vertex2, value0, value1, value2, new JSM.Coord (0.8, 0.8, 0)); - test.Assert (JSM.CoordIsEqual (result, new JSM.Coord (80.2, 80.2, 80.2))); -}); - -generalSuite.AddTest ('SphericalTest', function (test) { - function TestConversion (x, y, z) { - var original = new JSM.Coord (x, y, z); - - var spherical = JSM.CartesianToSpherical (original.x, original.y, original.z); - var cartesian = JSM.SphericalToCartesian (spherical.radius, spherical.theta, spherical.phi); - test.Assert (JSM.CoordIsEqual (original, cartesian)); - - var origo = new JSM.Coord (1.0, 2.0, 3.0); - var spherical = JSM.CartesianToSphericalWithOrigo (original, origo); - var cartesian = JSM.SphericalToCartesianWithOrigo (spherical, origo); - test.Assert (JSM.CoordIsEqual (original, cartesian)); - } - - var x, y, z; - for (x = -1.0; x <= 1.0; x = x + 1.0) { - for (y = -1.0; y <= 1.0; y = y + 1.0) { - for (z = -1.0; z <= 1.0; z = z + 1.0) { - TestConversion (x, y, z); - } - } - } - - var coord = new JSM.Coord (1.0, 0.0, 0.0); - var origo = new JSM.Coord (0.0, 0.0, 0.0); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 45.0 * JSM.DegRad), new JSM.Coord (0.7071067811865569, 0.7071067811865381, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 90.0 * JSM.DegRad), new JSM.Coord (0.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 180.0 * JSM.DegRad), new JSM.Coord (-1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 270.0 * JSM.DegRad), new JSM.Coord (0.0, -1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 360.0 * JSM.DegRad), new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 450.0 * JSM.DegRad), new JSM.Coord (0.0, 1.0, 0.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -45.0 * JSM.DegRad), new JSM.Coord (0.7071067811865569, -0.7071067811865381, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -90.0 * JSM.DegRad), new JSM.Coord (0.0, -1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -180.0 * JSM.DegRad), new JSM.Coord (-1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -270.0 * JSM.DegRad), new JSM.Coord (0.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -360.0 * JSM.DegRad), new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, -450.0 * JSM.DegRad), new JSM.Coord (0.0, -1.0, 0.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 90.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, -1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 180.0 * JSM.DegRad, 0.0), new JSM.Coord (-1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 270.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 360.0 * JSM.DegRad, 0.0), new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 450.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, -1.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, -90.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, -180.0 * JSM.DegRad, 0.0), new JSM.Coord (-1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, -270.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, -1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, -360.0 * JSM.DegRad, 0.0), new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, -450.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, 1.0))); - - var coord = new JSM.Coord (2.0, 0.0, 0.0); - var origo = new JSM.Coord (1.0, 0.0, 0.0); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 0.0), new JSM.Coord (2.0, 0.0, 0.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 45.0 * JSM.DegRad), new JSM.Coord (1.7071067811865569, 0.7071067811865381, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 90.0 * JSM.DegRad), new JSM.Coord (1.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 180.0 * JSM.DegRad), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 270.0 * JSM.DegRad), new JSM.Coord (1.0, -1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 360.0 * JSM.DegRad), new JSM.Coord (2.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 0.0, 450.0 * JSM.DegRad), new JSM.Coord (1.0, 1.0, 0.0))); - - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 90.0 * JSM.DegRad, 0.0), new JSM.Coord (1.0, 0.0, -1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 180.0 * JSM.DegRad, 0.0), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 270.0 * JSM.DegRad, 0.0), new JSM.Coord (1.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 360.0 * JSM.DegRad, 0.0), new JSM.Coord (2.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.MoveCoordOnSphere (coord, origo, 450.0 * JSM.DegRad, 0.0), new JSM.Coord (1.0, 0.0, -1.0))); - - var current = new JSM.Coord (1.0, 0.0, 0.0); - var origo = new JSM.Coord (0.0, 0.0, 0.0); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (current, new JSM.Coord (0.0, 1.0, 0.0))); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (current, new JSM.Coord (-1.0, 0.0, 0.0))); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (current, new JSM.Coord (0.0, -1.0, 0.0))); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (current, new JSM.Coord (1.0, 0.0, 0.0))); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - current = JSM.MoveCoordOnSphere (current, origo, 0.0, 45.0 * JSM.DegRad); - test.Assert (JSM.CoordIsEqual (current, new JSM.Coord (0.0, 1.0, 0.0))); + test.Assert (result.IsEqual (new JSM.Coord (80.2, 80.2, 80.2))); }); generalSuite.AddTest ('CircleTest', function (test) { @@ -515,7 +427,7 @@ generalSuite.AddTest ('ArcLengthTest', function (test) { var origo = new JSM.Coord (0.0, 0.0, 0.0); test.Assert (JSM.IsEqual (JSM.GetVectorsFullAngle (v1, v2, normal), 0.0)); for (var i = 0.0; i < Math.PI; i = i + 5.0 * JSM.DegRad) { - test.Assert (JSM.IsEqual (JSM.GetVectorsFullAngle (JSM.CoordRotate (v1, normal, i, origo), v2, normal), i)); + test.Assert (JSM.IsEqual (JSM.GetVectorsFullAngle (v1.Clone ().Rotate (normal, i, origo), v2, normal), i)); } }); @@ -524,35 +436,35 @@ generalSuite.AddTest ('TransformationTest', function (test) { var coord = new JSM.Coord (1.0, 1.0, 1.0); var direction = new JSM.Vector (1.0, 0.0, 0.0); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); transformation = JSM.OffsetTransformation (direction, 1.0); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (1.0, 2.0, 3.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (2.0, 3.0, 4.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (2.0, 3.0, 4.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (1.0, 0.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (-1.0, 0.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (0.0, 1.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 2.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 2.0, 1.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (0.0, -1.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 0.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 0.0, 1.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (0.0, 0.0, 1.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 1.0, 2.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 1.0, 2.0))); transformation = JSM.TranslationTransformation (new JSM.Coord (0.0, 0.0, -1.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 1.0, 0.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); var axis = new JSM.Vector (0.0, 0.0, 1.0); var angle = 90.0 * JSM.DegRad; transformation = JSM.RotationTransformation (axis, angle); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (-1.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (-1.0, 1.0, 1.0))); transformation = JSM.RotationZTransformation (angle); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (-1.0, 1.0, 1.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (-1.0, 1.0, 1.0))); var trX = new JSM.RotationXTransformation (angle); var trY = new JSM.RotationYTransformation (angle); @@ -566,18 +478,18 @@ generalSuite.AddTest ('TransformationTest', function (test) { var trRotY = new JSM.RotationTransformation (axisY, angle); var trRotZ = new JSM.RotationTransformation (axisZ, angle); - test.Assert (JSM.CoordIsEqual (trX.Apply (coord), trRotX.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trY.Apply (coord), trRotY.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trZ.Apply (coord), trRotZ.Apply (coord))); + test.Assert (trX.Apply (coord).IsEqual (trRotX.Apply (coord))); + test.Assert (trY.Apply (coord).IsEqual (trRotY.Apply (coord))); + test.Assert (trZ.Apply (coord).IsEqual (trRotZ.Apply (coord))); var origo = new JSM.Coord (0.0, 0.0, 0.0); trRotX = new JSM.RotationTransformation (axisX, angle, origo); trRotY = new JSM.RotationTransformation (axisY, angle, origo); trRotZ = new JSM.RotationTransformation (axisZ, angle, origo); - test.Assert (JSM.CoordIsEqual (trX.Apply (coord), trRotX.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trY.Apply (coord), trRotY.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trZ.Apply (coord), trRotZ.Apply (coord))); + test.Assert (trX.Apply (coord).IsEqual (trRotX.Apply (coord))); + test.Assert (trY.Apply (coord).IsEqual (trRotY.Apply (coord))); + test.Assert (trZ.Apply (coord).IsEqual (trRotZ.Apply (coord))); var origo = new JSM.Coord (1.0, 2.0, 3.0); var trXOrigo = new JSM.RotationXTransformation (angle, origo); @@ -588,31 +500,31 @@ generalSuite.AddTest ('TransformationTest', function (test) { var trRotYOrigo = new JSM.RotationTransformation (axisY, angle, origo); var trRotZOrigo = new JSM.RotationTransformation (axisZ, angle, origo); - test.Assert (JSM.CoordIsEqual (trXOrigo.Apply (coord), trRotXOrigo.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trYOrigo.Apply (coord), trRotYOrigo.Apply (coord))); - test.Assert (JSM.CoordIsEqual (trZOrigo.Apply (coord), trRotZOrigo.Apply (coord))); + test.Assert (trXOrigo.Apply (coord).IsEqual (trRotXOrigo.Apply (coord))); + test.Assert (trYOrigo.Apply (coord).IsEqual (trRotYOrigo.Apply (coord))); + test.Assert (trZOrigo.Apply (coord).IsEqual (trRotZOrigo.Apply (coord))); var coord = new JSM.Coord (2.0, 0.0, 0.0); transformation = new JSM.RotationZTransformation (90.0 * JSM.DegRad, new JSM.Coord (0.0, 0.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (0.0, 2.0, 0.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (0.0, 2.0, 0.0))); transformation = new JSM.RotationZTransformation (90.0 * JSM.DegRad, new JSM.Coord (1.0, 0.0, 0.0)); - test.Assert (JSM.CoordIsEqual (transformation.Apply (coord), new JSM.Coord (1.0, 1.0, 0.0))); + test.Assert (transformation.Apply (coord).IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); var coord = new JSM.Coord (1.0, 2.0, 3.0); var axis = new JSM.Vector (4.0, 5.0, 6.0); var angle = 7.0 * JSM.DegRad; var origo = new JSM.Coord (8.0, 9.0, 10.0); transformation = new JSM.RotationTransformation (axis, angle, origo); - test.Assert (JSM.CoordIsEqual (JSM.CoordRotate (coord, axis, angle, origo), transformation.Apply (coord))); + test.Assert (coord.Clone ().Rotate (axis, angle, origo).IsEqual (transformation.Apply (coord))); var coord = new JSM.Coord (1.0, 2.0, 3.0); var direction = new JSM.Coord (4.0, 5.0, 6.0); var axis = new JSM.Vector (4.0, 5.0, 6.0); var angle = 7.0 * JSM.DegRad; var origo = new JSM.Coord (0.0, 0.0, 0.0); - var result1 = coord; - result1 = JSM.CoordOffset (result1, direction, 11.0); - result1 = JSM.CoordRotate (result1, axis, angle, origo); + var result1 = coord.Clone (); + result1.Offset (direction, 11.0); + result1.Rotate (axis, angle, origo); var offsetTransformation = new JSM.OffsetTransformation (direction, 11.0); var rotateTransformation = new JSM.RotationTransformation (axis, angle, origo); @@ -622,7 +534,7 @@ generalSuite.AddTest ('TransformationTest', function (test) { transformation.Append (rotateTransformation); var result2 = transformation.Apply (coord); - test.Assert (JSM.CoordIsEqual (result1, result2)); + test.Assert (result1.IsEqual (result2)); var trX = new JSM.RotationXTransformation (10 * JSM.DegRad); var trY = new JSM.RotationYTransformation (20 * JSM.DegRad); @@ -634,7 +546,7 @@ generalSuite.AddTest ('TransformationTest', function (test) { coord = trY.Apply (coord); coord = trZ.Apply (coord); - test.Assert (JSM.CoordIsEqual (trXYZ.Apply (new JSM.Coord (1.0, 2.0, 3.0)), coord)); + test.Assert (trXYZ.Apply (new JSM.Coord (1.0, 2.0, 3.0)).IsEqual (coord)); }); generalSuite.AddTest ('SectorTest', function (test) { @@ -653,12 +565,12 @@ generalSuite.AddTest ('SectorTest', function (test) { var end = new JSM.Coord (4.0, 5.0, 6.0); var sector = new JSM.Sector (beg, end); - test.Assert (JSM.CoordIsEqual (sector.beg, new JSM.Coord (1.0, 2.0, 3.0))); - test.Assert (JSM.CoordIsEqual (sector.end, new JSM.Coord (4.0, 5.0, 6.0))); + test.Assert (sector.beg.IsEqual (new JSM.Coord (1.0, 2.0, 3.0))); + test.Assert (sector.end.IsEqual (new JSM.Coord (4.0, 5.0, 6.0))); sector.Set (end, beg); - test.Assert (JSM.CoordIsEqual (sector.beg, new JSM.Coord (4.0, 5.0, 6.0))); - test.Assert (JSM.CoordIsEqual (sector.end, new JSM.Coord (1.0, 2.0, 3.0))); + test.Assert (sector.beg.IsEqual (new JSM.Coord (4.0, 5.0, 6.0))); + test.Assert (sector.end.IsEqual (new JSM.Coord (1.0, 2.0, 3.0))); }); generalSuite.AddTest ('CoordLinePositionTest', function (test) @@ -676,15 +588,15 @@ generalSuite.AddTest ('CoordLinePositionTest', function (test) var projected = new JSM.Coord (0.0, 0.0, 0.0); test.Assert (JSM.CoordLinePosition (new JSM.Coord (0.0, 0.0, 0.0), line, projected) == 'CoordOutsideOfLine'); - test.Assert (JSM.CoordIsEqual (projected, new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (projected.IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); test.Assert (JSM.CoordLinePosition (new JSM.Coord (1.0, 1.0, 1.0), line, projected) == 'CoordOnLine'); - test.Assert (JSM.CoordIsEqual (projected, new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (projected.IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); test.Assert (JSM.CoordLinePosition (new JSM.Coord (2.0, 1.0, 1.0), line, projected) == 'CoordOnLine'); - test.Assert (JSM.CoordIsEqual (projected, new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (projected.IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToLine (new JSM.Coord (0.0, 0.0, 0.0), line), new JSM.Coord (0.0, 1.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToLine (new JSM.Coord (1.0, 1.0, 1.0), line), new JSM.Coord (1.0, 1.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToLine (new JSM.Coord (2.0, 1.0, 1.0), line), new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (0.0, 0.0, 0.0), line).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (1.0, 1.0, 1.0), line).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (2.0, 1.0, 1.0), line).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); var line1 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0)); var line2 = new JSM.Line (new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0)); @@ -705,25 +617,25 @@ generalSuite.AddTest ('CoordLinePositionTest', function (test) test.Assert (JSM.LineLinePosition (line4, line7, intersection) == 'LinesDontIntersects'); test.Assert (JSM.LineLinePosition (line5, line7, intersection) == 'LinesDontIntersects'); test.Assert (JSM.LineLinePosition (line6, line7, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); test.Assert (JSM.LineLinePosition (line1, line3, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); test.Assert (JSM.LineLinePosition (line1, line4, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (2.0, 0.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (2.0, 0.0, 0.0))); test.Assert (JSM.LineLinePosition (line1, line5, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); test.Assert (JSM.LineLinePosition (line2, line3, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 1.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 1.0, 0.0))); test.Assert (JSM.LineLinePosition (line2, line4, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (2.0, 1.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (2.0, 1.0, 0.0))); test.Assert (JSM.LineLinePosition (line2, line5, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (1.0, 1.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); test.Assert (JSM.LineLinePosition (line5, line6, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); test.Assert (JSM.LineLinePosition (line6, line7, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); test.Assert (JSM.LineLinePosition (line8, line9, intersection) == 'LinesIntersectsOnePoint'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (0.5, 0.5, 0.5))); + test.Assert (intersection.IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); }); generalSuite.AddTest ('CoordSectorPositionTest', function (test) @@ -919,23 +831,23 @@ generalSuite.AddTest ('BoxTest', function (test) test.Assert (box.GetCenter ().IsEqual (new JSM.Coord2D (0.5, 0.5))); var box = new JSM.Box (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 1.0, 1.0)); - test.Assert (JSM.CoordIsEqual (box.GetCenter (), new JSM.Coord (0.5, 0.5, 0.5))); + test.Assert (box.GetCenter ().IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); var box2 = new JSM.Box (new JSM.Coord (-0.5, -0.5, -0.5), new JSM.Coord (0.5, 0.5, 0.5)); var box3 = JSM.BoxUnion (box, box2); - test.Assert (JSM.CoordIsEqual (box3.min, new JSM.Coord (-0.5, -0.5, -0.5))); - test.Assert (JSM.CoordIsEqual (box3.max, new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (box3.min.IsEqual (new JSM.Coord (-0.5, -0.5, -0.5))); + test.Assert (box3.max.IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); }); generalSuite.AddTest ('SphereTest', function (test) { var sphere = new JSM.Sphere (new JSM.Coord (1.0, 1.0, 1.0), 2.0); var sphere2 = sphere.Clone (); - test.Assert (JSM.CoordIsEqual (sphere2.GetCenter (), new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (sphere2.GetCenter ().IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); test.Assert (sphere2.GetRadius () == 2.0); sphere.Set (new JSM.Coord (3.0, 3.0, 3.0), 4.0); - test.Assert (JSM.CoordIsEqual (sphere.GetCenter (), new JSM.Coord (3.0, 3.0, 3.0))); + test.Assert (sphere.GetCenter ().IsEqual (new JSM.Coord (3.0, 3.0, 3.0))); test.Assert (sphere.GetRadius () == 4.0); }); @@ -1000,17 +912,17 @@ generalSuite.AddTest ('PlaneTest', function (test) test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord3, plane2), 1.0)); test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord3, plane3), 0.0)); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord1, plane1), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord1, plane2), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord1, plane3), new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (JSM.ProjectCoordToPlane (coord1, plane1).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (JSM.ProjectCoordToPlane (coord1, plane2).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (JSM.ProjectCoordToPlane (coord1, plane3).IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord2, plane1), new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord2, plane2), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord2, plane3), new JSM.Coord (1.0, 0.0, 1.0))); + test.Assert (JSM.ProjectCoordToPlane (coord2, plane1).IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (JSM.ProjectCoordToPlane (coord2, plane2).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (JSM.ProjectCoordToPlane (coord2, plane3).IsEqual (new JSM.Coord (1.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord3, plane1), new JSM.Coord (1.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord3, plane2), new JSM.Coord (0.0, 1.0, 1.0))); - test.Assert (JSM.CoordIsEqual (JSM.ProjectCoordToPlane (coord3, plane3), new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (JSM.ProjectCoordToPlane (coord3, plane1).IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); + test.Assert (JSM.ProjectCoordToPlane (coord3, plane2).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (JSM.ProjectCoordToPlane (coord3, plane3).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); var line1 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); var line2 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (0.0, 0.0, 1.0)); @@ -1020,8 +932,8 @@ generalSuite.AddTest ('PlaneTest', function (test) var intersection = new JSM.Coord (0.0, 0.0, 0.0); test.Assert (JSM.LinePlanePosition (line3, plane1, intersection) == 'LineIntersectsPlane'); - test.Assert (JSM.CoordIsEqual (intersection, new JSM.Coord (1.0, 2.0, 0.0))); - test.Assert (JSM.CoordIsEqual (JSM.LinePlaneIntersection (line3, plane1), new JSM.Coord (1.0, 2.0, 0.0))); + test.Assert (intersection.IsEqual (new JSM.Coord (1.0, 2.0, 0.0))); + test.Assert (JSM.LinePlaneIntersection (line3, plane1).IsEqual (new JSM.Coord (1.0, 2.0, 0.0))); } }); @@ -1469,14 +1381,14 @@ polygonSuite.AddTest ('PolygonTest', function (test) polygon.AddVertex (1.0, 0.0); polygon.AddVertex (0.0, 1.0); test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon), 0.5)); - test.Assert (JSM.PolygonOrientation2D (polygon) == 'CounterClockwise'); - test.Assert (JSM.PolygonComplexity2D (polygon) == 'Convex'); + test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.CounterClockwise); + test.Assert (JSM.PolygonComplexity2D (polygon) == JSM.Complexity.Convex); test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.2, 0.2), polygon) == 'CoordInsideOfPolygon'); JSM.ChangePolygonOrientation2D (polygon); test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon), -0.5)); - test.Assert (JSM.PolygonOrientation2D (polygon) == 'Clockwise'); - test.Assert (JSM.PolygonComplexity2D (polygon) == 'Convex'); + test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.Clockwise); + test.Assert (JSM.PolygonComplexity2D (polygon) == JSM.Complexity.Convex); test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.2, 0.2), polygon) == 'CoordInsideOfPolygon'); var polygon = new JSM.Polygon2D (); @@ -1546,10 +1458,10 @@ polygonSuite.AddTest ('PolygonTest', function (test) ]; var polygon = JSM.CreatePolygonFromVertices (vertices); - test.Assert (JSM.PolygonOrientation2D (polygon) == 'Clockwise'); + test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.Clockwise); var polygon = JSM.CreateCCWPolygonFromVertices (vertices); - test.Assert (JSM.PolygonOrientation2D (polygon) == 'CounterClockwise'); + test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.CounterClockwise); }); polygonSuite.AddTest ('ContourPolygon2DTest', function (test) @@ -1918,10 +1830,10 @@ polygonSuite.AddTest ('PolygonOffsetTest', function (test) polygon.AddVertex (0.0, 1.0, 0.0); var offseted = JSM.OffsetPolygonContour (polygon, 0.2); - test.Assert (JSM.CoordIsEqual (offseted.vertices[0], new JSM.Coord (0.2, 0.2, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[1], new JSM.Coord (0.8, 0.2, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[2], new JSM.Coord (0.8, 0.8, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[3], new JSM.Coord (0.2, 0.8, 0.0))); + test.Assert (offseted.vertices[0].IsEqual (new JSM.Coord (0.2, 0.2, 0.0))); + test.Assert (offseted.vertices[1].IsEqual (new JSM.Coord (0.8, 0.2, 0.0))); + test.Assert (offseted.vertices[2].IsEqual (new JSM.Coord (0.8, 0.8, 0.0))); + test.Assert (offseted.vertices[3].IsEqual (new JSM.Coord (0.2, 0.8, 0.0))); var polygon = new JSM.Polygon (); polygon.AddVertex (0.0, 0.0, 0.0); @@ -1931,11 +1843,11 @@ polygonSuite.AddTest ('PolygonOffsetTest', function (test) polygon.AddVertex (1.0, 2.0, 0.0); var offseted = JSM.OffsetPolygonContour (polygon, 0.2); - test.Assert (JSM.CoordIsEqual (offseted.vertices[0], new JSM.Coord (0.32360679774997897, 0.2, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[1], new JSM.Coord (1.8, 0.2, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[2], new JSM.Coord (1.8, 0.8, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[3], new JSM.Coord (0.8, 0.8, 0.0))); - test.Assert (JSM.CoordIsEqual (offseted.vertices[4], new JSM.Coord (0.8, 1.1527864045000422, 0.0))); + test.Assert (offseted.vertices[0].IsEqual (new JSM.Coord (0.32360679774997897, 0.2, 0.0))); + test.Assert (offseted.vertices[1].IsEqual (new JSM.Coord (1.8, 0.2, 0.0))); + test.Assert (offseted.vertices[2].IsEqual (new JSM.Coord (1.8, 0.8, 0.0))); + test.Assert (offseted.vertices[3].IsEqual (new JSM.Coord (0.8, 0.8, 0.0))); + test.Assert (offseted.vertices[4].IsEqual (new JSM.Coord (0.8, 1.1527864045000422, 0.0))); }); polygonSuite.AddTest ('PolygonWithHole2DTest', function (test) @@ -2718,10 +2630,10 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.0, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (1.0, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (0.0, 1.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.0, 0.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (-1.0, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); @@ -2742,10 +2654,10 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.5, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.5, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (0.0, 0.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.5, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.5, 1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.5, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); @@ -2757,10 +2669,10 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.5, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.5, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (1.0, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (1.0, 1.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.5, 1.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.5, 0.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 0.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.8, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); @@ -2772,10 +2684,10 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.8, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.8, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (0.0, 0.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.8, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.8, 1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); @@ -2797,14 +2709,14 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (backPolygons[0].VertexCount () == 3); test.Assert (frontPolygons[0].VertexCount () == 3); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.0, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (0.0, 1.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) ); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (0.0, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (1.0, 0.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 0.0, 0.0)) ); polygon = new JSM.Polygon (); @@ -2822,16 +2734,16 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.0, -1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (-1.0, -1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (-1.0, 1.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.0, -1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (-1.0, -1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (-1.0, 1.0, 0.0)) ); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (0.0, -1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Vector (1.0, -1.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, -1.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (1.0, -1.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); @@ -2843,16 +2755,16 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.0, -1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (1.0, -1.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, -1.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (1.0, -1.0, 0.0)) ); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (0.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (0.0, -1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (-1.0, -1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Vector (-1.0, 1.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.0, -1.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (-1.0, -1.0, 0.0)) && + backPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (-1.0, 1.0, 0.0)) ); var polygon = new JSM.Polygon (); @@ -2883,30 +2795,30 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons[0].VertexCount () == 8); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (1.5, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (1.5, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (1.0, 2.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (4), new JSM.Vector (1.5, 2.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (5), new JSM.Vector (1.5, 3.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (6), new JSM.Vector (0.0, 3.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (7), new JSM.Vector (0.0, 0.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (1.5, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.5, 1.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (1.0, 2.0, 0.0)) && + frontPolygons[0].GetVertex (4).IsEqual (new JSM.Vector (1.5, 2.0, 0.0)) && + frontPolygons[0].GetVertex (5).IsEqual (new JSM.Vector (1.5, 3.0, 0.0)) && + frontPolygons[0].GetVertex (6).IsEqual (new JSM.Vector (0.0, 3.0, 0.0)) && + frontPolygons[0].GetVertex (7).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) ); test.Assert (backPolygons[0].VertexCount () == 4); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (1.5, 3.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (1.5, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (2.0, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Vector (2.0, 3.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (1.5, 3.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.5, 2.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (2.0, 2.0, 0.0)) && + backPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (2.0, 3.0, 0.0)) ); test.Assert (backPolygons[1].VertexCount () == 4); test.Assert ( - JSM.CoordIsEqual (backPolygons[1].GetVertex (0), new JSM.Vector (1.5, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[1].GetVertex (1), new JSM.Vector (1.5, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[1].GetVertex (2), new JSM.Vector (2.0, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[1].GetVertex (3), new JSM.Vector (2.0, 1.0, 0.0)) + backPolygons[1].GetVertex (0).IsEqual (new JSM.Vector (1.5, 1.0, 0.0)) && + backPolygons[1].GetVertex (1).IsEqual (new JSM.Vector (1.5, 0.0, 0.0)) && + backPolygons[1].GetVertex (2).IsEqual (new JSM.Vector (2.0, 0.0, 0.0)) && + backPolygons[1].GetVertex (3).IsEqual (new JSM.Vector (2.0, 1.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.5, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); @@ -2919,22 +2831,22 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons[0].VertexCount () == 4); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (0.5, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (0.5, 3.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (0.0, 3.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (0.0, 0.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.5, 0.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.5, 3.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (0.0, 3.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) ); test.Assert (backPolygons[0].VertexCount () == 8); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (0.5, 3.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (0.5, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (2.0, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Vector (2.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (5), new JSM.Vector (1.0, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (6), new JSM.Vector (2.0, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (7), new JSM.Vector (2.0, 3.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (0.5, 3.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (0.5, 0.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (2.0, 0.0, 0.0)) && + backPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (2.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (4).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (5).IsEqual (new JSM.Vector (1.0, 2.0, 0.0)) && + backPolygons[0].GetVertex (6).IsEqual (new JSM.Vector (2.0, 2.0, 0.0)) && + backPolygons[0].GetVertex (7).IsEqual (new JSM.Vector (2.0, 3.0, 0.0)) ); plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (1.0, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); @@ -2955,30 +2867,30 @@ polygonSuite.AddTest ('OldCutPolygonTest', function (test) test.Assert (frontPolygons[0].VertexCount () == 4); test.Assert ( - JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Vector (1.5, 3.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Vector (1.5, 2.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Vector (2.0, 2.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Vector (2.0, 3.0, 0.0)) + frontPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (1.5, 3.0, 0.0)) && + frontPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.5, 2.0, 0.0)) && + frontPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (2.0, 2.0, 0.0)) && + frontPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (2.0, 3.0, 0.0)) ); test.Assert (frontPolygons[1].VertexCount () == 4); test.Assert ( - JSM.CoordIsEqual (frontPolygons[1].GetVertex (0), new JSM.Vector (1.5, 1.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[1].GetVertex (1), new JSM.Vector (1.5, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[1].GetVertex (2), new JSM.Vector (2.0, 0.0, 0.0)) && - JSM.CoordIsEqual (frontPolygons[1].GetVertex (3), new JSM.Vector (2.0, 1.0, 0.0)) + frontPolygons[1].GetVertex (0).IsEqual (new JSM.Vector (1.5, 1.0, 0.0)) && + frontPolygons[1].GetVertex (1).IsEqual (new JSM.Vector (1.5, 0.0, 0.0)) && + frontPolygons[1].GetVertex (2).IsEqual (new JSM.Vector (2.0, 0.0, 0.0)) && + frontPolygons[1].GetVertex (3).IsEqual (new JSM.Vector (2.0, 1.0, 0.0)) ); test.Assert (backPolygons[0].VertexCount () == 8); test.Assert ( - JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Vector (1.5, 0.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Vector (1.5, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Vector (1.0, 1.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Vector (1.0, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Vector (1.5, 2.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (5), new JSM.Vector (1.5, 3.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (6), new JSM.Vector (0.0, 3.0, 0.0)) && - JSM.CoordIsEqual (backPolygons[0].GetVertex (7), new JSM.Vector (0.0, 0.0, 0.0)) + backPolygons[0].GetVertex (0).IsEqual (new JSM.Vector (1.5, 0.0, 0.0)) && + backPolygons[0].GetVertex (1).IsEqual (new JSM.Vector (1.5, 1.0, 0.0)) && + backPolygons[0].GetVertex (2).IsEqual (new JSM.Vector (1.0, 1.0, 0.0)) && + backPolygons[0].GetVertex (3).IsEqual (new JSM.Vector (1.0, 2.0, 0.0)) && + backPolygons[0].GetVertex (4).IsEqual (new JSM.Vector (1.5, 2.0, 0.0)) && + backPolygons[0].GetVertex (5).IsEqual (new JSM.Vector (1.5, 3.0, 0.0)) && + backPolygons[0].GetVertex (6).IsEqual (new JSM.Vector (0.0, 3.0, 0.0)) && + backPolygons[0].GetVertex (7).IsEqual (new JSM.Vector (0.0, 0.0, 0.0)) ); }); @@ -3011,36 +2923,36 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 2); test.Assert (backPolygons[0].VertexCount () == 8); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (1, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (1, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (5), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (6), new JSM.Coord (0, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (7), new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 1, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (1, 2, 0))); + test.Assert (backPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (5).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (backPolygons[0].GetVertex (6).IsEqual (new JSM.Coord (0, 3, 0))); + test.Assert (backPolygons[0].GetVertex (7).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (backPolygons[1].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (0), new JSM.Coord (2, 4, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (1), new JSM.Coord (2, 5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (2), new JSM.Coord (0, 5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (3), new JSM.Coord (0, 4, 0))); + test.Assert (backPolygons[1].GetVertex (0).IsEqual (new JSM.Coord (2, 4, 0))); + test.Assert (backPolygons[1].GetVertex (1).IsEqual (new JSM.Coord (2, 5, 0))); + test.Assert (backPolygons[1].GetVertex (2).IsEqual (new JSM.Coord (0, 5, 0))); + test.Assert (backPolygons[1].GetVertex (3).IsEqual (new JSM.Coord (0, 4, 0))); test.Assert (frontPolygons[0].VertexCount () == 8); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 4, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 4, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 3, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (4), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (5), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (6), new JSM.Coord (4, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (7), new JSM.Coord (4, 5, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 5, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 4, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 4, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (5).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (6).IsEqual (new JSM.Coord (4, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (7).IsEqual (new JSM.Coord (4, 5, 0))); test.Assert (frontPolygons[1].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (0), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (1), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (2), new JSM.Coord (3, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (3), new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[1].GetVertex (0).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[1].GetVertex (1).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (frontPolygons[1].GetVertex (2).IsEqual (new JSM.Coord (3, 0, 0))); + test.Assert (frontPolygons[1].GetVertex (3).IsEqual (new JSM.Coord (3, 1, 0))); // same with reversed plane var backPolygons = []; @@ -3052,36 +2964,36 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 2); test.Assert (frontPolygons[0].VertexCount () == 8); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (1, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (1, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (4), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (5), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (6), new JSM.Coord (0, 3, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (7), new JSM.Coord (0, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (1, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (5).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (6).IsEqual (new JSM.Coord (0, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (7).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (frontPolygons[1].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (0), new JSM.Coord (2, 4, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (1), new JSM.Coord (2, 5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (2), new JSM.Coord (0, 5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[1].GetVertex (3), new JSM.Coord (0, 4, 0))); + test.Assert (frontPolygons[1].GetVertex (0).IsEqual (new JSM.Coord (2, 4, 0))); + test.Assert (frontPolygons[1].GetVertex (1).IsEqual (new JSM.Coord (2, 5, 0))); + test.Assert (frontPolygons[1].GetVertex (2).IsEqual (new JSM.Coord (0, 5, 0))); + test.Assert (frontPolygons[1].GetVertex (3).IsEqual (new JSM.Coord (0, 4, 0))); test.Assert (backPolygons[0].VertexCount () == 8); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 4, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (3, 4, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (3, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (5), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (6), new JSM.Coord (4, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (7), new JSM.Coord (4, 5, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 5, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 4, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 4, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 3, 0))); + test.Assert (backPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (backPolygons[0].GetVertex (5).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (6).IsEqual (new JSM.Coord (4, 2, 0))); + test.Assert (backPolygons[0].GetVertex (7).IsEqual (new JSM.Coord (4, 5, 0))); test.Assert (backPolygons[1].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (0), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (1), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (2), new JSM.Coord (3, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[1].GetVertex (3), new JSM.Coord (3, 1, 0))); + test.Assert (backPolygons[1].GetVertex (0).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (backPolygons[1].GetVertex (1).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[1].GetVertex (2).IsEqual (new JSM.Coord (3, 0, 0))); + test.Assert (backPolygons[1].GetVertex (3).IsEqual (new JSM.Coord (3, 1, 0))); // all outside var polygon = new JSM.Polygon (); @@ -3099,10 +3011,10 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 0); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (1, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 1, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 1, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 1, 0))); // all outside, some on the plane var polygon = new JSM.Polygon (); @@ -3120,10 +3032,10 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 0); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 2, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 2, 0))); // all inside var polygon = new JSM.Polygon (); @@ -3141,10 +3053,10 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (3, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (4, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (4, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (3, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (4, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (4, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 1, 0))); // all inside, some on the plane var polygon = new JSM.Polygon (); @@ -3162,10 +3074,10 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (3, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (3, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (2, 1, 0))); // both sides, clean cut var polygon = new JSM.Polygon (); @@ -3183,16 +3095,16 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 3, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 3, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 3, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 3, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 3, 0))); // both sides, edge on the plane cut var polygon = new JSM.Polygon (); @@ -3212,17 +3124,17 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 5); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 2, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 2, 0))); // both sides, edge on the plane cut var polygon = new JSM.Polygon (); @@ -3242,17 +3154,17 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 5); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 2, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 2, 0))); // both sides, edge on the plane cut var polygon = new JSM.Polygon (); @@ -3272,17 +3184,17 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 5); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (4), new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 2, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (4).IsEqual (new JSM.Coord (2, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (3, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (3, 2, 0))); // cut triangle var polygon = new JSM.Polygon (); @@ -3298,15 +3210,15 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (2, 0.6666666666666666, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 2, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 0.6666666666666666, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 2, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (2, 0.6666666666666666, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (2, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (3, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (2, 0.6666666666666666, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (2, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (3, 0, 0))); // cut triangles from polygon var polygon = new JSM.Polygon (); @@ -3393,16 +3305,16 @@ polygonSuite.AddTest ('CutPolygonTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (1, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (4, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 1, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (4, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (1, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (3, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (4, 2, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (0, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (1, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (3, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (4, 2, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 2, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (1.0, 1.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); var backPolygons = []; @@ -3461,9 +3373,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 1); test.Assert (frontPolygons.length == 0); test.Assert (backPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (2.0, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); var backPolygons = []; @@ -3474,9 +3386,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 0); test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (1.0, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); var backPolygons = []; @@ -3487,9 +3399,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 1); test.Assert (frontPolygons.length == 0); test.Assert (backPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (1.0, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); var backPolygons = []; @@ -3500,9 +3412,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 0); test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (0.0, -1.0, 0.0)); var backPolygons = []; @@ -3513,9 +3425,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 1); test.Assert (frontPolygons.length == 0); test.Assert (backPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); var backPolygons = []; @@ -3526,9 +3438,9 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (backPolygons.length == 0); test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (0.0, 0.0, 1.0)); var backPolygons = []; @@ -3560,15 +3472,15 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (0.5, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 0.5, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0.5, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (1, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 0.5, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 0, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.5, 0.0, 0.0), new JSM.Vector (-1.0, 0.0, 0.0)); var backPolygons = []; @@ -3580,15 +3492,15 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (frontPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (0.5, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (0, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (3), new JSM.Coord (0, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 0.5, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (backPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0.5, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 0.5, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 0, 0))); var polygon = new JSM.Polygon (); polygon.AddVertex (0, 0, 0); @@ -3605,14 +3517,14 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (0.5, 1, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 1, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0.5, 1, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (0.5, 0, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (1, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.5, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.5, 0, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (1, 0, 0))); var plane = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.5, 0.0), new JSM.Vector (0.0, 1.0, 0.0)); var backPolygons = []; @@ -3624,15 +3536,15 @@ polygonSuite.AddTest ('CutTriangleTest', function (test) test.Assert (frontPolygons.length == 1); test.Assert (backPolygons[0].VertexCount () == 4); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (0), new JSM.Coord (0.75, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (1), new JSM.Coord (0.25, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (2), new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (backPolygons[0].GetVertex (3), new JSM.Coord (1, 0, 0))); + test.Assert (backPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.75, 0.5, 0))); + test.Assert (backPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.25, 0.5, 0))); + test.Assert (backPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (backPolygons[0].GetVertex (3).IsEqual (new JSM.Coord (1, 0, 0))); test.Assert (frontPolygons[0].VertexCount () == 3); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (0), new JSM.Coord (0.25, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (1), new JSM.Coord (0.75, 0.5, 0))); - test.Assert (JSM.CoordIsEqual (frontPolygons[0].GetVertex (2), new JSM.Coord (0.5, 1, 0))); + test.Assert (frontPolygons[0].GetVertex (0).IsEqual (new JSM.Coord (0.25, 0.5, 0))); + test.Assert (frontPolygons[0].GetVertex (1).IsEqual (new JSM.Coord (0.75, 0.5, 0))); + test.Assert (frontPolygons[0].GetVertex (2).IsEqual (new JSM.Coord (0.5, 1, 0))); }); polygonSuite.AddTest ('BSPTreeTest', function (test) @@ -3640,7 +3552,7 @@ polygonSuite.AddTest ('BSPTreeTest', function (test) function TestNode (test, node, vertexCount, normalVector) { test.Assert (node.polygon.VertexCount () == vertexCount); - test.Assert (JSM.CoordIsEqual (node.plane.GetNormal (), normalVector)); + test.Assert (node.plane.GetNormal ().IsEqual (normalVector)); } var bspTree = new JSM.BSPTree (); diff --git a/test/unittest/tests/modeler.js b/test/unittest/tests/modeler.js index be49c53c..6e813b4f 100644 --- a/test/unittest/tests/modeler.js +++ b/test/unittest/tests/modeler.js @@ -13,14 +13,14 @@ generalSuite.AddTest ('BodyTest', function (test) body.AddVertex (new JSM.BodyVertex (new JSM.Coord (0, 1, 0))); body.AddPolygon (new JSM.BodyPolygon ([0, 1, 2])); test.Assert (body.VertexCount () == 3 && body.PolygonCount () == 1); - test.Assert (JSM.CoordIsEqual (body.GetVertex (0).position, new JSM.Coord (0, 0, 0))); - test.Assert (JSM.CoordIsEqual (body.GetVertex (1).position, new JSM.Coord (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (body.GetVertex (2).position, new JSM.Coord (0, 1, 0))); + test.Assert (body.GetVertex (0).position.IsEqual (new JSM.Coord (0, 0, 0))); + test.Assert (body.GetVertex (1).position.IsEqual (new JSM.Coord (1, 0, 0))); + test.Assert (body.GetVertex (2).position.IsEqual (new JSM.Coord (0, 1, 0))); test.Assert (body.GetPolygon (0).vertices.toString () == [0, 1, 2].toString ()); polygonNormals = JSM.CalculateBodyPolygonNormals (body); test.Assert (polygonNormals.length == 1); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); body.AddVertex (new JSM.BodyVertex (new JSM.Coord (0, 0, 1))); body.AddVertex (new JSM.BodyVertex (new JSM.Coord (0, 1, 1))); @@ -33,15 +33,15 @@ generalSuite.AddTest ('BodyTest', function (test) test.Assert (body.GetPolygon (0).VertexIndexCount () == 3); test.Assert (body.GetPolygon (1).VertexIndexCount () == 4); test.Assert (polygonNormals.length == 2); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[1], new JSM.Vector (0, 0, -1))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[1].IsEqual (new JSM.Vector (0, 0, -1))); body.AddPolygon (new JSM.BodyPolygon ([0, 1, 6])); polygonNormals = JSM.CalculateBodyPolygonNormals (body); test.Assert (polygonNormals.length == 3); - test.Assert (JSM.CoordIsEqual (polygonNormals[2], new JSM.Vector (0, -1, 0))); + test.Assert (polygonNormals[2].IsEqual (new JSM.Vector (0, -1, 0))); - test.Assert (JSM.CoordIsEqual (body.GetCenter (), new JSM.Coord (0.5, 0.5, 0.5))); + test.Assert (body.GetCenter ().IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); body.Clear (); test.Assert (body.VertexCount () == 0 && body.PolygonCount () == 0); @@ -106,8 +106,8 @@ generalSuite.AddTest ('BodyVertexNormalTest', function (test) polygonNormals = JSM.CalculateBodyPolygonNormals (body); test.Assert (polygonNormals.length == 2); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[1], new JSM.Vector (1, 0, 0))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[1].IsEqual (new JSM.Vector (1, 0, 0))); body.GetPolygon (0).SetCurveGroup (0); body.GetPolygon (1).SetCurveGroup (0); @@ -115,15 +115,15 @@ generalSuite.AddTest ('BodyVertexNormalTest', function (test) var vertexNormals = JSM.CalculateBodyVertexNormals (body); test.Assert (vertexNormals.length == 2); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][0], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][1], JSM.VectorNormalize (new JSM.Vector (1, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][2], JSM.VectorNormalize (new JSM.Vector (1, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][3], new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[0][0].IsEqual (new JSM.Vector (0, 0, 1).Normalize ())); + test.Assert (vertexNormals[0][1].IsEqual (new JSM.Vector (1, 0, 1).Normalize ())); + test.Assert (vertexNormals[0][2].IsEqual (new JSM.Vector (1, 0, 1).Normalize ())); + test.Assert (vertexNormals[0][3].IsEqual (new JSM.Vector (0, 0, 1).Normalize ())); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][0], JSM.VectorNormalize (new JSM.Vector (1, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][1], JSM.VectorNormalize (new JSM.Vector (1, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][2], new JSM.Vector (1, 0, 0))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][3], new JSM.Vector (1, 0, 0))); + test.Assert (vertexNormals[1][0].IsEqual (new JSM.Vector (1, 0, 1).Normalize ())); + test.Assert (vertexNormals[1][1].IsEqual (new JSM.Vector (1, 0, 1).Normalize ())); + test.Assert (vertexNormals[1][2].IsEqual (new JSM.Vector (1, 0, 0).Normalize ())); + test.Assert (vertexNormals[1][3].IsEqual (new JSM.Vector (1, 0, 0).Normalize ())); }); generalSuite.AddTest ('AdjacencyListTest', function (test) @@ -643,10 +643,10 @@ generatorSuite.AddTest ('GenerateRectangleTest', function (test) test.Assert (rectangle.VertexCount () == 4 && rectangle.PolygonCount () == 1); var vertexNormals = JSM.CalculateBodyVertexNormals (rectangle); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); + test.Assert (vertexNormals[0][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[0][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[0][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[0][3].IsEqual (new JSM.Vector (0, 0, 1))); }); generatorSuite.AddTest ('GenerateCuboidTest', function (test) @@ -656,15 +656,15 @@ generatorSuite.AddTest ('GenerateCuboidTest', function (test) test.Assert (JSM.CheckSolidBody (cuboid)); var vertexNormals = JSM.CalculateBodyVertexNormals (cuboid); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][0], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][1], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][2], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][3], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[5][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); + test.Assert (vertexNormals[0][0].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[0][1].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[0][2].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[0][3].IsEqual (new JSM.Vector (0, -1, 0))); + + test.Assert (vertexNormals[5][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][3].IsEqual (new JSM.Vector (0, 0, 1))); }); generatorSuite.AddTest ('GenerateSegmentedCuboidTest', function (test) @@ -691,10 +691,10 @@ generatorSuite.AddTest ('GenerateSegmentedRectangleTest', function (test) test.Assert (plane.VertexCount () == 9 && plane.PolygonCount () == 4); var polygonNormals = JSM.CalculateBodyPolygonNormals (plane); test.Assert (polygonNormals.length == 4); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[1], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[2], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[3], new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[3].IsEqual (new JSM.Vector (0, 0, 1))); var plane = JSM.GenerateSegmentedRectangle (1, 2, 3, 3); test.Assert (plane.VertexCount () == 16 && plane.PolygonCount () == 9); @@ -733,7 +733,7 @@ generatorSuite.AddTest ('GenerateCircleTest', function (test) var polygonNormals = JSM.CalculateBodyPolygonNormals (circle); test.Assert (polygonNormals.length == 1); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); }); generatorSuite.AddTest ('GenerateCylinderTest', function (test) @@ -753,25 +753,25 @@ generatorSuite.AddTest ('GenerateCylinderTest', function (test) test.Assert (cylinder2.GetPolygon (5).VertexIndexCount () == 4); var vertexNormals = JSM.CalculateBodyVertexNormals (cylinder2); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][0], JSM.VectorNormalize (new JSM.Vector (1, 0, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][1], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][2], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][3], JSM.VectorNormalize (new JSM.Vector (1, 0, 0)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[1][0], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][1], JSM.VectorNormalize (new JSM.Vector (-1, 0, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][2], JSM.VectorNormalize (new JSM.Vector (-1, 0, 0)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[1][3], JSM.VectorNormalize (new JSM.Vector (0, -1, 0)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[4][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[5][0], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][1], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][2], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][3], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); + test.Assert (vertexNormals[0][0].IsEqual (new JSM.Vector (1, 0, 0))); + test.Assert (vertexNormals[0][1].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[0][2].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[0][3].IsEqual (new JSM.Vector (1, 0, 0))); + + test.Assert (vertexNormals[1][0].IsEqual (new JSM.Vector (0, -1, 0))); + test.Assert (vertexNormals[1][1].IsEqual (new JSM.Vector (-1, 0, 0))); + test.Assert (vertexNormals[1][2].IsEqual (new JSM.Vector (-1, 0, 0))); + test.Assert (vertexNormals[1][3].IsEqual (new JSM.Vector (0, -1, 0))); + + test.Assert (vertexNormals[4][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][3].IsEqual (new JSM.Vector (0, 0, 1))); + + test.Assert (vertexNormals[5][0].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][1].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][2].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][3].IsEqual (new JSM.Vector (0, 0, -1))); var cylinder3 = JSM.GenerateCylinder (1.0, 2.0, 25, false, true); test.Assert (cylinder3.VertexCount () == 50 && cylinder3.PolygonCount () == 25); @@ -810,20 +810,20 @@ generatorSuite.AddTest ('GenerateConeTest', function (test) test.Assert (cone2.GetPolygon (5).VertexIndexCount () == 4); var vertexNormals = JSM.CalculateBodyVertexNormals (cone2); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][0], JSM.VectorNormalize (new JSM.Vector (0.8944271909999159, 0, 0.4472135954999579)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][1], JSM.VectorNormalize (new JSM.Vector (0, -0.8944271909999159, 0.4472135954999579)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][2], JSM.VectorNormalize (new JSM.Vector (0, -0.8944271909999159, 0.4472135954999579)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[0][3], JSM.VectorNormalize (new JSM.Vector (0.8944271909999159, 0, 0.4472135954999579)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[4][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[4][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[5][0], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][1], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][2], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][3], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); + test.Assert (vertexNormals[0][0].IsEqual (new JSM.Vector (0.8944271909999159, 0, 0.4472135954999579))); + test.Assert (vertexNormals[0][1].IsEqual (new JSM.Vector (0, -0.8944271909999159, 0.4472135954999579))); + test.Assert (vertexNormals[0][2].IsEqual (new JSM.Vector (0, -0.8944271909999159, 0.4472135954999579))); + test.Assert (vertexNormals[0][3].IsEqual (new JSM.Vector (0.8944271909999159, 0, 0.4472135954999579))); + + test.Assert (vertexNormals[4][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[4][3].IsEqual (new JSM.Vector (0, 0, 1))); + + test.Assert (vertexNormals[5][0].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][1].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][2].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[5][3].IsEqual (new JSM.Vector (0, 0, -1))); var cone3 = JSM.GenerateCone (0.0, 1.0, 1.0, 4, true, true); test.Assert (cone3.VertexCount () == 5 && cone3.PolygonCount () == 5); @@ -848,21 +848,21 @@ generatorSuite.AddTest ('GeneratePrismTest', function (test) var prism = JSM.GeneratePrism (basePoints, direction, 1.0, true); test.Assert (prism.VertexCount () == 10 && prism.PolygonCount () == 7); test.Assert (JSM.CheckSolidBody (prism)); - test.Assert (JSM.CoordIsEqual (prism.GetVertex (0).position, new JSM.Vector (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (prism.GetVertex (1).position, new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (prism.GetVertex (0).position.IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); + test.Assert (prism.GetVertex (1).position.IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); var vertexNormals = JSM.CalculateBodyVertexNormals (prism); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][4], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[6][0], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][1], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][2], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][3], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][4], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); + test.Assert (vertexNormals[5][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][3].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][4].IsEqual (new JSM.Vector (0, 0, 1))); + + test.Assert (vertexNormals[6][0].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][1].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][2].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][3].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][4].IsEqual (new JSM.Vector (0, 0, -1))); var basePoints2 = [ new JSM.Coord (0.0, 0.0, 0.0), @@ -877,17 +877,17 @@ generatorSuite.AddTest ('GeneratePrismTest', function (test) test.Assert (JSM.CheckSolidBody (prism2)); var vertexNormals = JSM.CalculateBodyVertexNormals (prism2); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][0], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][1], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][2], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][3], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[5][4], JSM.VectorNormalize (new JSM.Vector (0, 0, 1)))); - - test.Assert (JSM.CoordIsEqual (vertexNormals[6][0], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][1], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][2], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][3], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); - test.Assert (JSM.CoordIsEqual (vertexNormals[6][4], JSM.VectorNormalize (new JSM.Vector (0, 0, -1)))); + test.Assert (vertexNormals[5][0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][3].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (vertexNormals[5][4].IsEqual (new JSM.Vector (0, 0, 1))); + + test.Assert (vertexNormals[6][0].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][1].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][2].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][3].IsEqual (new JSM.Vector (0, 0, -1))); + test.Assert (vertexNormals[6][4].IsEqual (new JSM.Vector (0, 0, -1))); }); generatorSuite.AddTest ('GeneratePrismWithHoleTest', function (test) @@ -1013,8 +1013,8 @@ generatorSuite.AddTest ('GeneratePrismShellTest', function (test) var prism = JSM.GeneratePrismShell (basePoints, direction, 1.0, 0.1, true); test.Assert (prism.VertexCount () == 20 && prism.PolygonCount () == 20); test.Assert (JSM.CheckSolidBody (prism)); - test.Assert (JSM.CoordIsEqual (prism.GetVertex (0).position, new JSM.Vector (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (prism.GetVertex (10).position, new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (prism.GetVertex (0).position.IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); + test.Assert (prism.GetVertex (10).position.IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); }); generatorSuite.AddTest ('GenerateCylinderShellTest', function (test) @@ -1038,8 +1038,8 @@ generatorSuite.AddTest ('GenerateLineShellTest', function (test) var shell = JSM.GenerateLineShell (basePoints, direction, 1.0, 0.1, true, true); test.Assert (JSM.CheckSolidBody (shell)); test.Assert (shell.VertexCount () == 20 && shell.PolygonCount () == 18); - test.Assert (JSM.CoordIsEqual (shell.GetVertex (0).position, new JSM.Vector (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (shell.GetVertex (10).position, new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (shell.GetVertex (0).position.IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); + test.Assert (shell.GetVertex (10).position.IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); var basePoints = [ new JSM.Coord (0.0, 0.0, 0.0), @@ -1052,8 +1052,8 @@ generatorSuite.AddTest ('GenerateLineShellTest', function (test) var shell = JSM.GenerateLineShell (basePoints, direction, 1.0, 0.1, true, true); test.Assert (JSM.CheckSolidBody (shell)); test.Assert (shell.VertexCount () == 20 && shell.PolygonCount () == 18); - test.Assert (JSM.CoordIsEqual (shell.GetVertex (0).position, new JSM.Vector (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (shell.GetVertex (10).position, new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (shell.GetVertex (0).position.IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); + test.Assert (shell.GetVertex (10).position.IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); }); generatorSuite.AddTest ('GenerateTorusTest', function (test) @@ -1073,38 +1073,38 @@ generatorSuite.AddTest ('GenerateRuledTest', function (test) JSM.GetRuledMesh (aCoords, bCoords, 2, vertices, polygons); test.Assert (vertices.length == 9); test.Assert (polygons.length == 4); - test.Assert (JSM.CoordIsEqual (vertices[4], new JSM.Vector (1.0, 1.0, 0.0))); + test.Assert (vertices[4].IsEqual (new JSM.Vector (1.0, 1.0, 0.0))); var ruledFromCoords = JSM.GenerateRuledFromCoords (aCoords, bCoords, 2); test.Assert (ruledFromCoords.VertexCount () == 9); test.Assert (ruledFromCoords.PolygonCount () == 4); - test.Assert (JSM.CoordIsEqual (ruledFromCoords.GetVertex (4).position, new JSM.Vector (1.0, 1.0, 0.0))); + test.Assert (ruledFromCoords.GetVertex (4).position.IsEqual (new JSM.Vector (1.0, 1.0, 0.0))); var sector1 = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (2.0, 0.0, 0.0)); var sector2 = new JSM.Sector (new JSM.Coord (0.0, 2.0, 0.0), new JSM.Coord (2.0, 2.0, 0.0)); var sector1Coords = []; JSM.GetSectorSegmentation (sector1, 2, sector1Coords); test.Assert (sector1Coords.length == 3); - test.Assert (JSM.CoordIsEqual (sector1Coords[0], new JSM.Vector (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (sector1Coords[1], new JSM.Vector (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (sector1Coords[2], new JSM.Vector (2.0, 0.0, 0.0))); + test.Assert (sector1Coords[0].IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); + test.Assert (sector1Coords[1].IsEqual (new JSM.Vector (1.0, 0.0, 0.0))); + test.Assert (sector1Coords[2].IsEqual (new JSM.Vector (2.0, 0.0, 0.0))); var ruledFromSectors = JSM.GenerateRuledFromSectors (sector1, sector2, 2, 2, false); test.Assert (ruledFromSectors.VertexCount () == 9); test.Assert (ruledFromSectors.PolygonCount () == 4); - test.Assert (JSM.CoordIsEqual (ruledFromSectors.GetVertex (4).position, new JSM.Vector (1.0, 1.0, 0.0))); + test.Assert (ruledFromSectors.GetVertex (4).position.IsEqual (new JSM.Vector (1.0, 1.0, 0.0))); var polygonNormals = JSM.CalculateBodyPolygonNormals (ruledFromSectors); test.Assert (polygonNormals.length == 4); - test.Assert (JSM.CoordIsEqual (polygonNormals[0], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[1], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[2], new JSM.Vector (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (polygonNormals[3], new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[0].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[1].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[2].IsEqual (new JSM.Vector (0, 0, 1))); + test.Assert (polygonNormals[3].IsEqual (new JSM.Vector (0, 0, 1))); var ruledFromSectors2 = JSM.GenerateRuledFromSectors (sector1, sector2, 10, 10, false); test.Assert (ruledFromSectors2.VertexCount () == 121); test.Assert (ruledFromSectors2.PolygonCount () == 100); - test.Assert (JSM.CoordIsEqual (ruledFromSectors2.GetVertex (60).position, new JSM.Vector (1.0, 1.0, 0.0))); + test.Assert (ruledFromSectors2.GetVertex (60).position.IsEqual (new JSM.Vector (1.0, 1.0, 0.0))); }); generatorSuite.AddTest ('GenerateRevolvedTest', function (test) @@ -1120,8 +1120,8 @@ generatorSuite.AddTest ('GenerateRevolvedTest', function (test) test.Assert (JSM.CheckSolidBody (revolved)); var vertexNormals = JSM.CalculateBodyVertexNormals (revolved); - test.Assert (JSM.CoordIsEqual (vertexNormals[10][0], new JSM.Vector (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (vertexNormals[11][0], new JSM.Vector (0.0, 0.0, -1.0))); + test.Assert (vertexNormals[10][0].IsEqual (new JSM.Vector (0.0, 0.0, 1.0))); + test.Assert (vertexNormals[11][0].IsEqual (new JSM.Vector (0.0, 0.0, -1.0))); var openRevolved = JSM.GenerateRevolved (polyLine, axis, 180.0 * JSM.DegRad, 10, true, 'None'); test.Assert (openRevolved.VertexCount () == 22); @@ -1230,11 +1230,11 @@ generatorSuite.AddTest ('SolidGeneratorTest', function (test) polygon = body.GetPolygon (i); first = body.GetVertex (polygon.GetVertexIndex (0)); last = body.GetVertex (polygon.GetVertexIndex (polygon.VertexIndexCount () - 1)); - length = JSM.CoordDistance (first.position, last.position); + length = first.position.DistanceTo (last.position); for (j = 1; j < polygon.VertexIndexCount (); j++) { a = body.GetVertex (polygon.GetVertexIndex (j - 1)); b = body.GetVertex (polygon.GetVertexIndex (j)); - currentLength = JSM.CoordDistance (a.position, b.position); + currentLength = a.position.DistanceTo (b.position); if (!JSM.IsEqual (length, currentLength)) { return false; } @@ -1705,17 +1705,16 @@ raySuite.AddTest ('RayTest', function (test) var ray2 = ray.Clone (); ray.Set (new JSM.Coord (0.0, 1.0, 0.0), new JSM.Vector (12.0, 0.0, 0.0), 10.1); - test.Assert (JSM.CoordIsEqual (ray.origin, new JSM.Coord (0.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (ray.direction, new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (ray.GetOrigin (), new JSM.Coord (0.0, 1.0, 0.0))); - test.Assert (JSM.CoordIsEqual (ray.GetDirection (), new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (ray.origin.IsEqual (new JSM.Coord (0.0, 1.0, 0.0))); + test.Assert (ray.direction.IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (ray.GetOrigin ().IsEqual (new JSM.Coord (0.0, 1.0, 0.0))); + test.Assert (ray.GetDirection ().IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); test.Assert (ray.length == 10.1); - test.Assert (JSM.CoordIsEqual (ray2.origin, new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (ray2.direction, new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (ray2.GetOrigin (), new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.CoordIsEqual (ray2.GetDirection (), new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.CoordIsEqual (ray2.GetDirection (), new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (ray2.origin.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (ray2.direction.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (ray2.GetOrigin ().IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (ray2.GetDirection ().IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); test.Assert (ray2.length == 10.0); test.Assert (ray2.IsLengthReached (11)); @@ -1749,13 +1748,13 @@ raySuite.AddTest ('RayTriangleIntersectionTest', function (test) var ray = new JSM.Ray (new JSM.Coord (0.2, 0.2, 1.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = JSM.RayTriangleIntersection (ray, v0, v1, v2); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.2, 0.2, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.2, 0.2, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var ray = new JSM.Ray (new JSM.Coord (0.2, 0.2, 1.0), new JSM.Vector (0.0, 0.0, -1.0), null); var intersection = JSM.RayTriangleIntersection (ray, v0, v1, v2); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.2, 0.2, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.2, 0.2, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); test.Assert (CheckIntersection (new JSM.Coord (0, 0, 1), new JSM.Coord (0, 0, 0)) == true); @@ -1804,22 +1803,22 @@ raySuite.AddTest ('RayBoxIntersectionTest', function (test) var intersection = GetIntersection (box, new JSM.Coord (1, 0, 0), new JSM.Coord (2, 1, 1), null); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 0.0)); var intersection = GetIntersection (box, new JSM.Coord (1.5, 0.5, 0.5), new JSM.Coord (1.6, 0.5, 0.5), null); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (1.5, 0.5, 0.5))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (1.5, 0.5, 0.5))); test.Assert (JSM.IsEqual (intersection.distance, 0.0)); var intersection = GetIntersection (box, new JSM.Coord (0, 0, 0), new JSM.Coord (1, 0, 0), null); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var intersection = GetIntersection (box, new JSM.Coord (1.5, -1, 0.5), new JSM.Coord (1.5, 1, 0.5), null); test.Assert (intersection !== null); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (1.5, 0.0, 0.5))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (1.5, 0.0, 0.5))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); for (var i = -3; i <= 3; i += 0.1) { @@ -1871,21 +1870,21 @@ raySuite.AddTest ('RayTriangleModelIntersectionTest', function (test) var ray = new JSM.Ray (new JSM.Coord (0.6, 0.4, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleBodyIntersection (ray, body, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.6, 0.4, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.6, 0.4, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 2.0)); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.6, 0.4, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.6, 0.4, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 2.0)); var ray = new JSM.Ray (new JSM.Coord (0.4, 0.6, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleBodyIntersection (ray, body, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.4, 0.6, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.4, 0.6, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 2.0)); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.4, 0.6, 0.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.4, 0.6, 0.0))); test.Assert (JSM.IsEqual (intersection.distance, 2.0)); var body = new JSM.TriangleBody (); @@ -1918,21 +1917,21 @@ raySuite.AddTest ('RayTriangleModelIntersectionTest', function (test) var ray = new JSM.Ray (new JSM.Coord (0.6, 0.4, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleBodyIntersection (ray, body, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.6, 0.4, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.6, 0.4, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.6, 0.4, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.6, 0.4, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var ray = new JSM.Ray (new JSM.Coord (0.4, 0.6, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleBodyIntersection (ray, body, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.4, 0.6, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.4, 0.6, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.4, 0.6, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.4, 0.6, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var body = new JSM.TriangleBody (); @@ -1952,8 +1951,8 @@ raySuite.AddTest ('RayTriangleModelIntersectionTest', function (test) body2.AddTriangle (0, 2, 3); var box = body2.GetBoundingBox (); - test.Assert (JSM.CoordIsEqual (box.min, new JSM.Coord (0, 0, 1))); - test.Assert (JSM.CoordIsEqual (box.max, new JSM.Coord (1, 1, 1))); + test.Assert (box.min.IsEqual (new JSM.Coord (0, 0, 1))); + test.Assert (box.max.IsEqual (new JSM.Coord (1, 1, 1))); var model = new JSM.TriangleModel (); model.AddBody (body); @@ -1972,13 +1971,13 @@ raySuite.AddTest ('RayTriangleModelIntersectionTest', function (test) var ray = new JSM.Ray (new JSM.Coord (0.6, 0.4, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.6, 0.4, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.6, 0.4, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); var ray = new JSM.Ray (new JSM.Coord (0.4, 0.6, 2.0), new JSM.Vector (0.0, 0.0, -1.0), 10.0); var intersection = {}; test.Assert (JSM.RayTriangleModelIntersection (ray, model, intersection)); - test.Assert (JSM.CoordIsEqual (intersection.position, new JSM.Coord (0.4, 0.6, 1.0))); + test.Assert (intersection.position.IsEqual (new JSM.Coord (0.4, 0.6, 1.0))); test.Assert (JSM.IsEqual (intersection.distance, 1.0)); }); @@ -1989,24 +1988,24 @@ raySuite.AddTest ('RayTriangleModelIntersectionTest2', function (test) model.AddBody (body); var box = body.GetBoundingBox (); - test.Assert (JSM.CoordIsEqual (box.min, new JSM.Coord (-0.5, -0.5, -0.5))); - test.Assert (JSM.CoordIsEqual (box.max, new JSM.Coord (0.5, 0.5, 0.5))); + test.Assert (box.min.IsEqual (new JSM.Coord (-0.5, -0.5, -0.5))); + test.Assert (box.max.IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); var center = body.GetCenter (); - test.Assert (JSM.CoordIsEqual (center, new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (center.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); var sphere = body.GetBoundingSphere (); - test.Assert (JSM.CoordIsEqual (sphere.center, new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.IsEqual (sphere.radius, JSM.CoordDistance (sphere.center, box.max))); + test.Assert (sphere.center.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (JSM.IsEqual (sphere.radius, sphere.center.DistanceTo (box.max))); var triangleModel = JSM.ConvertModelToTriangleModel (model); var triangleBody = triangleModel.GetBody (0); var box = triangleBody.GetBoundingBox (); - test.Assert (JSM.CoordIsEqual (box.min, new JSM.Coord (-0.5, -0.5, -0.5))); - test.Assert (JSM.CoordIsEqual (box.max, new JSM.Coord (0.5, 0.5, 0.5))); + test.Assert (box.min.IsEqual (new JSM.Coord (-0.5, -0.5, -0.5))); + test.Assert (box.max.IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); var center = triangleBody.GetCenter (); - test.Assert (JSM.CoordIsEqual (center, new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (center.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); var sphere = triangleBody.GetBoundingSphere (); - test.Assert (JSM.CoordIsEqual (sphere.center, new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.IsEqual (sphere.radius, JSM.CoordDistance (sphere.center, box.max))); + test.Assert (sphere.center.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (JSM.IsEqual (sphere.radius, sphere.center.DistanceTo (box.max))); var ray = new JSM.Ray (new JSM.Coord (2, 0, 0), JSM.CoordSub (new JSM.Coord (0, 0, 0), new JSM.Coord (2, 0, 0.1)), 10.0); var intersection = {}; @@ -2052,7 +2051,7 @@ raySuite.AddTest ('TriangleBodyOctreeTest', function (test) return false; } if (hasBodyIntersection && hasOctreeIntersection) { - test.Assert (JSM.CoordIsEqual (bodyIntersection.position, octreeIntersection.position)); + test.Assert (bodyIntersection.position.IsEqual (octreeIntersection.position)); test.Assert (JSM.IsEqual (bodyIntersection.distance, octreeIntersection.distance)); if (checkIndex) { test.Assert (bodyIntersection.triangleIndex == octreeIntersection.userData.triangleIndex); diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index 388604d0..097340a5 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 9979a4b0..0394bb83 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index 4ec7de2b..f71aa8f0 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index c7cff6df..216f6d84 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index 0c4c5ab2..a2f30e78 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 81216275..5206916c 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -15,14 +15,13 @@ + - - diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index 5f523199..d8487461 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -15,14 +15,13 @@ + - - diff --git a/tools/documentation/jsmdoc/jsmdoc.py b/tools/documentation/jsmdoc/jsmdoc.py index 5ea856f3..885c3b9e 100644 --- a/tools/documentation/jsmdoc/jsmdoc.py +++ b/tools/documentation/jsmdoc/jsmdoc.py @@ -5,6 +5,8 @@ keywords = [ 'Function:', 'Class:', + 'Enum:', + 'Values:', 'Description:', 'Parameters:', 'Returns:', @@ -15,10 +17,12 @@ functionKeyword = keywords[0] classKeyword = keywords[1] -descriptionKeyword = keywords[2] -parametersKeyword = keywords[3] -returnsKeyword = keywords[4] -exampleKeyword = keywords[5] +enumKeyword = keywords[2] +enumValuesKeyword = keywords[3] +descriptionKeyword = keywords[4] +parametersKeyword = keywords[5] +returnsKeyword = keywords[6] +exampleKeyword = keywords[7] class SourceFileParser: def __init__ (self, fileName): @@ -42,6 +46,8 @@ def ParseDocStrings (self, docStrings): current['partType'] = functionKeyword elif classKeyword in docPart.keys (): current['partType'] = classKeyword + elif enumKeyword in docPart.keys (): + current['partType'] = enumKeyword current['partContent'] = docPart docParts.append (current) return docParts @@ -127,7 +133,7 @@ def ProcessNormalLine (keyword, line, lines, index, sections): line = lines[i].strip () keyword = self.GetKeyword (line) if keyword != None: - if keyword == parametersKeyword or keyword == returnsKeyword: + if keyword == parametersKeyword or keyword == returnsKeyword or keyword == enumValuesKeyword: i = ProcessParameterLine (keyword, line, lines, i, sections) elif keyword == exampleKeyword: i = ProcessExampleLine (keyword, line, lines, i, sections) @@ -184,6 +190,17 @@ def WriteJSON (self, tabs, file, comma): if comma: content += ',' file.Write (tabs, content, False) + +class Value: + def __init__ (self, value, description): + self.value = value + self.description = description + + def WriteJSON (self, tabs, file, comma): + content = '["' + self.value + '", "' + self.description + '"]' + if comma: + content += ',' + file.Write (tabs, content, False) class Function: def __init__ (self, name): @@ -239,7 +256,7 @@ def WriteJSON (self, tabs, file, comma): if self.HasExample (): file.Write (tabs + 1, '"example" : "' + self.example + '"', False) file.Write (tabs, '}', comma) - + class Class: def __init__ (self, name): self.name = name @@ -294,12 +311,56 @@ def WriteJSON (self, tabs, file, comma): if self.HasExample (): file.Write (tabs + 1, '"example" : "' + self.example + '"', False) file.Write (tabs, '}', comma) + + +class Enum: + def __init__ (self, name): + self.name = name + self.description = '' + self.values = [] + self.example = '' + + def GetName (self): + return self.name + + def HasDescription (self): + return self.description != '' + + def HasValues (self): + return len (self.values) > 0 + + def HasExample (self): + return self.example != '' + + def SetDescription (self, description): + self.description = description + + def AddValue (self, value): + self.values.append (value) + + def SetExample (self, example): + self.example = example + + def WriteJSON (self, tabs, file, comma): + file.Write (tabs, '"' + self.name + '" : {', False) + if self.HasDescription (): + file.Write (tabs + 1, '"description" : "' + self.description + '"', self.HasValues () or self.HasExample ()) + if self.HasValues (): + file.Write (tabs + 1, '"values" : [', False) + for i in range (0, len (self.values)): + parameter = self.values[i] + parameter.WriteJSON (tabs + 2, file, i < len (self.values) - 1) + file.Write (tabs + 1, ']', self.HasExample ()) + if self.HasExample (): + file.Write (tabs + 1, '"example" : "' + self.example + '"', False) + file.Write (tabs, '}', comma) class Module: def __init__ (self, name): self.name = name self.functions = [] self.classes = [] + self.enums = [] def IsEmpty (self): if len (self.functions) > 0: @@ -314,6 +375,9 @@ def HasFunctions (self): def HasClasses (self): return len (self.classes) > 0 + def HasEnums (self): + return len (self.enums) > 0 + def AddFunction (self, function): self.functions.append (function) @@ -326,6 +390,9 @@ def AddClassFunction (self, className, function): classVal.AddFunction (function) break + def AddEnum (self, classVal): + self.enums.append (classVal) + def WriteJSON (self, tabs, file, comma): file.Write (tabs, '"' + self.name + '" : {', False) if self.HasFunctions (): @@ -333,12 +400,18 @@ def WriteJSON (self, tabs, file, comma): for i in range (0, len (self.functions)): function = self.functions[i] function.WriteJSON (tabs + 2, file, i < len (self.functions) - 1) - file.Write (tabs + 1, '}', self.HasClasses ()) + file.Write (tabs + 1, '}', self.HasClasses () or self.HasEnums ()) if self.HasClasses (): file.Write (tabs + 1, '"classes" : {', False) for i in range (0, len (self.classes)): classVal = self.classes[i] classVal.WriteJSON (tabs + 2, file, i < len (self.classes) - 1) + file.Write (tabs + 1, '}', self.HasEnums ()) + if self.HasEnums (): + file.Write (tabs + 1, '"enums" : {', False) + for i in range (0, len (self.enums)): + enumVal = self.enums[i] + enumVal.WriteJSON (tabs + 2, file, i < len (self.enums) - 1) file.Write (tabs + 1, '}', False) file.Write (tabs, '}', comma) @@ -404,6 +477,17 @@ def ProcessDocParts (self, docParts, module): if exampleKeyword in partContent.keys (): theClass.SetExample (partContent[exampleKeyword]) module.AddClass (theClass) + elif partType == enumKeyword: + theEnum = Enum (partName) + if descriptionKeyword in partContent.keys (): + theEnum.SetDescription (partContent[descriptionKeyword]) + if enumValuesKeyword in partContent.keys (): + for value in partContent[enumValuesKeyword]: + theValue = Value (value[0], value[1]) + theEnum.AddValue (theValue) + if exampleKeyword in partContent.keys (): + theEnum.SetExample (partContent[exampleKeyword]) + module.AddEnum (theEnum) def WriteJSON (self, fileName): file = JSONFile (fileName) diff --git a/tools/documentation/test/reference/testdocumentation.json b/tools/documentation/test/reference/testdocumentation.json index 9d494a6e..b5b9629f 100644 --- a/tools/documentation/test/reference/testdocumentation.json +++ b/tools/documentation/test/reference/testdocumentation.json @@ -145,6 +145,30 @@ ["exampleTypeC", "example return value description c"] ] } + }, + "enums" : { + "ExampleEnum" : { + }, + "ExampleEnum2" : { + "description" : "Example enum 2 description." + }, + "ExampleEnum3" : { + "description" : "Example enum 3 description.", + "values" : [ + ["EnumValue1", "example enum value 1"], + ["EnumValue1", "example enum value 2"], + ["EnumValue1", "example enum value 3"] + ] + }, + "ExampleEnum4" : { + "description" : "Example enum 4 description.", + "values" : [ + ["EnumValue1", "example enum value 1"], + ["EnumValue1", "example enum value 2"], + ["EnumValue1", "example enum value 3"] + ], + "example" : "Example line 1\nExample line 2" + } } } } diff --git a/tools/documentation/test/runtest.py b/tools/documentation/test/runtest.py index 9a42eff3..d9e5231b 100644 --- a/tools/documentation/test/runtest.py +++ b/tools/documentation/test/runtest.py @@ -13,15 +13,15 @@ def Main (argv): referenceFilePath = os.path.join ('reference', 'testdocumentation.json') resultFilePath = os.path.join ('result', 'testdocumentation.json') - os.system (os.path.join ('..', 'generatejson.py') + ' TestProject testfiles.txt' + ' ' + resultFilePath) + os.system ('python ' + os.path.join ('..', 'generatejson.py') + ' TestProject testfiles.txt' + ' ' + resultFilePath) equal = filecmp.cmp (referenceFilePath, resultFilePath) if equal: print 'Succeeded.' + shutil.rmtree (resultFolder) else: print 'Failed.' - shutil.rmtree (resultFolder) return Main (sys.argv) diff --git a/tools/documentation/test/testfiles.txt b/tools/documentation/test/testfiles.txt index 0041201a..b5730cc2 100644 --- a/tools/documentation/test/testfiles.txt +++ b/tools/documentation/test/testfiles.txt @@ -2,3 +2,4 @@ testsource/module1/testfile1.js testsource/module1/testfile2.js testsource/module1/testfile3.js testsource/module2/testfile4.js +testsource/module2/testfile5.js diff --git a/tools/documentation/test/testsource/module2/testfile5.js b/tools/documentation/test/testsource/module2/testfile5.js new file mode 100644 index 00000000..ce35a6cb --- /dev/null +++ b/tools/documentation/test/testsource/module2/testfile5.js @@ -0,0 +1,29 @@ +/** +* Enum: ExampleEnum +*/ + +/** +* Enum: ExampleEnum2 +* Description: Example enum 2 description. +*/ + +/** +* Enum: ExampleEnum3 +* Description: Example enum 3 description. +* Values: +* {EnumValue1} example enum value 1 +* {EnumValue1} example enum value 2 +* {EnumValue1} example enum value 3 +*/ + +/** +* Enum: ExampleEnum4 +* Description: Example enum 4 description. +* Values: +* {EnumValue1} example enum value 1 +* {EnumValue1} example enum value 2 +* {EnumValue1} example enum value 3 +* Example: +* Example line 1 +* Example line 2 +*/ diff --git a/tools/files.txt b/tools/files.txt index c33b37cf..0d0df2e6 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -3,14 +3,13 @@ ../src/core/algorithm.js ../src/core/async.js ../src/core/check.js +../src/geometry/definitions.js ../src/geometry/coord2d.js ../src/geometry/coord.js ../src/geometry/determinant.js -../src/geometry/coordutils2d.js ../src/geometry/coordutils.js ../src/geometry/matrix.js ../src/geometry/coordsystem.js -../src/geometry/coordsystemutils.js ../src/geometry/sector.js ../src/geometry/sectorutils.js ../src/geometry/line.js From 9ab4f5362997c393e3b5d20926b0df79410c9f35 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Fri, 17 Jul 2015 17:29:50 +0200 Subject: [PATCH 09/27] Create class member functions from utility functions 2. --- build/jsmodeler.js | 447 ++++++------ documentation/jsmdoc/include/jsmdoc.css | 4 +- documentation/jsmdoc/include/jsmdoc.json | 668 +++++++++--------- sandbox/3dsdump.html | 5 - sandbox/bezier.html | 5 - sandbox/beziercurve.html | 5 - sandbox/bspline.html | 5 - sandbox/charts.html | 5 - sandbox/convexhull.html | 5 - sandbox/coplanar.html | 5 - sandbox/csg.html | 5 - sandbox/csg2.html | 5 - sandbox/curvedprism.html | 5 - sandbox/docimages.html | 5 - sandbox/doublesided.html | 5 - sandbox/githublogo.html | 5 - sandbox/heightmap.html | 5 - sandbox/hiddenline.html | 5 - sandbox/importer.html | 5 - sandbox/jsonimport.html | 5 - sandbox/jsonimporttexture.html | 5 - sandbox/minimal.html | 5 - sandbox/minimal2.html | 5 - sandbox/octree.html | 5 - sandbox/pointcloud.html | 5 - sandbox/pointcloudjson.html | 5 - sandbox/print.html | 5 - sandbox/prismwithhole.html | 5 - sandbox/randommat.html | 5 - sandbox/renderer.html | 5 - sandbox/revolved.html | 5 - sandbox/smartbuilder.html | 5 - sandbox/smartbuilder.js | 2 +- sandbox/smartbuilder2.html | 5 - sandbox/snippets/spherical.txt | 4 +- sandbox/solids.html | 5 - sandbox/specular.html | 5 - sandbox/svgonthefly.html | 5 - sandbox/svgtomodel.html | 5 - sandbox/svgtomodeltexture.html | 5 - sandbox/tasks.html | 5 - sandbox/texture.html | 5 - sandbox/tictactoecanvas.html | 5 - sandbox/triangulate.html | 5 - sandbox/triangulatewithhole.html | 7 +- sandbox/tube.html | 5 - sandbox/undermouse.html | 5 - sandbox/viewer.html | 5 - src/extras/painter.js | 8 +- src/geometry/box.js | 35 + src/geometry/boxutils.js | 35 - src/geometry/bsptree.js | 6 +- src/geometry/coord.js | 65 +- src/geometry/coord2d.js | 43 -- src/geometry/coordsystem.js | 169 +---- src/geometry/coordutils.js | 275 +++++-- src/geometry/definitions.js | 29 - src/geometry/line.js | 235 ++++++ src/geometry/lineutils.js | 206 ------ src/geometry/octree.js | 2 +- src/geometry/plane.js | 302 ++++++++ src/geometry/planeutils.js | 280 -------- src/geometry/polygonutils.js | 39 +- src/geometry/sector.js | 272 ++++++- src/geometry/sectorutils.js | 228 ------ src/geometry/transformation.js | 147 ++++ src/geometry/transformationutils.js | 146 ---- src/modeler/body.js | 12 +- src/modeler/bodyutils.js | 2 +- src/modeler/cututils.js | 6 +- src/modeler/generator.js | 6 +- src/modeler/textureutils.js | 12 +- src/viewer/navigation.js | 2 +- test/unittest/jsmodelertest.js | 5 - test/unittest/references/generator_circle.svg | 12 + test/unittest/references/generator_cone1.svg | 32 + test/unittest/references/generator_cone2.svg | 22 + test/unittest/references/generator_cuboid.svg | 14 + .../references/generator_cuboidsides.svg | 9 + .../references/generator_cylinder.svg | 32 + .../references/generator_cylindershell.svg | 82 +++ .../references/generator_function.svg | 222 ++++++ .../references/generator_functionsolid.svg | 482 +++++++++++++ test/unittest/references/generator_grid.svg | 222 ++++++ .../references/generator_lineshell.svg | 22 + test/unittest/references/generator_pie.svg | 35 + .../references/generator_polytorus.svg | 62 ++ test/unittest/references/generator_prism.svg | 11 + .../references/generator_prismshell.svg | 26 + .../references/generator_rectangle.svg | 6 + .../references/generator_revolved1.svg | 54 ++ .../references/generator_revolved2.svg | 52 ++ test/unittest/references/generator_ruled.svg | 222 ++++++ .../references/generator_segmentedcuboid.svg | 302 ++++++++ .../generator_segmentedrectangle.svg | 40 ++ test/unittest/references/generator_sphere.svg | 382 ++++++++++ .../references/generator_squaregrid.svg | 62 ++ test/unittest/references/generator_torus.svg | 202 ++++++ .../generator_triangulatedsphere.svg | 482 +++++++++++++ test/unittest/references/generator_tube.svg | 52 ++ test/unittest/tests/geometry.js | 390 +++++----- test/unittest/tests/visual.js | 62 ++ test/viewertest/cameratest.html | 5 - test/viewertest/csgtest.html | 5 - test/viewertest/importtest.html | 5 - test/viewertest/svgtomodeltest.html | 5 - test/viewertest/texturetest.html | 5 - test/viewertest/viewertest.html | 5 - test/viewertest/viewertypes.html | 5 - tools/files.txt | 5 - 110 files changed, 5300 insertions(+), 2242 deletions(-) delete mode 100644 src/geometry/boxutils.js delete mode 100644 src/geometry/lineutils.js delete mode 100644 src/geometry/planeutils.js delete mode 100644 src/geometry/sectorutils.js delete mode 100644 src/geometry/transformationutils.js create mode 100644 test/unittest/references/generator_circle.svg create mode 100644 test/unittest/references/generator_cone1.svg create mode 100644 test/unittest/references/generator_cone2.svg create mode 100644 test/unittest/references/generator_cuboid.svg create mode 100644 test/unittest/references/generator_cuboidsides.svg create mode 100644 test/unittest/references/generator_cylinder.svg create mode 100644 test/unittest/references/generator_cylindershell.svg create mode 100644 test/unittest/references/generator_function.svg create mode 100644 test/unittest/references/generator_functionsolid.svg create mode 100644 test/unittest/references/generator_grid.svg create mode 100644 test/unittest/references/generator_lineshell.svg create mode 100644 test/unittest/references/generator_pie.svg create mode 100644 test/unittest/references/generator_polytorus.svg create mode 100644 test/unittest/references/generator_prism.svg create mode 100644 test/unittest/references/generator_prismshell.svg create mode 100644 test/unittest/references/generator_rectangle.svg create mode 100644 test/unittest/references/generator_revolved1.svg create mode 100644 test/unittest/references/generator_revolved2.svg create mode 100644 test/unittest/references/generator_ruled.svg create mode 100644 test/unittest/references/generator_segmentedcuboid.svg create mode 100644 test/unittest/references/generator_segmentedrectangle.svg create mode 100644 test/unittest/references/generator_sphere.svg create mode 100644 test/unittest/references/generator_squaregrid.svg create mode 100644 test/unittest/references/generator_torus.svg create mode 100644 test/unittest/references/generator_triangulatedsphere.svg create mode 100644 test/unittest/references/generator_tube.svg diff --git a/build/jsmodeler.js b/build/jsmodeler.js index f6600d7a..ca06f06e 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,80 +1,82 @@ /* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=37};JSM.RandomNumber=function(a,b){return Math.random()*(b-a)+a};JSM.RandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1)+a)};JSM.SeededRandomInt=function(a,b,c){return Math.floor((9301*c+49297)%233280/233280*(b-a+1)+a)};JSM.ValueOrDefault=function(a,b){return void 0===a||null===a?b:a}; JSM.CopyObjectProperties=function(a,b,c){if(!(void 0===a||null===a||void 0===b||null===b))for(var d in a)if(a.hasOwnProperty(d)&&(c||void 0===b[d]||null===b[d]))b[d]=a[d]};JSM.Assert=function(a,b){if(!a){var c="Assertion failed.";void 0!==b&&null!==b&&(c+=" "+b);alert(c)}};JSM.Timer=function(){this.stop=this.start=0};JSM.Timer.prototype.Start=function(){this.start=(new Date).getTime()};JSM.Timer.prototype.Stop=function(){this.end=(new Date).getTime()}; JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter=function(){this.current=this.frames=this.start=null};JSM.FPSCounter.prototype.Get=function(a){var b=(new Date).getTime();null===this.start&&(this.start=b,this.current=this.frames=0);if(null===a||void 0===a)a=1E3;this.frames+=1;var c=b-this.start;c>=a&&(this.current=1E3*(this.frames/c),this.start=b,this.frames=0);return parseInt(this.current,10)}; -JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;ca.length||void 0===b||null===b)){var c,d;for(c=0;cJSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(g);b=b.DistanceTo(g);g=c.DistanceTo(g);c=h(l,k,m);if(JSM.IsZero(c))return d;l=h(l,a,b);k=h(k,b,g);m=h(m,a,g);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.BarycentricInterpolation=function(a,b,c,d,e,f,h){function g(a,b,c){var d=(a+b+c)/2;a=d*(d-a)*(d-b)*(d-c);return 0>a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=a[1],h=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],u=a[14],v=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*g+d*k+e*p+f*s;r[2]=c*h+d*m+e*q+f*u;r[3]=c*l+d*n+e*t+f*v;return r}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],u=a[14],v=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=g*r+h*x+l*L+k*N;F[5]=g*w+h*A+l*H+k*O;F[6]=g*y+h*B+l*C+k*J;F[7]=g*z+h*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=t*r+s*x+u*L+v*N;F[13]=t*w+s*A+u*H+v*O;F[14]=t*y+s*B+u*C+v*J;F[15]=t*z+s*K+u*E+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*g-c*f)*(n*a-p*s)-(b*h-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*h-d*g)*(k*a-p*q)-(c*l-e*g)*(k*s-n*q)+(d*l-e*h)*(k*t-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var u=b*g-c*f,v=b*h-d*f,r=b*l-e*f,w=c*h-d*g,y=c*l-e*g,z=d*l-e*h,x=k*t-m*q,A=k*s-n*q,B=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,C=u*H-v*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(g*H-h*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(t*z-s*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(h*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(s*r-q*z-a*v)/C;E[7]=(k*z-n*r+p* -v)/C;E[8]=(f*L-g*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-t*r+a*u)/C;E[11]=(m*r-k*y-p*u)/C;E[12]=(g*A-f*K-h*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(t*v-q*w-s*u)/C;E[15]=(k*w-m*v+n*u)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,g=e*e,h=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(g+h)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=g+(f+h)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=h+(f+g)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(g+h)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=g+(f+h)*b;k[6]=e*d*(1- -b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=h+(f+g)*b;k[11]=0;k[12]=(m*(g+h)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+h)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+g)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,g=c+c,h=d+d;a=b*f;var l=b*g,b=b*h,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h,h=[];h[0]=1-(k+d);h[1]=l+e;h[2]=b-g;h[3]=0;h[4]=l-e;h[5]=1-(a+d);h[6]=c+f;h[7]=0;h[8]=b+g;h[9]=c-f;h[10]=1-(a+k);h[11]=0;h[12]=0;h[13]=0;h[14]=0;h[15]=1;return h};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],u=a[14],v=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*s;r[2]=c*g+d*m+e*q+f*u;r[3]=c*l+d*n+e*t+f*v;return r}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],u=a[14],v=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*r+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ +p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=t*r+s*x+u*L+v*N;F[13]=t*w+s*A+u*H+v*O;F[14]=t*y+s*B+u*C+v*J;F[15]=t*z+s*K+u*E+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*h-c*f)*(n*a-p*s)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*s-n*q)+(d*l-e*g)*(k*t-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,r=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*t-m*q,A=k*s-n*q,B=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,C=u*H-v*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(t*z-s*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(s*r-q*z-a*v)/C;E[7]=(k*z-n*r+p* +v)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-t*r+a*u)/C;E[11]=(m*r-k*y-p*u)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(t*v-q*w-s*u)/C;E[15]=(k*w-m*v+n*u)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- +b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; -JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSystemToDirectionVectors=function(a){return new JSM.CoordSystem(a.origo,JSM.CoordSub(a.e1,a.origo),JSM.CoordSub(a.e2,a.origo),JSM.CoordSub(a.e3,a.origo))}; -JSM.CoordSystemToAbsoluteCoords=function(a){return new JSM.CoordSystem(a.origo,JSM.CoordAdd(a.e1,a.origo),JSM.CoordAdd(a.e2,a.origo),JSM.CoordAdd(a.e3,a.origo))};JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c};JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a}; -JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d};JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return JSM.GetVectorsAngle(a,b)*c};JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c};JSM.Sector2D=function(a,b){this.beg=a;this.end=b}; -JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())}; -JSM.CoordSectorPosition2D=function(a,b){var c=a.x,d=a.y,e=b.beg.x,f=b.beg.y,g=b.end.x,h=b.end.y,l=b.GetLength();if(JSM.IsZero(l))return a.IsEqual(b.beg)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";l=((c-e)*(g-e)+(d-f)*(h-f))/(l*l);if(JSM.IsLower(l,0)||JSM.IsGreater(l,1))return"CoordOutsideOfSector";f+=l*(h-f);return!JSM.IsEqual(e+l*(g-e),c)||!JSM.IsEqual(f,d)?"CoordOutsideOfSector":JSM.IsEqual(l,0)||JSM.IsEqual(l,1)?"CoordOnSectorEndCoord":"CoordInsideOfSector"}; -JSM.ProjectCoordToSector2D=function(a,b){var c=a.x,d=a.y,e=b.beg,f=b.end,g=e.x,h=e.y,l=f.x,k=f.y,m=(l-g)*(l-g)+(k-h)*(k-h);if(JSM.IsZero(m))return e;c=((l-g)*(c-g)+(k-h)*(d-h))/m;if(JSM.IsLower(c,0))return e;if(JSM.IsGreater(c,1))return f;f=JSM.CoordSub2D(f,e);f.MultiplyScalar(c);return JSM.CoordAdd2D(e,f)}; -JSM.CoordSectorPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=b.beg,g=JSM.CoordSub(b.end,b.beg),h=f.x,l=f.y,k=f.z,m=f.x+g.x,n=f.y+g.y,p=f.z+g.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return f.IsEqual(a)?"CoordOnSectorEndCoord":"CoordOutsideOfSector";c=((m-h)*(c-h)+(n-l)*(d-l)+(p-k)*(e-k))/q;g=g.Clone().MultiplyScalar(c);f=JSM.CoordAdd(f,g);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.IsLower(c,0)||JSM.IsGreater(c,1)?"CoordOutsideOfSector":JSM.IsEqual(c,0)||JSM.IsEqual(c,1)?"CoordOnSectorEndCoord": -"CoordInsideOfSector":"CoordOutsideOfSector"}; -JSM.SectorSectorPosition2D=function(a,b,c){var d=a.beg.x,e=a.beg.y,f=a.end.x,g=a.end.y,h=b.beg.x,l=b.beg.y,k=b.end.x,m=b.end.y,n=(k-h)*(e-l)-(m-l)*(d-h),p=(f-d)*(e-l)-(g-e)*(d-h);if(JSM.IsZero(n)&&JSM.IsZero(p))return c=JSM.CoordSectorPosition2D(a.beg,b),d=JSM.CoordSectorPosition2D(a.end,b),e=JSM.CoordSectorPosition2D(b.beg,a),a=JSM.CoordSectorPosition2D(b.end,a),"CoordInsideOfSector"===c||("CoordInsideOfSector"===d||"CoordInsideOfSector"===e||"CoordInsideOfSector"===a)||"CoordOnSectorEndCoord"=== -c&&"CoordOnSectorEndCoord"===d&&"CoordOnSectorEndCoord"===e&&"CoordOnSectorEndCoord"===a?"SectorsIntersectsCoincident":"CoordOnSectorEndCoord"===c||"CoordOnSectorEndCoord"===d||"CoordOnSectorEndCoord"===e||"CoordOnSectorEndCoord"===a?"SectorsIntersectsEndPoint":"SectorsDontIntersects";a=(m-l)*(f-d)-(k-h)*(g-e);if(JSM.IsZero(a))return"SectorsDontIntersects";n/=a;p/=a;if(JSM.IsLower(n,0)||JSM.IsGreater(n,1)||JSM.IsLower(p,0)||JSM.IsGreater(p,1))return"SectorsDontIntersects";void 0!==c&&(c.x=d+n*(f- -d),c.y=e+n*(g-e));return JSM.IsEqual(n,0)||JSM.IsEqual(n,1)||JSM.IsEqual(p,0)||JSM.IsEqual(p,1)?"SectorsIntersectsEndPoint":"SectorsIntersectsOnePoint"};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,g,h;for(g=0;g<=b;g++)h=a.beg.Clone().Offset(d,f),c.push(h),f+=e};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; -JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())}; -JSM.CoordLinePosition2D=function(a,b){var c=b.start,d=b.direction,c=d.x*(a.y-c.y)-d.y*(a.x-c.x);return JSM.IsPositive(c)?"CoordAtLineLeft":JSM.IsNegative(c)?"CoordAtLineRight":"CoordOnLine"}; -JSM.CoordLinePosition=function(a,b,c){var d=a.x,e=a.y,f=a.z,g=b.start;b=b.direction;var h=g.x,l=g.y,k=g.z,m=g.x+b.x,n=g.y+b.y,p=g.z+b.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==c&&c.Set(g.x,g.y,g.z),g.IsEqual(a)?"CoordOnLine":"CoordOutsideOfLine";d=b.Clone().MultiplyScalar(((m-h)*(d-h)+(n-l)*(e-l)+(p-k)*(f-k))/q);g=JSM.CoordAdd(g,d);void 0!==c&&c.Set(g.x,g.y,g.z);a=a.DistanceTo(g);return JSM.IsZero(a)?"CoordOnLine":"CoordOutsideOfLine"}; -JSM.ProjectCoordToLine=function(a,b){var c=new JSM.Coord(0,0,0),d=a.x,e=a.y,f=a.z,g=b.start,h=b.direction,l=g.x,k=g.y,m=g.z,n=g.x+h.x,p=g.y+h.y,q=g.z+h.z,t=(n-l)*(n-l)+(p-k)*(p-k)+(q-m)*(q-m);if(JSM.IsZero(t))return c.Set(g.x,g.y,g.z),c;d=h.Clone().MultiplyScalar(((n-l)*(d-l)+(p-k)*(e-k)+(q-m)*(f-m))/t);g=JSM.CoordAdd(g,d);c.Set(g.x,g.y,g.z);return c}; -JSM.LineLineClosestPoint=function(a,b,c,d){function e(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var f=a.direction.Clone().Normalize(),g=a.start,h=JSM.CoordAdd(g,f);a=b.direction.Clone().Normalize();b=b.start;var l=JSM.CoordAdd(b,a),k=[g,h,b,l],m=e(k,1,0,1,0),n=e(k,0,2,1,0),h=e(k,0,2,3,2),l=e(k,3,2,1,0),k=e(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==c&&(f.MultiplyScalar(n),f=JSM.CoordAdd(g, -f),c.Set(f.x,f.y,f.z));void 0!==d&&(a.MultiplyScalar(h),c=JSM.CoordAdd(b,a),d.Set(c.x,c.y,c.z));return!0};JSM.LineLinePosition=function(a,b,c){var d=new JSM.Coord(0,0,0),e=new JSM.Coord(0,0,0);return!JSM.LineLineClosestPoint(a,b,d,e)?"LinesIntersectsCoincident":d.IsEqual(e)?(void 0!==c&&c.Set(d.x,d.y,d.z),"LinesIntersectsOnePoint"):"LinesDontIntersects"};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b}; -JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)}; -JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())};JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)}; -JSM.IsCoordInBox=function(a,b){return JSM.IsLower(a.x,b.min.x)||JSM.IsLower(a.y,b.min.y)||JSM.IsLower(a.z,b.min.z)||JSM.IsGreater(a.x,b.max.x)||JSM.IsGreater(a.y,b.max.y)||JSM.IsGreater(a.z,b.max.z)?!1:!0};JSM.Sphere=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.Set=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.GetCenter=function(){return this.center};JSM.Sphere.prototype.GetRadius=function(){return this.radius}; +JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.ToDirectionVectors=function(){this.e1=JSM.CoordSub(this.e1,this.origo);this.e2=JSM.CoordSub(this.e2,this.origo);this.e3=JSM.CoordSub(this.e3,this.origo);return this};JSM.CoordSystem.prototype.ToAbsoluteCoords=function(){this.e1=JSM.CoordAdd(this.e1,this.origo);this.e2=JSM.CoordAdd(this.e2,this.origo);this.e3=JSM.CoordAdd(this.e3,this.origo);return this}; +JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2}; +JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; +JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: +JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| +f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.SectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? +(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint):JSM.SectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.SectorSectorPosition2D.SectorsDontIntersect;m/=h;n/=h;if(JSM.IsLower(m, +0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.SectorSectorPosition2D.SectorsIntersectEndPoint:JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; +JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; +JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: +JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,h,g;for(h=0;h<=b;h++)g=a.beg.Clone().Offset(d,f),c.push(g),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; +JSM.CoordLinePosition={CoordOnLine:0,CoordOutsideOfLine:1};JSM.LineLinePosition={LinesDontIntersect:0,LinesIntersectsOnePoint:1,LinesIntersectsCoincident:2};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; +JSM.Line2D.prototype.CoordPosition=function(a){var b=this.start,c=this.direction;a=c.x*(a.y-b.y)-c.y*(a.x-b.x);return JSM.IsPositive(a)?JSM.CoordLinePosition2D.CoordAtLineLeft:JSM.IsNegative(a)?JSM.CoordLinePosition2D.CoordAtLineRight:JSM.CoordLinePosition2D.CoordOnLine};JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b}; +JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: +JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-h)*(k-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; +JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,g),k=[f,h,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),h=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= +JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(g.MultiplyScalar(h),b=JSM.CoordAdd(a,g),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; +JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b}; +JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)};JSM.Box.prototype.IsCoordInside=function(a){return JSM.IsLower(a.x,this.min.x)||JSM.IsLower(a.y,this.min.y)||JSM.IsLower(a.z,this.min.z)||JSM.IsGreater(a.x,this.max.x)||JSM.IsGreater(a.y,this.max.y)||JSM.IsGreater(a.z,this.max.z)?!1:!0};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())}; +JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)};JSM.Sphere=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.Set=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.GetCenter=function(){return this.center};JSM.Sphere.prototype.GetRadius=function(){return this.radius}; JSM.Sphere.prototype.Clone=function(){return new JSM.Sphere(this.center.Clone(),this.radius)};JSM.Transformation=function(){this.matrix=JSM.MatrixIdentity()};JSM.Transformation.prototype.GetMatrix=function(){return this.matrix};JSM.Transformation.prototype.SetMatrix=function(a){this.matrix=a};JSM.Transformation.prototype.Append=function(a){this.matrix=JSM.MatrixMultiply(this.matrix,a.matrix)};JSM.Transformation.prototype.Apply=function(a){return JSM.ApplyTransformation(this.matrix,a)}; JSM.Transformation.prototype.Clone=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixClone(this.matrix);return a};JSM.IdentityTransformation=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixIdentity();return a};JSM.TranslationTransformation=function(a){var b=new JSM.Transformation;b.matrix=JSM.MatrixTranslation(a.x,a.y,a.z);return b};JSM.OffsetTransformation=function(a,b){var c=a.Clone().Normalize().Clone().MultiplyScalar(b);return JSM.TranslationTransformation(c)}; JSM.RotationTransformation=function(a,b,c){var d=new JSM.Transformation;d.matrix=JSM.MatrixRotation(a,b,c);return d};JSM.RotationXTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationX(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationXTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationY(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationYTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; -JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)}; -JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)};JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; -JSM.CoordPlanePosition=function(a,b){var c=b.a*a.x+b.b*a.y+b.c*a.z+b.d;return JSM.IsPositive(c)?"CoordInFrontOfPlane":JSM.IsNegative(c)?"CoordAtBackOfPlane":"CoordOnPlane"}; -JSM.LinePlanePosition=function(a,b,c){var d=a.direction.Clone().Normalize(),e=a.start.x,f=a.start.y,g=a.start.z,h=b.a,l=b.b,k=b.c;b=b.d;var m=h*(e-(a.start.x+d.x))+l*(f-(a.start.y+d.y))+k*(g-(a.start.z+d.z));if(JSM.IsZero(m))return"LineParallelToPlane";void 0!==c&&(d.MultiplyScalar((h*e+l*f+k*g+b)/m),a=JSM.CoordAdd(a.start,d),c.Set(a.x,a.y,a.z));return"LineIntersectsPlane"}; -JSM.LinePlaneIntersection=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,g=a.start.x+c.x,h=a.start.y+c.y,l=a.start.z+c.z,k=b.a,m=b.b,n=b.c,p=b.d,q=new JSM.Coord(0,0,0),g=k*(d-g)+m*(e-h)+n*(f-l);if(JSM.IsZero(g))return q;c.MultiplyScalar((k*d+m*e+n*f+p)/g);return q=JSM.CoordAdd(a.start,c)};JSM.CoordPlaneSignedDistance=function(a,b){var c=b.a,d=b.b,e=b.c;return(c*a.x+d*a.y+e*a.z+b.d)/Math.sqrt(c*c+d*d+e*e)}; -JSM.CoordPlaneDistance=function(a,b){return Math.abs(JSM.CoordPlaneSignedDistance(a,b))};JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,g=c.a,h=c.b,l=c.c;c=c.d;var k=g*(b-(a.x+d.x))+h*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((g*b+h*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(g*b+h*e+l*f+c)&&(a=-a);return a}; -JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))};JSM.ProjectCoordToPlane=function(a,b){var c=a.x,d=a.y,e=a.z,f=b.a,g=b.b,h=b.c,l=b.d,k=JSM.CoordPlaneDistance(a,b);JSM.IsGreater(f*c+g*d+h*e+l,0)&&(k=-k);c=(new JSM.Coord(f,g,h)).Normalize();return a.Clone().Offset(c,k)}; -JSM.Project=function(a,b,c,d,e,f,g,h,l){b=JSM.MatrixView(b,c,d);g=JSM.MatrixPerspective(e,f,g,h);e=new JSM.Coord(0,0,0);h=[];f=[];h[0]=a.x;h[1]=a.y;h[2]=a.z;h[3]=1;f=JSM.MatrixVectorMultiply(g,JSM.MatrixVectorMultiply(b,h));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; +JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.CoordPlanePosition={CoordOnPlane:0,CoordInFrontOfPlane:1,CoordAtBackOfPlane:2};JSM.LinePlanePosition={LineParallelToPlane:0,LineIntersectsPlane:1};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d}; +JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)};JSM.Plane.prototype.CoordSignedDistance=function(a){var b=this.a,c=this.b,d=this.c;return(b*a.x+c*a.y+d*a.z+this.d)/Math.sqrt(b*b+c*c+d*d)};JSM.Plane.prototype.CoordDistance=function(a){a=this.CoordSignedDistance(a);return Math.abs(a)}; +JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; +JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,l=this.c,k=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; +JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+h*d+g*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; +JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; +JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((h*b+g*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; +JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;q=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& -(g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var g=[],h,l,k;for(h=0;hb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf)return[];a=[];var h=[],g,l,k;for(g=0;gb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;c=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, b.children[7]):null};JSM.Octree.prototype.SplitNode=function(a){var b=this,c=JSM.CreateOctreeChildNodes(a.box,function(c){return b.CreateNewNode(a,c)});if(null===c)return!1;a.children=c;c=a.coords;a.coords=[];var d,e;for(d=0;db.VertexCount())return!1;var d;if(null===a.polygon){d=JSM.CalculateNormal(b.vertices);var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0k;k++)0===k?m=e:1===k?m=f:2===k&&(m=g),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(h=k,l=n);if(-1===h)return d;b=null;0===h?b=new JSM.CoordSystem(c.origo,f,g,new JSM.Coord(0,0,0)):1===h?b=new JSM.CoordSystem(c.origo,e,g,new JSM.Coord(0,0,0)):2===h&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== -b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(JSM.VectorsAreCollinear(e,b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];b=new JSM.Line(c.origo,e);var f=JSM.ProjectCoordToLine(a,b);b=JSM.CoordSignedDistance(c.origo,f,e);var g=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,g,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; -JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,g;for(f=0;fk;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var h=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; +JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fe;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),u.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(u)}}var f=new JSM.Body;(function(){var d; -for(d=0;dw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var g,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),g=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, -p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,g,n,p);else if(g=!0,void 0!==c&&c&&(g=!1),q=JSM.CalculateBodyPolygonNormal(a,b),g){g=new JSM.Polygon;for(b=0;bw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, +p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, -c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=g(b,p.v0,c,d,f),p.n1=g(b,p.v1,c,d,f),p.n2=g(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eh))if(3==h)f=g.GetVertexIndex(0),h=g.GetVertexIndex(1),k=g.GetVertexIndex(2),b(c,g,f,h,k);else{l= -new JSM.Polygon;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(g[k]=-1,h[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(g[k]=1,h[k]=c[k],l=!1):g[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==g[k]&&!JSM.IsZero(e[k])?l[k]=(h[k]-f[k])/e[k]:l[k]=-1;g=0;for(k=1;3>k;k++)JSM.IsLower(l[g],l[k])&&(g=k);if(JSM.IsNegative(l[g]))return null; -var m=[0,0,0];for(k=0;3>k;k++)if(g!=k){if(m[k]=f[k]+l[g]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=h[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; +JSM.RayBoxIntersection=function(a,b,c){var d=a.GetOrigin(),e=a.GetDirection(),f=JSM.CoordToArray(d),e=JSM.CoordToArray(e);b=JSM.CoordToArray(b);c=JSM.CoordToArray(c);var h=[0,0,0],g=[0,0,0],l=!0,k;for(k=0;3>k;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; +var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -269,37 +270,37 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,g,h,l,k,m,n,p,q,t,s,u,v,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;g=40992;h=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;u=41728;v=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,t,s,u,v,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;u=41728;v=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ 255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= [1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==g?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==h?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= -W(a,b,p)):b==s?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,l;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else D("Skip chunk ("+c.toString(16)+", "+d+")",4), a.Skip(d-6)})}function ca(a,b,c){D("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?D("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?D("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):D("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){D("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==B?ca(a,b,c):(D("Skip chunk ("+ b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],s;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=h(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=h(a,"mtllib"),n=g(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); -var b,c;for(b=0;bn.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,g,h,l,k;for(f=0;fc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= @@ -309,9 +310,9 @@ JSM.ImportFileList.prototype.InitFromURLs=function(a){this.originalList=a;this.d JSM.ImportFileList.prototype.GetInputList=function(){var a=[],b,c,d;for(b=0;br;r++)v[r].z=n-c;r=JSM.GeneratePrism(v,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rr;r++)v[r].z=n-c;r=JSM.GeneratePrism(v,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rg;g++)k=0===g?h.pgon1:h.pgon2,-1===k&&(k=0===g?h.pgon2:h.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],g,h,l,k;for(l=0;lh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lthis.cameraFarDistanceLimit)return 0;c*=0.1;a||(c*=-1);this.camera.eye.Offset(b,c)};JSM.Navigation.prototype.DrawCallback=function(){void 0!==this.drawCallback&&null!==this.drawCallback&&this.drawCallback()};JSM.Navigation.prototype.ResizeCallback=function(){void 0!==this.resizeCallback&&null!==this.resizeCallback&&this.resizeCallback()}; JSM.Navigation.prototype.OnMouseDown=function(a){a.preventDefault();this.mouse.Down(a,this.canvas)};JSM.Navigation.prototype.OnMouseMove=function(a){a.preventDefault();this.mouse.Move(a,this.canvas);this.mouse.down&&(a=0,1==this.mouse.button?this.cameraEnableOrbit&&(a=0.5,this.Orbit(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()):3==this.mouse.button&&this.cameraEnablePan&&(a=0.001*this.camera.eye.DistanceTo(this.camera.center),this.Pan(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()))}; @@ -527,7 +528,7 @@ JSM.SoftwareViewer.prototype.GetBoundingSphere=function(){var a=this.GetCenter() JSM.SoftwareViewer.prototype.Draw=function(){var a,b;this.drawer.Clear();for(a=0;a - - - - - diff --git a/sandbox/bezier.html b/sandbox/bezier.html index 0830470b..916957c1 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index 9972193c..95f1896a 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/bspline.html b/sandbox/bspline.html index dc070d1a..fcc066d2 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/charts.html b/sandbox/charts.html index 2a184d4a..8c028135 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index e4f50a2f..d7d99b85 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index c6c75502..3e19fc28 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/csg.html b/sandbox/csg.html index fcf1b151..d17d048e 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/csg2.html b/sandbox/csg2.html index 2f4392f4..d9260bde 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index caaccece..8cbbbe9d 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/docimages.html b/sandbox/docimages.html index cadcba10..d09889af 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index 6974d3fc..b97c61d1 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index 9c2d04c0..c1727c3a 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index d708edbd..73f6298a 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 0ceb7e4b..b7f3e0de 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/importer.html b/sandbox/importer.html index 2d68a9a9..88d1187a 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index 69127363..21734a9e 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index 967695f4..c00ab9d3 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/minimal.html b/sandbox/minimal.html index f401c559..ed76d204 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index ceb784e0..b0ccb83c 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/octree.html b/sandbox/octree.html index 67c91267..485dc951 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 77fc2aca..834234cc 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index ae82ed53..88b6819e 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/print.html b/sandbox/print.html index 3b7395ce..610a065a 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index 82debe0a..399db324 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/randommat.html b/sandbox/randommat.html index b9e6c017..16ea4040 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/renderer.html b/sandbox/renderer.html index 03f3eda5..a35574cc 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/revolved.html b/sandbox/revolved.html index d6fb6517..1644ed3d 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index ac39b262..efab5cbd 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/smartbuilder.js b/sandbox/smartbuilder.js index 04ffa1ab..7a65d566 100644 --- a/sandbox/smartbuilder.js +++ b/sandbox/smartbuilder.js @@ -28,7 +28,7 @@ JSM.BodySmartBuilder.prototype.AddPolygon = function (coords) for (i = 0; i < vertices.length; i++) { index = vertices[i]; coord = body.GetVertexPosition (index); - if (JSM.CoordSectorPosition (coord, sector) == 'CoordInsideOfSector') { + if (sector.CoordPosition () == JSM.CoordSectorPosition.CoordInsideOfSector) { result.push (index); } } diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index 380f2b00..926f1cb2 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/snippets/spherical.txt b/sandbox/snippets/spherical.txt index 24682891..8ba1ac8b 100644 --- a/sandbox/snippets/spherical.txt +++ b/sandbox/snippets/spherical.txt @@ -13,13 +13,13 @@ JSM.CalculateSphericalTextureCoord = function (coord, normal, system) var result = new JSM.Coord2D (0.0, 0.0); var e3Direction = system.e3.Clone ().Normalize (); - if (JSM.VectorsAreCollinear (e3Direction, normal)) { + if (e3Direction.IsCollinearWith (normal)) { result = JSM.CalculateCubicTextureCoord (coord, normal, system); return [result, 0.0]; } var baseLine = new JSM.Line (system.origo, e3Direction); - var projectedCoord = JSM.ProjectCoordToLine (coord, baseLine); + var projectedCoord = baseLine.ProjectCoord (coord); var radius = system.e1.Length (); if (!coord.IsEqual (projectedCoord)) { diff --git a/sandbox/solids.html b/sandbox/solids.html index efed404f..44bbfd28 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/specular.html b/sandbox/specular.html index 6ec42acf..5d18c97f 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index d406afd3..ac74c2be 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index ca8def34..8cca080d 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index acc2cd13..039c71af 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/tasks.html b/sandbox/tasks.html index e3f91b8d..93bd1bc8 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/texture.html b/sandbox/texture.html index 9ed5f8e5..b0916791 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index 6a52dff5..c2d6f404 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -20,16 +20,11 @@ - - - - - diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index 258bfe5d..7ea5e625 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/triangulatewithhole.html b/sandbox/triangulatewithhole.html index 778ab729..3f11ab06 100644 --- a/sandbox/triangulatewithhole.html +++ b/sandbox/triangulatewithhole.html @@ -7,7 +7,7 @@ - + @@ -22,16 +22,11 @@ - - - - - diff --git a/sandbox/tube.html b/sandbox/tube.html index b834e531..fa1d7645 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index fea19720..bf39f25c 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -21,16 +21,11 @@ - - - - - diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 8af1721e..08fedea0 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -21,16 +21,11 @@ - - - - - diff --git a/src/extras/painter.js b/src/extras/painter.js index 9e02ef70..c5a4c238 100644 --- a/src/extras/painter.js +++ b/src/extras/painter.js @@ -46,7 +46,7 @@ JSM.OrderPolygons = function (body, eye, center) polygon = body.GetPolygon (i); for (j = 0; j < polygon.VertexIndexCount (); j++) { coord = body.GetVertexPosition (polygon.GetVertexIndex (j)); - distance = JSM.CoordPlaneDistance (coord, cameraPlane); + distance = cameraPlane.CoordDistance (coord); if (JSM.IsLower (distance, minDistance)) { minDistance = distance; } @@ -59,7 +59,7 @@ JSM.OrderPolygons = function (body, eye, center) maxViewDistances.push (maxDistance); polygonCenter = GetPolygonCenter (i); - polygonCenterDistance = JSM.CoordPlaneDistance (polygonCenter, cameraPlane); + polygonCenterDistance = cameraPlane.CoordDistance (polygonCenter); polygonCenters.push (polygonCenter); polygonCenterDistances.push (polygonCenterDistance); @@ -91,7 +91,7 @@ JSM.OrderPolygons = function (body, eye, center) var sPolygon = body.GetPolygon (s); for (i = 0; i < sPolygon.VertexIndexCount (); i++) { coord = body.GetVertexPosition (sPolygon.GetVertexIndex (i)); - if (JSM.CoordPlanePosition (coord, pPlane) === 'CoordInFrontOfPlane') { + if (pPlane.CoordPosition (coord) === JSM.CoordPlanePosition.CoordInFrontOfPlane) { isSBehindP = false; break; } @@ -105,7 +105,7 @@ JSM.OrderPolygons = function (body, eye, center) var pPolygon = body.GetPolygon (p); for (i = 0; i < pPolygon.VertexIndexCount (); i++) { coord = body.GetVertexPosition (pPolygon.GetVertexIndex (i)); - if (JSM.CoordPlanePosition (coord, sPlane) === 'CoordAtBackOfPlane') { + if (sPlane.CoordPosition (coord) === JSM.CoordPlanePosition.CoordAtBackOfPlane) { isPFrontOfS = false; break; } diff --git a/src/geometry/box.js b/src/geometry/box.js index 6979ec8b..95257966 100644 --- a/src/geometry/box.js +++ b/src/geometry/box.js @@ -94,6 +94,25 @@ JSM.Box.prototype.GetSize = function () return JSM.CoordSub (this.max, this.min); }; +/** +* Function: Box.IsCoordInside +* Description: Determines if the given coordinate is inside the box. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {boolean} the result +*/ +JSM.Box.prototype.IsCoordInside = function (coord) +{ + if (JSM.IsLower (coord.x, this.min.x) || JSM.IsLower (coord.y, this.min.y) || JSM.IsLower (coord.z, this.min.z)) { + return false; + } + if (JSM.IsGreater (coord.x, this.max.x) || JSM.IsGreater (coord.y, this.max.y) || JSM.IsGreater (coord.z, this.max.z)) { + return false; + } + return true; +}; + /** * Function: Box.Clone * Description: Clones the box. @@ -104,3 +123,19 @@ JSM.Box.prototype.Clone = function () { return new JSM.Box (this.min.Clone (), this.max.Clone ()); }; + +/** +* Function: BoxUnion +* Description: Calculates the union of two 3D boxes. +* Parameters: +* aBox {Box} the first box +* bBox {Box} the second box +* Returns: +* {Box} the result +*/ +JSM.BoxUnion = function (aBox, bBox) +{ + var min = new JSM.Coord (JSM.Minimum (aBox.min.x, bBox.min.x), JSM.Minimum (aBox.min.y, bBox.min.y), JSM.Minimum (aBox.min.z, bBox.min.z)); + var max = new JSM.Coord (JSM.Maximum (aBox.max.x, bBox.max.x), JSM.Maximum (aBox.max.y, bBox.max.y), JSM.Maximum (aBox.max.z, bBox.max.z)); + return new JSM.Box (min, max); +}; diff --git a/src/geometry/boxutils.js b/src/geometry/boxutils.js deleted file mode 100644 index daa13de1..00000000 --- a/src/geometry/boxutils.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* Function: BoxUnion -* Description: Calculates the union of two 3D boxes. -* Parameters: -* aBox {Box} the first box -* bBox {Box} the second box -* Returns: -* {Box} the result -*/ -JSM.BoxUnion = function (aBox, bBox) -{ - var min = new JSM.Coord (JSM.Minimum (aBox.min.x, bBox.min.x), JSM.Minimum (aBox.min.y, bBox.min.y), JSM.Minimum (aBox.min.z, bBox.min.z)); - var max = new JSM.Coord (JSM.Maximum (aBox.max.x, bBox.max.x), JSM.Maximum (aBox.max.y, bBox.max.y), JSM.Maximum (aBox.max.z, bBox.max.z)); - return new JSM.Box (min, max); -}; - -/** -* Function: IsCoordInBox -* Description: Determines if a coordinate is inside a box. -* Parameters: -* coord {Coord} the coordinate -* box {Box} the box -* Returns: -* {boolean} the result -*/ -JSM.IsCoordInBox = function (coord, box) -{ - if (JSM.IsLower (coord.x, box.min.x) || JSM.IsLower (coord.y, box.min.y) || JSM.IsLower (coord.z, box.min.z)) { - return false; - } - if (JSM.IsGreater (coord.x, box.max.x) || JSM.IsGreater (coord.y, box.max.y) || JSM.IsGreater (coord.z, box.max.z)) { - return false; - } - return true; -}; diff --git a/src/geometry/bsptree.js b/src/geometry/bsptree.js index 24b7e8d2..2f08a1ce 100644 --- a/src/geometry/bsptree.js +++ b/src/geometry/bsptree.js @@ -288,12 +288,12 @@ JSM.TraverseBSPTreeForEyePosition = function (bspTree, eyePosition, nodeFound) function TraverseNode (node) { if (node !== null) { - var coordPlanePosition = JSM.CoordPlanePosition (eyePosition, node.plane); - if (coordPlanePosition == 'CoordInFrontOfPlane') { + var coordPlanePosition = node.plane.CoordPosition (eyePosition); + if (coordPlanePosition == JSM.CoordPlanePosition.CoordInFrontOfPlane) { TraverseNode (node.inside); nodeFound (node); TraverseNode (node.outside); - } else if (coordPlanePosition == 'CoordAtBackOfPlane') { + } else if (coordPlanePosition == JSM.CoordPlanePosition.CoordAtBackOfPlane) { TraverseNode (node.outside); nodeFound (node); TraverseNode (node.inside); diff --git a/src/geometry/coord.js b/src/geometry/coord.js index 31427be0..6d9329d3 100644 --- a/src/geometry/coord.js +++ b/src/geometry/coord.js @@ -68,6 +68,39 @@ JSM.Coord.prototype.DistanceTo = function (coord) return Math.sqrt ((coord.x - this.x) * (coord.x - this.x) + (coord.y - this.y) * (coord.y - this.y) + (coord.z - this.z) * (coord.z - this.z)); }; +/** +* Function: Coord.AngleTo +* Description: Calculates the coordinate vector angle to the given one. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {number} the result +*/ +JSM.Coord.prototype.AngleTo = function (coord) +{ + var aDirection = this.Clone ().Normalize (); + var bDirection = coord.Clone ().Normalize (); + if (aDirection.IsEqual (bDirection)) { + return 0.0; + } + var product = JSM.VectorDot (aDirection, bDirection); + return JSM.ArcCos (product); +}; + +/** +* Function: Coord.IsCollinearWith +* Description: Calculates the coordinate vector is collinear with the given one. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {boolean} the result +*/ +JSM.Coord.prototype.IsCollinearWith = function (coord) +{ + var angle = this.AngleTo (coord); + return JSM.IsEqual (angle, 0.0) || JSM.IsEqual (angle, Math.PI); +}; + /** * Function: Coord.Length * Description: Calculates the length of the coordinate vector. @@ -192,6 +225,24 @@ JSM.Coord.prototype.ToString = function () return ('(' + this.x + ', ' + this.y + ', ' + this.z + ')'); }; +/** +* Function: Coord.ToCoord2D +* Description: Converts the coordinate to a 2D coordinate. +* Parameters: +* normal {Vector} the normal vector for conversion +* Returns: +* {Coord2D} the result +*/ +JSM.Coord.prototype.ToCoord2D = function (normal) +{ + var origo = new JSM.Coord (0.0, 0.0, 0.0); + var zNormal = new JSM.Vector (0.0, 0.0, 1.0); + var axis = JSM.VectorCross (normal, zNormal); + var angle = normal.AngleTo (zNormal); + var rotated = this.Clone ().Rotate (axis, angle, origo); + return new JSM.Coord2D (rotated.x, rotated.y); +}; + /** * Function: Coord.Clone * Description: Clones the coordinate. @@ -263,20 +314,6 @@ JSM.CoordSub = function (a, b) return new JSM.Coord (a.x - b.x, a.y - b.y, a.z - b.z); }; -/** -* Function: MidCoord -* Description: Calculates the coordinate in the middle of two coordinates. -* Parameters: -* a {Coord} first coordinate -* b {Coord} second coordinate -* Returns: -* {Coord} the result -*/ -JSM.MidCoord = function (a, b) -{ - return new JSM.Coord ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0, (a.z + b.z) / 2.0); -}; - /** * Function: VectorDot * Description: Calculates the dot product of two vectors. diff --git a/src/geometry/coord2d.js b/src/geometry/coord2d.js index bbae0c93..01b25704 100644 --- a/src/geometry/coord2d.js +++ b/src/geometry/coord2d.js @@ -240,46 +240,3 @@ JSM.CoordSub2D = function (a, b) { return new JSM.Coord2D (a.x - b.x, a.y - b.y, a.z - b.z); }; - -/** -* Function: MidCoord2D -* Description: Calculates the coordinate in the middle of two coordinates. -* Parameters: -* a {Coord2D} first coordinate -* b {Coord2D} second coordinate -* Returns: -* {Coord2D} the result -*/ -JSM.MidCoord2D = function (a, b) -{ - return new JSM.Coord2D ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0); -}; - -/** -* Function: CoordOrientation2D -* Description: Calculates the turn type of three coordinates. -* Parameters: -* a {Coord2D} the first coordinate -* b {Coord2D} the second coordinate -* c {Coord2D} the third coordinate -* Returns: -* {Orientation} the result -*/ -JSM.CoordOrientation2D = function (a, b, c) -{ - var m00 = a.x; - var m01 = a.y; - var m10 = b.x; - var m11 = b.y; - var m20 = c.x; - var m21 = c.y; - - var determinant = m00 * m11 + m01 * m20 + m10 * m21 - m11 * m20 - m01 * m10 - m00 * m21; - if (JSM.IsPositive (determinant)) { - return JSM.Orientation.CounterClockwise; - } else if (JSM.IsNegative (determinant)) { - return JSM.Orientation.Clockwise; - } - - return JSM.Orientation.Invalid; -}; diff --git a/src/geometry/coordsystem.js b/src/geometry/coordsystem.js index 5e43b7f7..5f47a52a 100644 --- a/src/geometry/coordsystem.js +++ b/src/geometry/coordsystem.js @@ -33,169 +33,40 @@ JSM.CoordSystem.prototype.Set = function (origo, e1, e2, e3) }; /** -* Function: CoordSystem.Clone -* Description: Clones the coordinate system. -* Returns: -* {CoordSystem} a cloned instance -*/ -JSM.CoordSystem.prototype.Clone = function () -{ - return new JSM.CoordSystem (this.origo.Clone (), this.e1.Clone (), this.e2.Clone (), this.e3.Clone ()); -}; - -/** -* Function: CoordSystemToDirectionVectors +* Function: CoordSystem.CoordSystemToDirectionVectors * Description: Converts coordinate system vectors to origo relative direction vectors. -* Parameters: -* system {CoordSystem} the coordinate system -* Returns: -* {CoordSystem} the result -*/ -JSM.CoordSystemToDirectionVectors = function (system) -{ - return new JSM.CoordSystem ( - system.origo, - JSM.CoordSub (system.e1, system.origo), - JSM.CoordSub (system.e2, system.origo), - JSM.CoordSub (system.e3, system.origo) - ); -}; - -/** -* Function: CoordSystemToAbsoluteCoords -* Description: Converts coordinate system vectors to absolute coordinates. -* Parameters: -* system {CoordSystem} the coordinate system -* Returns: -* {CoordSystem} the result -*/ -JSM.CoordSystemToAbsoluteCoords = function (system) -{ - return new JSM.CoordSystem ( - system.origo, - JSM.CoordAdd (system.e1, system.origo), - JSM.CoordAdd (system.e2, system.origo), - JSM.CoordAdd (system.e3, system.origo) - ); -}; - -/** -* Function: PolarToCartesian -* Description: Converts a polar coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* theta {number} the angle component -* Returns: -* {Coord2D} the result -*/ -JSM.PolarToCartesian = function (radius, theta) -{ - var result = new JSM.Coord2D (0.0, 0.0); - result.x = radius * Math.cos (theta); - result.y = radius * Math.sin (theta); - return result; -}; - - -/** -* Function: GetArcLengthFromAngle -* Description: Calculates arc length from radius and angle. -* Parameters: -* radius {number} the radius of the circle -* theta {number} the angle of rotation -* Returns: -* {number} the result -*/ -JSM.GetArcLengthFromAngle = function (radius, theta) -{ - return theta * radius; -}; - -/** -* Function: GetAngleFromArcLength -* Description: Calculates angle from arc length. -* Parameters: -* radius {number} the radius of the circle -* arcLength {number} the arc length * Returns: -* {number} the result +* {CoordSystem} this pointer */ -JSM.GetAngleFromArcLength = function (radius, arcLength) +JSM.CoordSystem.prototype.ToDirectionVectors = function () { - if (JSM.IsEqual (radius, 0.0)) { - return 0.0; - } - - return arcLength / radius; + this.e1 = JSM.CoordSub (this.e1, this.origo); + this.e2 = JSM.CoordSub (this.e2, this.origo); + this.e3 = JSM.CoordSub (this.e3, this.origo); + return this; }; /** -* Function: SphericalToCartesian -* Description: Converts a spherical coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* theta {number} the angle component -* phi {number} the phi component +* Function: CoordSystem.CoordSystemToAbsoluteCoords +* Description: Converts the coordinate system vectors to absolute coordinates. * Returns: -* {Coord} the result +* {CoordSystem} this pointer */ -JSM.SphericalToCartesian = function (radius, theta, phi) +JSM.CoordSystem.prototype.ToAbsoluteCoords = function () { - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = radius * Math.sin (theta) * Math.cos (phi); - result.y = radius * Math.sin (theta) * Math.sin (phi); - result.z = radius * Math.cos (theta); - return result; + this.e1 = JSM.CoordAdd (this.e1, this.origo); + this.e2 = JSM.CoordAdd (this.e2, this.origo); + this.e3 = JSM.CoordAdd (this.e3, this.origo); + return this; }; /** -* Function: CylindricalToCartesian -* Description: Converts a cylindrical coordinate to a cartesian coordinate. -* Parameters: -* radius {number} the radius component -* height {number} the height component -* theta {number} the theta component -* Returns: -* {Coord} the result -*/ -JSM.CylindricalToCartesian = function (radius, height, theta) -{ - var result = new JSM.Coord (0.0, 0.0, 0.0); - result.x = radius * Math.cos (theta); - result.y = radius * Math.sin (theta); - result.z = height; - return result; -}; - -/** -* Function: GetArcLength -* Description: Calculates arc length between two vectors. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* radius {number} the radius component -* Returns: -* {number} the result -*/ -JSM.GetArcLength = function (a, b, radius) -{ - var angle = JSM.GetVectorsAngle (a, b); - return angle * radius; -}; - -/** -* Function: GetFullArcLength -* Description: Calculates arc length between two vectors with the given normal vector. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* radius {number} the radius component -* normal {Vector} the normal vector +* Function: CoordSystem.Clone +* Description: Clones the coordinate system. * Returns: -* {number} the result +* {CoordSystem} a cloned instance */ -JSM.GetFullArcLength = function (a, b, radius, normal) +JSM.CoordSystem.prototype.Clone = function () { - var angle = JSM.GetVectorsFullAngle (a, b, normal); - return angle * radius; + return new JSM.CoordSystem (this.origo.Clone (), this.e1.Clone (), this.e2.Clone (), this.e3.Clone ()); }; diff --git a/src/geometry/coordutils.js b/src/geometry/coordutils.js index 7a7c59e5..e5ce1f2f 100644 --- a/src/geometry/coordutils.js +++ b/src/geometry/coordutils.js @@ -1,3 +1,138 @@ +/** +* Enum: Orientation +* Description: Orientation of coordinates. +* Values: +* {Invalid} invalid orientation or collinear +* {CounterClockwise} counter clockwise orientation +* {Clockwise} clockwise orientation +*/ +JSM.Orientation = { + Invalid : 0, + CounterClockwise : 1, + Clockwise : 2 +}; + +/** +* Enum: Complexity +* Description: Complexity of polygon. +* Values: +* {Invalid} invalid polygon +* {Convex} convex polygon +* {Concave} concave polygon +*/ +JSM.Complexity = { + Invalid : 0, + Convex : 1, + Concave : 2 +}; + +/** +* Function: MidCoord2D +* Description: Calculates the coordinate in the middle of two coordinates. +* Parameters: +* a {Coord2D} first coordinate +* b {Coord2D} second coordinate +* Returns: +* {Coord2D} the result +*/ +JSM.MidCoord2D = function (a, b) +{ + return new JSM.Coord2D ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0); +}; + +/** +* Function: CoordOrientation2D +* Description: Calculates the turn type of three coordinates. +* Parameters: +* a {Coord2D} the first coordinate +* b {Coord2D} the second coordinate +* c {Coord2D} the third coordinate +* Returns: +* {Orientation} the result +*/ +JSM.CoordOrientation2D = function (a, b, c) +{ + var m00 = a.x; + var m01 = a.y; + var m10 = b.x; + var m11 = b.y; + var m20 = c.x; + var m21 = c.y; + + var determinant = m00 * m11 + m01 * m20 + m10 * m21 - m11 * m20 - m01 * m10 - m00 * m21; + if (JSM.IsPositive (determinant)) { + return JSM.Orientation.CounterClockwise; + } else if (JSM.IsNegative (determinant)) { + return JSM.Orientation.Clockwise; + } + + return JSM.Orientation.Invalid; +}; + + +/** +* Function: PolarToCartesian +* Description: Converts a polar coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* theta {number} the angle component +* Returns: +* {Coord2D} the result +*/ +JSM.PolarToCartesian = function (radius, theta) +{ + var result = new JSM.Coord2D (0.0, 0.0); + result.x = radius * Math.cos (theta); + result.y = radius * Math.sin (theta); + return result; +}; + +/** +* Function: GetArcLengthFromAngle +* Description: Calculates arc length from radius and angle. +* Parameters: +* radius {number} the radius of the circle +* theta {number} the angle of rotation +* Returns: +* {number} the result +*/ +JSM.GetArcLengthFromAngle = function (radius, theta) +{ + return theta * radius; +}; + +/** +* Function: GetAngleFromArcLength +* Description: Calculates angle from arc length. +* Parameters: +* radius {number} the radius of the circle +* arcLength {number} the arc length +* Returns: +* {number} the result +*/ +JSM.GetAngleFromArcLength = function (radius, arcLength) +{ + if (JSM.IsEqual (radius, 0.0)) { + return 0.0; + } + + return arcLength / radius; +}; + +/** +* Function: MidCoord +* Description: Calculates the coordinate in the middle of two coordinates. +* Parameters: +* a {Coord} first coordinate +* b {Coord} second coordinate +* Returns: +* {Coord} the result +*/ +JSM.MidCoord = function (a, b) +{ + return new JSM.Coord ((a.x + b.x) / 2.0, (a.y + b.y) / 2.0, (a.z + b.z) / 2.0); +}; + /** * Function: CoordSignedDistance * Description: Calculates the distance of two coordinates along a direction vector. @@ -13,7 +148,7 @@ JSM.CoordSignedDistance = function (a, b, direction) var abDirection = JSM.CoordSub (b, a); var distance = a.DistanceTo (b); - var angle = JSM.GetVectorsAngle (abDirection, direction); + var angle = abDirection.AngleTo (direction); if (JSM.IsPositive (angle)) { distance = -distance; } @@ -21,27 +156,6 @@ JSM.CoordSignedDistance = function (a, b, direction) return distance; }; -/** -* Function: GetVectorsAngle -* Description: Calculates the angle of two vectors. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* Returns: -* {number} the result -*/ -JSM.GetVectorsAngle = function (a, b) -{ - var aDirection = a.Clone ().Normalize (); - var bDirection = b.Clone ().Normalize (); - if (aDirection.IsEqual (bDirection)) { - return 0.0; - } - - var product = JSM.VectorDot (aDirection, bDirection); - return JSM.ArcCos (product); -}; - /** * Function: GetVectorsFullAngle * Description: Calculates the full angle (0 to pi) of two vectors with the given normal vector. @@ -54,7 +168,7 @@ JSM.GetVectorsAngle = function (a, b) */ JSM.GetVectorsFullAngle = function (a, b, normal) { - var angle = JSM.GetVectorsAngle (a, b); + var angle = a.AngleTo (b); var origo = new JSM.Coord (0.0, 0.0, 0.0); if (JSM.CoordOrientation (a, origo, b, normal) == JSM.Orientation.Clockwise) { @@ -64,41 +178,6 @@ JSM.GetVectorsFullAngle = function (a, b, normal) return angle; }; -/** -* Function: VectorsAreCollinear -* Description: Determines if two vectors are collinear. -* Parameters: -* a {Vector} the first vector -* b {Vector} the second vector -* Returns: -* {boolean} the result -*/ -JSM.VectorsAreCollinear = function (a, b) -{ - var angle = JSM.GetVectorsAngle (a, b); - return JSM.IsEqual (angle, 0.0) || JSM.IsEqual (angle, Math.PI); -}; - -/** -* Function: GetCoord2DFromCoord -* Description: Transforms a 3D coordinate to a 2D coordinate. -* Parameters: -* coord {Coord} the coordinate -* origo {Coord} the origo of transformation -* normal {Vector} the normal vector of transformation -* Returns: -* {Coord2D} the result -*/ -JSM.GetCoord2DFromCoord = function (coord, origo, normal) -{ - var zNormal = new JSM.Vector (0.0, 0.0, 1.0); - var axis = JSM.VectorCross (normal, zNormal); - var angle = JSM.GetVectorsAngle (normal, zNormal); - - var rotated = coord.Clone ().Rotate (axis, angle, origo); - return new JSM.Coord2D (rotated.x, rotated.y); -}; - /** * Function: CoordOrientation * Description: Calculates the turn type of three coordinates. @@ -112,14 +191,13 @@ JSM.GetCoord2DFromCoord = function (coord, origo, normal) */ JSM.CoordOrientation = function (a, b, c, normal) { - var origo = new JSM.Coord (0.0, 0.0, 0.0); - var a2 = JSM.GetCoord2DFromCoord (a, origo, normal); - var b2 = JSM.GetCoord2DFromCoord (b, origo, normal); - var c2 = JSM.GetCoord2DFromCoord (c, origo, normal); + var a2 = a.ToCoord2D (normal); + var b2 = b.ToCoord2D (normal); + var c2 = c.ToCoord2D (normal); var orientation = JSM.CoordOrientation2D (a2, b2, c2); var zNormal = new JSM.Vector (0.0, 0.0, 1.0); - var angle = JSM.GetVectorsAngle (normal, zNormal); + var angle = normal.AngleTo (zNormal); if (JSM.IsEqual (angle, Math.PI)) { if (orientation == JSM.Orientation.CounterClockwise) { orientation = JSM.Orientation.Clockwise; @@ -131,6 +209,77 @@ JSM.CoordOrientation = function (a, b, c, normal) return orientation; }; +/** +* Function: SphericalToCartesian +* Description: Converts a spherical coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* theta {number} the angle component +* phi {number} the phi component +* Returns: +* {Coord} the result +*/ +JSM.SphericalToCartesian = function (radius, theta, phi) +{ + var result = new JSM.Coord (0.0, 0.0, 0.0); + result.x = radius * Math.sin (theta) * Math.cos (phi); + result.y = radius * Math.sin (theta) * Math.sin (phi); + result.z = radius * Math.cos (theta); + return result; +}; + +/** +* Function: CylindricalToCartesian +* Description: Converts a cylindrical coordinate to a cartesian coordinate. +* Parameters: +* radius {number} the radius component +* height {number} the height component +* theta {number} the theta component +* Returns: +* {Coord} the result +*/ +JSM.CylindricalToCartesian = function (radius, height, theta) +{ + var result = new JSM.Coord (0.0, 0.0, 0.0); + result.x = radius * Math.cos (theta); + result.y = radius * Math.sin (theta); + result.z = height; + return result; +}; + +/** +* Function: GetArcLength +* Description: Calculates arc length between two vectors. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector +* radius {number} the radius component +* Returns: +* {number} the result +*/ +JSM.GetArcLength = function (a, b, radius) +{ + var angle = a.AngleTo (b); + return angle * radius; +}; + +/** +* Function: GetFullArcLength +* Description: Calculates arc length between two vectors with the given normal vector. +* Parameters: +* a {Vector} the first vector +* b {Vector} the second vector +* radius {number} the radius component +* normal {Vector} the normal vector +* Returns: +* {number} the result +*/ +JSM.GetFullArcLength = function (a, b, radius, normal) +{ + var angle = JSM.GetVectorsFullAngle (a, b, normal); + return angle * radius; +}; + /** * Function: CalculateCentroid * Description: Calculates center points of the given coordinates. diff --git a/src/geometry/definitions.js b/src/geometry/definitions.js index f530a92e..135d0f55 100644 --- a/src/geometry/definitions.js +++ b/src/geometry/definitions.js @@ -1,4 +1,3 @@ - JSM.Eps = 0.00000001; JSM.Inf = 9999999999; JSM.RadDeg = 57.29577951308232; @@ -193,31 +192,3 @@ JSM.ArcCos = function (value) return Math.acos (value); }; - -/** -* Enum: Orientation -* Description: Orientation of coordinates. -* Values: -* {Invalid} invalid orientation or collinear -* {CounterClockwise} counter clockwise orientation -* {Clockwise} clockwise orientation -*/ -JSM.Orientation = { - Invalid : 0, - CounterClockwise : 1, - Clockwise : 2 -}; - -/** -* Enum: Complexity -* Description: Complexity of polygon. -* Values: -* {Invalid} invalid polygon -* {Convex} convex polygon -* {Concave} concave polygon -*/ -JSM.Complexity = { - Invalid : 0, - Convex : 1, - Concave : 2 -}; diff --git a/src/geometry/line.js b/src/geometry/line.js index 3a27dfa8..b3a54241 100644 --- a/src/geometry/line.js +++ b/src/geometry/line.js @@ -1,3 +1,43 @@ +/** +* Enum: CoordLinePosition2D +* Description: Position of a coordinate and a line. +* Values: +* {CoordOnLine} coordinate lies on the line +* {CoordAtLineLeft} coordinate lies on the left side of the line +* {CoordAtLineRight} coordinate lies on the left side right the line +*/ +JSM.CoordLinePosition2D = { + CoordOnLine : 0, + CoordAtLineLeft : 1, + CoordAtLineRight : 2 +}; + +/** +* Enum: CoordLinePosition +* Description: Position of a coordinate and a line. +* Values: +* {CoordOnLine} coordinate lies on the line +* {CoordOutsideOfLine} coordinate lies outside of the line +*/ +JSM.CoordLinePosition = { + CoordOnLine : 0, + CoordOutsideOfLine : 1 +}; + +/** +* Enum: LineLinePosition +* Description: Position of two lines. +* Values: +* {LinesDontIntersect} lines do not intersect +* {LinesIntersectsCoincident} lines intersect coincident +* {LinesIntersectsOnePoint} lines intersect one point +*/ +JSM.LineLinePosition = { + LinesDontIntersect : 0, + LinesIntersectsOnePoint : 1, + LinesIntersectsCoincident : 2 +}; + /** * Class: Line2D * Description: Represents a 2D infinite line. @@ -24,6 +64,31 @@ JSM.Line2D.prototype.Set = function (start, direction) this.direction = direction; }; +/** +* Function: Line2D.CoordPosition +* Description: Calculates the position of the line and the given coordinate. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {CoordLinePosition2D} the result +*/ +JSM.Line2D.prototype.CoordPosition = function (coord) +{ + var x = coord.x; + var y = coord.y; + var a = this.start; + var b = this.direction; + + var position = b.x * (y - a.y) - b.y * (x - a.x); + if (JSM.IsPositive (position)) { + return JSM.CoordLinePosition2D.CoordAtLineLeft; + } else if (JSM.IsNegative (position)) { + return JSM.CoordLinePosition2D.CoordAtLineRight; + } + + return JSM.CoordLinePosition2D.CoordOnLine; +}; + /** * Function: Line2D.Clone * Description: Clones the line. @@ -61,6 +126,176 @@ JSM.Line.prototype.Set = function (start, direction) this.direction = direction; }; +/** +* Function: Line.CoordPosition +* Description: Calculates the position of the line and the given coordinate. +* Parameters: +* coord {Coord} the coordinate +* projected {Coord} (out) the projected coordinate +* Returns: +* {CoordLinePosition} the result +*/ +JSM.Line.prototype.CoordPosition = function (coord, projected) +{ + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var a = this.start; + var b = this.direction; + + var x1 = a.x; + var y1 = a.y; + var z1 = a.z; + var x2 = a.x + b.x; + var y2 = a.y + b.y; + var z2 = a.z + b.z; + + var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); + if (JSM.IsZero (denom)) { + if (projected !== undefined) { + projected.Set (a.x, a.y, a.z); + } + + if (a.IsEqual (coord)) { + return JSM.CoordLinePosition.CoordOnLine; + } + + return JSM.CoordLinePosition.CoordOutsideOfLine; + } + + var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; + var bu = b.Clone ().MultiplyScalar (u); + var c = JSM.CoordAdd (a, bu); + if (projected !== undefined) { + projected.Set (c.x, c.y, c.z); + } + + var distance = coord.DistanceTo (c); + if (JSM.IsZero (distance)) { + return JSM.CoordLinePosition.CoordOnLine; + } + + return JSM.CoordLinePosition.CoordOutsideOfLine; +}; + +/** +* Function: Line.ProjectCoord +* Description: Calculates the projected coordinate of the given coordinate. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {Coord} the result +*/ +JSM.Line.prototype.ProjectCoord = function (coord) +{ + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var a = this.start; + var b = this.direction; + + var x1 = a.x; + var y1 = a.y; + var z1 = a.z; + var x2 = a.x + b.x; + var y2 = a.y + b.y; + var z2 = a.z + b.z; + + var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); + if (JSM.IsZero (denom)) { + return a.Clone (); + } + + var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; + var bu = b.Clone ().MultiplyScalar (u); + return JSM.CoordAdd (a, bu); +}; + +/** +* Function: Line.ClosestPoint +* Description: Calculates the closest points between the line and a given line. +* Parameters: +* line {Line} the line +* thisClosestPoint {Coord} (out) the closest point on the current line +* lineClosestPoint {Coord} (out) the closest point on the given line +* Returns: +* {boolean} success +*/ +JSM.Line.prototype.ClosestPoint = function (line, thisClosestPoint, lineClosestPoint) +{ + function Dmnop (v, m, n, o, p) + { + var result = (v[m].x - v[n].x) * (v[o].x - v[p].x) + (v[m].y - v[n].y) * (v[o].y - v[p].y) + (v[m].z - v[n].z) * (v[o].z - v[p].z); + return result; + } + + var aDir = this.direction.Clone ().Normalize (); + var aStart = this.start; + var aEnd = JSM.CoordAdd (aStart, aDir); + + var bDir = line.direction.Clone ().Normalize (); + var bStart = line.start; + var bEnd = JSM.CoordAdd (bStart, bDir); + + var v = [aStart, aEnd, bStart, bEnd]; + var d1010 = Dmnop (v, 1, 0, 1, 0); + var d0210 = Dmnop (v, 0, 2, 1, 0); + var d0232 = Dmnop (v, 0, 2, 3, 2); + var d3210 = Dmnop (v, 3, 2, 1, 0); + var d3232 = Dmnop (v, 3, 2, 3, 2); + var denom = (d1010 * d3232 - d3210 * d3210); + if (JSM.IsEqual (denom, 0.0)) { + return false; + } + + var nom = (d0232 * d3210 - d0210 * d3232); + var mua = nom / denom; + var mub = (d0232 + mua * d3210) / d3232; + + if (thisClosestPoint !== undefined) { + aDir.MultiplyScalar (mua); + var aClosest = JSM.CoordAdd (aStart, aDir); + thisClosestPoint.Set (aClosest.x, aClosest.y, aClosest.z); + } + + if (lineClosestPoint !== undefined) { + bDir.MultiplyScalar (mub); + var bClosest = JSM.CoordAdd (bStart, bDir); + lineClosestPoint.Set (bClosest.x, bClosest.y, bClosest.z); + } + + return true; +}; + +/** +* Function: Line.LinePosition +* Description: Calculates the position of the line and the given line. +* Parameters: +* line {Line} the line +* intersection {Coord} (out) the intersection point if it exists +* Returns: +* {LineLinePosition} the result +*/ +JSM.Line.prototype.LinePosition = function (line, intersection) +{ + var thisClosestPoint = new JSM.Coord (0.0, 0.0, 0.0); + var lineClosestPoint = new JSM.Coord (0.0, 0.0, 0.0); + if (!this.ClosestPoint (line, thisClosestPoint, lineClosestPoint)) { + return JSM.LineLinePosition.LinesIntersectsCoincident; + } + + if (thisClosestPoint.IsEqual (lineClosestPoint)) { + if (intersection !== undefined) { + intersection.Set (thisClosestPoint.x, thisClosestPoint.y, thisClosestPoint.z); + } + return JSM.LineLinePosition.LinesIntersectsOnePoint; + } + + return JSM.LineLinePosition.LinesDontIntersect; +}; + /** * Function: Line.Clone * Description: Clones the line. diff --git a/src/geometry/lineutils.js b/src/geometry/lineutils.js deleted file mode 100644 index 73b73bfa..00000000 --- a/src/geometry/lineutils.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* Function: CoordLinePosition2D -* Description: Calculates the position of a coordinate and a line. -* Parameters: -* coord {Coord2D} the coordinate -* line {Line2D} the line -* Returns: -* {string} 'CoordAtLineLeft', 'CoordAtLineRight', or 'CoordOnLine' -*/ -JSM.CoordLinePosition2D = function (coord, line) -{ - var x = coord.x; - var y = coord.y; - var a = line.start; - var b = line.direction; - - var position = b.x * (y - a.y) - b.y * (x - a.x); - if (JSM.IsPositive (position)) { - return 'CoordAtLineLeft'; - } else if (JSM.IsNegative (position)) { - return 'CoordAtLineRight'; - } - - return 'CoordOnLine'; -}; - -/** -* Function: CoordLinePosition -* Description: Calculates the position of a coordinate and a line. -* Parameters: -* coord {Coord} the coordinate -* line {Line} the line -* projected {Coord} the projected coordinate -* Returns: -* {string} 'CoordOutsideOfLine', or 'CoordOnLine' -*/ -JSM.CoordLinePosition = function (coord, line, projected) -{ - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var a = line.start; - var b = line.direction; - - var x1 = a.x; - var y1 = a.y; - var z1 = a.z; - var x2 = a.x + b.x; - var y2 = a.y + b.y; - var z2 = a.z + b.z; - - var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); - if (JSM.IsZero (denom)) { - if (projected !== undefined) { - projected.Set (a.x, a.y, a.z); - } - - if (a.IsEqual (coord)) { - return 'CoordOnLine'; - } - - return 'CoordOutsideOfLine'; - } - - var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var bu = b.Clone ().MultiplyScalar (u); - var c = JSM.CoordAdd (a, bu); - if (projected !== undefined) { - projected.Set (c.x, c.y, c.z); - } - - var distance = coord.DistanceTo (c); - if (JSM.IsZero (distance)) { - return 'CoordOnLine'; - } - - return 'CoordOutsideOfLine'; -}; - -/** -* Function: ProjectCoordToLine -* Description: Projects a coordinate to a line. -* Parameters: -* coord {Coord} the coordinate -* line {Line} the line -* Returns: -* {Coord} the projected coordinate -*/ -JSM.ProjectCoordToLine = function (coord, line) -{ - var result = new JSM.Coord (0.0, 0.0, 0.0); - - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var a = line.start; - var b = line.direction; - - var x1 = a.x; - var y1 = a.y; - var z1 = a.z; - var x2 = a.x + b.x; - var y2 = a.y + b.y; - var z2 = a.z + b.z; - - var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); - if (JSM.IsZero (denom)) { - result.Set (a.x, a.y, a.z); - return result; - } - - var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var bu = b.Clone ().MultiplyScalar (u); - var c = JSM.CoordAdd (a, bu); - - result.Set (c.x, c.y, c.z); - return result; -}; - -/** -* Function: LineLineClosestPoint -* Description: Calculates the closest points between two lines. -* Parameters: -* aLine {Line} first line -* bLine {Line} second line -* aClosestPoint {Coord} (out) the closest point on first line -* bClosestPoint {Coord} (out) the closest point on second line -* Returns: -* {boolean} success -*/ -JSM.LineLineClosestPoint = function (aLine, bLine, aClosestPoint, bClosestPoint) -{ - function Dmnop (v, m, n, o, p) - { - var result = (v[m].x - v[n].x) * (v[o].x - v[p].x) + (v[m].y - v[n].y) * (v[o].y - v[p].y) + (v[m].z - v[n].z) * (v[o].z - v[p].z); - return result; - } - - var aDir = aLine.direction.Clone ().Normalize (); - var aStart = aLine.start; - var aEnd = JSM.CoordAdd (aStart, aDir); - - var bDir = bLine.direction.Clone ().Normalize (); - var bStart = bLine.start; - var bEnd = JSM.CoordAdd (bStart, bDir); - - var v = [aStart, aEnd, bStart, bEnd]; - - var d1010 = Dmnop (v, 1, 0, 1, 0); - var d0210 = Dmnop (v, 0, 2, 1, 0); - var d0232 = Dmnop (v, 0, 2, 3, 2); - var d3210 = Dmnop (v, 3, 2, 1, 0); - var d3232 = Dmnop (v, 3, 2, 3, 2); - var denom = (d1010 * d3232 - d3210 * d3210); - if (JSM.IsEqual (denom, 0.0)) { - return false; - } - - var nom = (d0232 * d3210 - d0210 * d3232); - var mua = nom / denom; - var mub = (d0232 + mua * d3210) / d3232; - - if (aClosestPoint !== undefined) { - aDir.MultiplyScalar (mua); - var aClosest = JSM.CoordAdd (aStart, aDir); - aClosestPoint.Set (aClosest.x, aClosest.y, aClosest.z); - } - - if (bClosestPoint !== undefined) { - bDir.MultiplyScalar (mub); - var bClosest = JSM.CoordAdd (bStart, bDir); - bClosestPoint.Set (bClosest.x, bClosest.y, bClosest.z); - } - - return true; -}; - -/** -* Function: LineLinePosition -* Description: Calculates the position of two lines. -* Parameters: -* aLine {Line} first line -* bLine {Line} second line -* intersection {Coord} (out) the intersection point if it exists -* Returns: -* {string} 'LinesIntersectsCoincident', 'LinesIntersectsOnePoint', or 'LinesDontIntersects' -*/ -JSM.LineLinePosition = function (aLine, bLine, intersection) -{ - var aClosestPoint = new JSM.Coord (0.0, 0.0, 0.0); - var bClosestPoint = new JSM.Coord (0.0, 0.0, 0.0); - if (!JSM.LineLineClosestPoint (aLine, bLine, aClosestPoint, bClosestPoint)) { - return 'LinesIntersectsCoincident'; - } - - if (aClosestPoint.IsEqual (bClosestPoint)) { - if (intersection !== undefined) { - intersection.Set (aClosestPoint.x, aClosestPoint.y, aClosestPoint.z); - } - return 'LinesIntersectsOnePoint'; - } - - return 'LinesDontIntersects'; -}; diff --git a/src/geometry/octree.js b/src/geometry/octree.js index 8a620287..ec4d8ffc 100644 --- a/src/geometry/octree.js +++ b/src/geometry/octree.js @@ -309,7 +309,7 @@ JSM.TriangleOctree.prototype.AddTriangleToNode = function (v0, v1, v2, root, use { function IsTriangleInNode (v0, v1, v2, node) { - return JSM.IsCoordInBox (v0, node.box) && JSM.IsCoordInBox (v1, node.box) && JSM.IsCoordInBox (v2, node.box); + return node.box.IsCoordInside (v0) && node.box.IsCoordInside (v1) && node.box.IsCoordInside (v2); } if (!IsTriangleInNode (v0, v1, v2, root)) { diff --git a/src/geometry/plane.js b/src/geometry/plane.js index 2eedb88b..376655c4 100644 --- a/src/geometry/plane.js +++ b/src/geometry/plane.js @@ -1,3 +1,29 @@ +/** +* Enum: CoordPlanePosition +* Description: Position of a coordinate and a plane. +* Values: +* {CoordOnPlane} coordinate lies on the plane +* {CoordInFrontOfPlane} coordinate lies in front of of the plane +* {CoordAtBackOfPlane} coordinate lies at the back of the plane +*/ +JSM.CoordPlanePosition = { + CoordOnPlane : 0, + CoordInFrontOfPlane : 1, + CoordAtBackOfPlane : 2 +}; + +/** +* Enum: LinePlanePosition +* Description: Position of a line and a plane. +* Values: +* {LineParallelToPlane} line is parallel to the plane +* {LineIntersectsPlane} line intersects the plane +*/ +JSM.LinePlanePosition = { + LineParallelToPlane : 0, + LineIntersectsPlane : 1 +}; + /** * Class: Plane * Description: Represents a plane. @@ -43,6 +69,181 @@ JSM.Plane.prototype.GetNormal = function () return new JSM.Vector (this.a, this.b, this.c); }; +/** +* Function: Plane.CoordSignedDistance +* Description: Calculates the signed distance of a coordinate and the plane. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {number} the result +*/ +JSM.Plane.prototype.CoordSignedDistance = function (coord) +{ + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var distance = (a * x + b * y + c * z + d) / Math.sqrt (a * a + b * b + c * c); + return distance; +}; + +/** +* Function: Plane.CoordDistance +* Description: Calculates the distance of a coordinate and the plane. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {number} the result +*/ +JSM.Plane.prototype.CoordDistance = function (coord) +{ + var signed = this.CoordSignedDistance (coord); + return Math.abs (signed); +}; + +/** +* Function: Plane.ProjectCoord +* Description: Projects a coordinate to the plane. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {Coord} the projected coordinate +*/ +JSM.Plane.prototype.ProjectCoord = function (coord) +{ + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var distance = this.CoordDistance (coord); + var side = a * x + b * y + c * z + d; + if (JSM.IsGreater (side, 0.0)) { + distance = -distance; + } + + var normal = this.GetNormal ().Normalize (); + var result = coord.Clone ().Offset (normal, distance); + return result; +}; + + +/** +* Function: Plane.CoordPosition +* Description: Calculates the position of the plane and the given coordinate. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {CoordPlanePosition} thre result +*/ +JSM.Plane.prototype.CoordPosition = function (coord) +{ + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var s = a * x + b * y + c * z + d; + if (JSM.IsPositive (s)) { + return JSM.CoordPlanePosition.CoordInFrontOfPlane; + } else if (JSM.IsNegative (s)) { + return JSM.CoordPlanePosition.CoordAtBackOfPlane; + } + + return JSM.CoordPlanePosition.CoordOnPlane; +}; + +/** +* Function: Plane.LinePosition +* Description: Calculates the position of the plane and the given line. +* Parameters: +* line {Line} the line +* intersection {Coord} (out) the intersection point if it exists +* Returns: +* {CoordLinePosition} the result +*/ +JSM.Plane.prototype.LinePosition = function (line, intersection) +{ + var direction = line.direction.Clone ().Normalize (); + + var x1 = line.start.x; + var y1 = line.start.y; + var z1 = line.start.z; + + var x2 = line.start.x + direction.x; + var y2 = line.start.y + direction.y; + var z2 = line.start.z + direction.z; + + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); + if (JSM.IsZero (denom)) { + return JSM.LinePlanePosition.LineParallelToPlane; + } + + var u = (a * x1 + b * y1 + c * z1 + d) / denom; + if (intersection !== undefined) { + direction.MultiplyScalar (u); + var i = JSM.CoordAdd (line.start, direction); + intersection.Set (i.x, i.y, i.z); + } + + return JSM.LinePlanePosition.LineIntersectsPlane; +}; + +/** +* Function: Plane.LineIntersection +* Description: +* Calculates the intersection point of a line and a plane. +* The line should not be parallel to the plane. +* Parameters: +* line {Line} the line +* Returns: +* {Coord} the result +*/ +JSM.Plane.prototype.LineIntersection = function (line) +{ + var direction = line.direction.Clone ().Normalize (); + + var x1 = line.start.x; + var y1 = line.start.y; + var z1 = line.start.z; + + var x2 = line.start.x + direction.x; + var y2 = line.start.y + direction.y; + var z2 = line.start.z + direction.z; + + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); + if (JSM.IsZero (denom)) { + return null; + } + + var u = (a * x1 + b * y1 + c * z1 + d) / denom; + direction.MultiplyScalar (u); + return JSM.CoordAdd (line.start, direction); +}; + /** * Function: Plane.Clone * Description: Clones the plane. @@ -53,3 +254,104 @@ JSM.Plane.prototype.Clone = function () { return new JSM.Plane (this.a, this.b, this.c, this.d); }; + +/** +* Function: GetPlaneFromCoordAndDirection +* Description: Generates a plane from a coordinate and a direction. +* Parameters: +* coord {Coord} the coordinate +* direction {Vector} the direction +* Returns: +* {Plane} the result +*/ +JSM.GetPlaneFromCoordAndDirection = function (coord, direction) +{ + var plane = new JSM.Plane (); + var normal = direction.Clone ().Normalize (); + var pa = normal.x; + var pb = normal.y; + var pc = normal.z; + var pd = -(pa * coord.x + pb * coord.y + pc * coord.z); + plane.Set (pa, pb, pc, pd); + return plane; +}; + +/** +* Function: GetPlaneFromThreeCoords +* Description: Generates a plane from three coordinates. +* Parameters: +* a {Coord} the first coordinate +* b {Coord} the second coordinate +* c {Coord} the third coordinate +* Returns: +* {Plane} the result +*/ +JSM.GetPlaneFromThreeCoords = function (a, b, c) +{ + var plane = new JSM.Plane (); + var pa = (b.y - a.y) * (c.z - a.z) - (c.y - a.y) * (b.z - a.z); + var pb = (b.z - a.z) * (c.x - a.x) - (c.z - a.z) * (b.x - a.x); + var pc = (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y); + var pd = -(pa * a.x + pb * a.y + pc * a.z); + plane.Set (pa, pb, pc, pd); + return plane; +}; + +/** +* Function: CoordPlaneSignedDirectionalDistance +* Description: Calculates the signed distance of a coordinate and a plane along a direction vector. +* Parameters: +* coord {Coord} the coordinate +* direction {Vector} the direction +* plane {Plane} the plane +* Returns: +* {number} the result +*/ +JSM.CoordPlaneSignedDirectionalDistance = function (coord, direction, plane) +{ + var normal = direction.Clone ().Normalize (); + + var x1 = coord.x; + var y1 = coord.y; + var z1 = coord.z; + + var x2 = coord.x + normal.x; + var y2 = coord.y + normal.y; + var z2 = coord.z + normal.z; + + var a = plane.a; + var b = plane.b; + var c = plane.c; + var d = plane.d; + + var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); + if (JSM.IsZero (denom)) { + return 0.0; + } + + var u = (a * x1 + b * y1 + c * z1 + d) / denom; + normal.MultiplyScalar (u); + var intersection = JSM.CoordAdd (coord, normal); + var distance = coord.DistanceTo (intersection); + var s = a * x1 + b * y1 + c * z1 + d; + if (JSM.IsNegative (s)) { + distance = -distance; + } + + return distance; +}; + +/** +* Function: CoordPlaneDirectionalDistance +* Description: Calculates the distance of a coordinate and a plane along a direction vector. +* Parameters: +* coord {Coord} the coordinate +* direction {Vector} the direction +* plane {Plane} the plane +* Returns: +* {number} the result +*/ +JSM.CoordPlaneDirectionalDistance = function (coord, direction, plane) +{ + return Math.abs (JSM.CoordPlaneSignedDirectionalDistance (coord, direction, plane)); +}; diff --git a/src/geometry/planeutils.js b/src/geometry/planeutils.js deleted file mode 100644 index b743c7b7..00000000 --- a/src/geometry/planeutils.js +++ /dev/null @@ -1,280 +0,0 @@ -/** -* Function: GetPlaneFromCoordAndDirection -* Description: Generates a plane from a coordinate and a direction. -* Parameters: -* coord {Coord} the coordinate -* direction {Vector} the direction -* Returns: -* {Plane} the result -*/ -JSM.GetPlaneFromCoordAndDirection = function (coord, direction) -{ - var plane = new JSM.Plane (); - var normal = direction.Clone ().Normalize (); - var pa = normal.x; - var pb = normal.y; - var pc = normal.z; - var pd = -(pa * coord.x + pb * coord.y + pc * coord.z); - plane.Set (pa, pb, pc, pd); - return plane; -}; - -/** -* Function: GetPlaneFromThreeCoords -* Description: Generates a plane from three coordinates. -* Parameters: -* a {Coord} the first coordinate -* b {Coord} the second coordinate -* c {Coord} the third coordinate -* Returns: -* {Plane} the result -*/ -JSM.GetPlaneFromThreeCoords = function (a, b, c) -{ - var plane = new JSM.Plane (); - var pa = (b.y - a.y) * (c.z - a.z) - (c.y - a.y) * (b.z - a.z); - var pb = (b.z - a.z) * (c.x - a.x) - (c.z - a.z) * (b.x - a.x); - var pc = (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y); - var pd = -(pa * a.x + pb * a.y + pc * a.z); - plane.Set (pa, pb, pc, pd); - return plane; -}; - -/** -* Function: CoordPlanePosition -* Description: Calculates the position of a coordinate and a plane. -* Parameters: -* coord {Coord} the coordinate -* plane {Plane} the plane -* Returns: -* {string} 'CoordInFrontOfPlane', 'CoordAtBackOfPlane', or 'CoordOnPlane' -*/ -JSM.CoordPlanePosition = function (coord, plane) -{ - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var s = a * x + b * y + c * z + d; - if (JSM.IsPositive (s)) { - return 'CoordInFrontOfPlane'; - } else if (JSM.IsNegative (s)) { - return 'CoordAtBackOfPlane'; - } - - return 'CoordOnPlane'; -}; - -/** -* Function: LinePlanePosition -* Description: Calculates the position of a line and a plane. -* Parameters: -* line {Line} the line -* plane {Plane} the plane -* intersection {Coord} (out) the intersection point if it exists -* Returns: -* {string} 'LineParallelToPlane', or 'LineIntersectsPlane' -*/ -JSM.LinePlanePosition = function (line, plane, intersection) -{ - var direction = line.direction.Clone ().Normalize (); - - var x1 = line.start.x; - var y1 = line.start.y; - var z1 = line.start.z; - - var x2 = line.start.x + direction.x; - var y2 = line.start.y + direction.y; - var z2 = line.start.z + direction.z; - - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); - if (JSM.IsZero (denom)) { - return 'LineParallelToPlane'; - } - - var u = (a * x1 + b * y1 + c * z1 + d) / denom; - if (intersection !== undefined) { - direction.MultiplyScalar (u); - var i = JSM.CoordAdd (line.start, direction); - intersection.Set (i.x, i.y, i.z); - } - - return 'LineIntersectsPlane'; -}; - -/** -* Function: LinePlaneIntersection -* Description: Calculates the intersection point of a line and a plane. -* Parameters: -* line {Line} the line -* plane {Plane} the plane -* Returns: -* {Coord} the result -*/ -JSM.LinePlaneIntersection = function (line, plane) -{ - var direction = line.direction.Clone ().Normalize (); - - var x1 = line.start.x; - var y1 = line.start.y; - var z1 = line.start.z; - - var x2 = line.start.x + direction.x; - var y2 = line.start.y + direction.y; - var z2 = line.start.z + direction.z; - - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var result = new JSM.Coord (0.0, 0.0, 0.0); - var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); - if (JSM.IsZero (denom)) { - return result; - } - - var u = (a * x1 + b * y1 + c * z1 + d) / denom; - direction.MultiplyScalar (u); - result = JSM.CoordAdd (line.start, direction); - return result; -}; - -/** -* Function: CoordPlaneSignedDistance -* Description: Calculates the signed distance of a coordinate and a plane. -* Parameters: -* coord {Coord} the coordinate -* plane {Plane} the plane -* Returns: -* {number} the result -*/ -JSM.CoordPlaneSignedDistance = function (coord, plane) -{ - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var distance = (a * x + b * y + c * z + d) / Math.sqrt (a * a + b * b + c * c); - return distance; -}; - -/** -* Function: CoordPlaneDistance -* Description: Calculates the distance of a coordinate and a plane. -* Parameters: -* coord {Coord} the coordinate -* plane {Plane} the plane -* Returns: -* {number} the result -*/ -JSM.CoordPlaneDistance = function (coord, plane) -{ - return Math.abs (JSM.CoordPlaneSignedDistance (coord, plane)); -}; - -/** -* Function: CoordPlaneSignedDirectionalDistance -* Description: Calculates the signed distance of a coordinate and a plane along a direction vector. -* Parameters: -* coord {Coord} the coordinate -* direction {Vector} the direction -* plane {Plane} the plane -* Returns: -* {number} the result -*/ -JSM.CoordPlaneSignedDirectionalDistance = function (coord, direction, plane) -{ - var normal = direction.Clone ().Normalize (); - - var x1 = coord.x; - var y1 = coord.y; - var z1 = coord.z; - - var x2 = coord.x + normal.x; - var y2 = coord.y + normal.y; - var z2 = coord.z + normal.z; - - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var denom = (a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2)); - if (JSM.IsZero (denom)) { - return 0.0; - } - - var u = (a * x1 + b * y1 + c * z1 + d) / denom; - normal.MultiplyScalar (u); - var intersection = JSM.CoordAdd (coord, normal); - var distance = coord.DistanceTo (intersection); - var s = a * x1 + b * y1 + c * z1 + d; - if (JSM.IsNegative (s)) { - distance = -distance; - } - - return distance; -}; - -/** -* Function: CoordPlaneDirectionalDistance -* Description: Calculates the distance of a coordinate and a plane along a direction vector. -* Parameters: -* coord {Coord} the coordinate -* direction {Vector} the direction -* plane {Plane} the plane -* Returns: -* {number} the result -*/ -JSM.CoordPlaneDirectionalDistance = function (coord, direction, plane) -{ - return Math.abs (JSM.CoordPlaneSignedDirectionalDistance (coord, direction, plane)); -}; - -/** -* Function: ProjectCoordToPlane -* Description: Projects a coordinate to a plane. -* Parameters: -* coord {Coord} the coordinate -* plane {Plane} the plane -* Returns: -* {Coord} the projected coordinate -*/ -JSM.ProjectCoordToPlane = function (coord, plane) -{ - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var a = plane.a; - var b = plane.b; - var c = plane.c; - var d = plane.d; - - var distance = JSM.CoordPlaneDistance (coord, plane); - var side = a * x + b * y + c * z + d; - if (JSM.IsGreater (side, 0.0)) { - distance = -distance; - } - - var normal = new JSM.Coord (a, b, c).Normalize (); - var result = coord.Clone ().Offset (normal, distance); - - return result; -}; diff --git a/src/geometry/polygonutils.js b/src/geometry/polygonutils.js index 05b969c5..0dec93b3 100644 --- a/src/geometry/polygonutils.js +++ b/src/geometry/polygonutils.js @@ -176,7 +176,8 @@ JSM.CoordPolygonPosition2D = function (coord, polygon) current = polygon.GetVertex (i); next = polygon.GetVertex ((i + 1) % count); sector = new JSM.Sector2D (current, next); - if (JSM.CoordSectorPosition2D (coord, sector) !== 'CoordOutsideOfSector') { + + if (sector.CoordPosition (coord) != JSM.CoordSectorPosition2D.CoordOutsideOfSector) { return 'CoordOnPolygonEdge'; } } @@ -200,14 +201,14 @@ JSM.CoordPolygonPosition2D = function (coord, polygon) sector = new JSM.Sector2D (current, next); intersection = new JSM.Coord2D (0.0, 0.0); - ssp = JSM.SectorSectorPosition2D (ray, sector, intersection); - if (ssp === 'SectorsDontIntersects') { + ssp = ray.SectorPosition (sector, intersection); + if (ssp === JSM.SectorSectorPosition2D.SectorsDontIntersect) { continue; } - if (ssp === 'SectorsIntersectsOnePoint') { + if (ssp === JSM.SectorSectorPosition2D.SectorsIntersectOnePoint) { intersections++; - } else if (ssp === 'SectorsIntersectsEndPoint') { + } else if (ssp === JSM.SectorSectorPosition2D.SectorsIntersectEndPoint) { if (intersection.IsEqual (sector.beg)) { if (JSM.IsGreater (sector.beg.y, sector.end.y)) { intersections++; @@ -253,8 +254,8 @@ JSM.SectorIntersectsPolygon2D = function (polygon, sector, from, to) } currentSector = new JSM.Sector2D (polygon.GetVertex (sectorBeg), polygon.GetVertex (sectorEnd)); - position = JSM.SectorSectorPosition2D (sector, currentSector); - if (position !== 'SectorsDontIntersects') { + position = sector.SectorPosition (currentSector); + if (position !== JSM.SectorSectorPosition2D.SectorsDontIntersect) { return true; } } @@ -385,7 +386,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) var currentSector; for (i = 0; i < originalPolygon.VertexCount (); i++) { for (j = 0; j < currentHolePolygon.VertexCount (); j++) { - currentSector = new JSM.Sector (originalPolygon.GetVertex (i), currentHolePolygon.GetVertex (j)); + currentSector = new JSM.Sector2D (originalPolygon.GetVertex (i), currentHolePolygon.GetVertex (j)); if (IsNotIntersectingSector (currentSector, i, j, originalPolygon, currentHolePolygon, contourPolygons, finishedContours)) { entryPoint = [resultIndices[i], j + from]; break; @@ -741,14 +742,11 @@ JSM.CreatePolygonWithHole = function (vertices) } var normal = JSM.CalculateNormal (noNullVertices); - - var origo = new JSM.Coord (0.0, 0.0, 0.0); var vertices2D = []; - var vertex; for (i = 0; i < vertices.length; i++) { if (vertices[i] !== null) { - vertex = JSM.GetCoord2DFromCoord (vertices[i], origo, normal); + vertex = vertices[i].ToCoord2D (normal); vertices2D.push (vertex); } else { vertices2D.push (null); @@ -773,11 +771,10 @@ JSM.PolygonTriangulate = function (polygon) var polygon2D = new JSM.Polygon2D (); var normal = JSM.CalculateNormal (polygon.vertices); - var origo = new JSM.Coord (0.0, 0.0, 0.0); var vertexCount = polygon.VertexCount (); var i, vertex; for (i = 0; i < vertexCount; i++) { - vertex = JSM.GetCoord2DFromCoord (polygon.GetVertex (i), origo, normal); + vertex = polygon.GetVertex (i).ToCoord2D (normal); polygon2D.AddVertex (vertex.x, vertex.y); } @@ -817,7 +814,7 @@ JSM.OffsetPolygonContour = function (polygon, width) prevDir = JSM.CoordSub (prevVertex, currVertex); nextDir = JSM.CoordSub (nextVertex, currVertex); - angle = JSM.GetVectorsAngle (prevDir, nextDir) / 2.0; + angle = prevDir.AngleTo (nextDir) / 2.0; if (JSM.CoordOrientation (prevVertex, currVertex, nextVertex, normal) == JSM.Orientation.Clockwise) { angle = Math.PI - angle; } @@ -860,8 +857,8 @@ JSM.CutPolygonWithPlane = function (polygon, plane, frontPolygons, backPolygons, var currVertex = polygon.GetVertex (currIndex); var line = new JSM.Line (currVertex, JSM.CoordSub (currVertex, prevVertex)); var intersection = new JSM.Coord (0.0, 0.0, 0.0); - var linePlanePosition = JSM.LinePlanePosition (line, plane, intersection); - if (linePlanePosition == 'LineIntersectsPlane') { + var linePlanePosition = plane.LinePosition (line, intersection); + if (linePlanePosition == JSM.LinePlanePosition.LineIntersectsPlane) { cutPolygon.AddVertex (intersection.x, intersection.y, intersection.z); vertexTypes.push (0); } @@ -906,12 +903,12 @@ JSM.CutPolygonWithPlane = function (polygon, plane, frontPolygons, backPolygons, var i, position, currVertex, currType; for (i = 0; i < polygon.VertexCount (); i++) { currVertex = polygon.GetVertex (i); - position = JSM.CoordPlanePosition (currVertex, plane); + position = plane.CoordPosition (currVertex); currType = 0; - if (position == 'CoordInFrontOfPlane') { + if (position == JSM.CoordPlanePosition.CoordInFrontOfPlane) { currType = 1; frontFound = true; - } else if (position == 'CoordAtBackOfPlane') { + } else if (position == JSM.CoordPlanePosition.CoordAtBackOfPlane) { currType = -1; backFound = true; } @@ -1000,7 +997,7 @@ JSM.CutPolygonWithPlane = function (polygon, plane, frontPolygons, backPolygons, var distances = []; for (i = 0; i < entryVertices.length; i++) { vertex = cutPolygon.GetVertex (entryVertices[i]); - distances.push (JSM.CoordPlaneSignedDistance (vertex, referencePlane)); + distances.push (referencePlane.CoordSignedDistance (vertex)); } for (i = 0; i < entryVertices.length - 1; i++) { diff --git a/src/geometry/sector.js b/src/geometry/sector.js index 4590657a..43cd18d3 100644 --- a/src/geometry/sector.js +++ b/src/geometry/sector.js @@ -1,3 +1,47 @@ +/** +* Enum: CoordSectorPosition2D +* Description: Position of a coordinate and a sector. +* Values: +* {CoordInsideOfSector} coordinate lies inside of sector +* {CoordOnSectorEndCoord} coordinate lies at the end of the sector +* {CoordOutsideOfSector} coordinate lies outside of the sector +*/ +JSM.CoordSectorPosition2D = { + CoordInsideOfSector : 0, + CoordOnSectorEndCoord : 1, + CoordOutsideOfSector : 2 +}; + +/** +* Enum: SectorSectorPosition2D +* Description: Position of two sectors. +* Values: +* {SectorsDontIntersect} sectors do not intersect +* {SectorsIntersectCoincident} sectors intersect coincident +* {SectorsIntersectEndPoint} sectors intersect at end point +* {SectorsIntersectOnePoint} sectors intersect one point +*/ +JSM.SectorSectorPosition2D = { + SectorsDontIntersect : 0, + SectorsIntersectCoincident : 1, + SectorsIntersectEndPoint : 2, + SectorsIntersectOnePoint : 3 +}; + +/** +* Enum: CoordSectorPosition +* Description: Position of a coordinate and a sector. +* Values: +* {CoordInsideOfSector} coordinate lies inside of sector +* {CoordOnSectorEndCoord} coordinate lies at the end of the sector +* {CoordOutsideOfSector} coordinate lies outside of the sector +*/ +JSM.CoordSectorPosition = { + CoordInsideOfSector : 0, + CoordOnSectorEndCoord : 1, + CoordOutsideOfSector : 2 +}; + /** * Class: Sector2D * Description: Represents a 2D sector. @@ -35,6 +79,162 @@ JSM.Sector2D.prototype.GetLength = function () return this.beg.DistanceTo (this.end); }; +/** +* Function: Sector2D.CoordPosition +* Description: Calculates the position of the sector and the given coordinate. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {CoordSectorPosition2D} the result +*/ +JSM.Sector2D.prototype.CoordPosition = function (coord) +{ + var x = coord.x; + var y = coord.y; + var x1 = this.beg.x; + var y1 = this.beg.y; + var x2 = this.end.x; + var y2 = this.end.y; + + var length = this.GetLength (); + if (JSM.IsZero (length)) { + if (coord.IsEqual (this.beg)) { + return JSM.CoordSectorPosition2D.CoordOnSectorEndCoord; + } + + return JSM.CoordSectorPosition2D.CoordOutsideOfSector; + } + + var u = ((x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)) / (length * length); + if (JSM.IsLower (u, 0.0) || JSM.IsGreater (u, 1.0)) { + return JSM.CoordSectorPosition2D.CoordOutsideOfSector; + } + + var ux = x1 + u * (x2 - x1); + var uy = y1 + u * (y2 - y1); + if (!JSM.IsEqual (ux, x) || !JSM.IsEqual (uy, y)) { + return JSM.CoordSectorPosition2D.CoordOutsideOfSector; + } + + if (JSM.IsEqual (u, 0.0) || JSM.IsEqual (u, 1.0)) { + return JSM.CoordSectorPosition2D.CoordOnSectorEndCoord; + } + + return JSM.CoordSectorPosition2D.CoordInsideOfSector; +}; + +/** +* Function: Sector2D.SectorPosition +* Description: Calculates the position of the sector and the given sector. +* Parameters: +* sector {Sector2D} the sector +* intersection {Coord2D} (out) the intersection point if it exists +* Returns: +* {SectorSectorPosition2D} the result +*/ +JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) +{ + var aSector = this; + var bSector = sector; + + var x1 = aSector.beg.x; + var y1 = aSector.beg.y; + var x2 = aSector.end.x; + var y2 = aSector.end.y; + var x3 = bSector.beg.x; + var y3 = bSector.beg.y; + var x4 = bSector.end.x; + var y4 = bSector.end.y; + var ux = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var uy = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + + if (JSM.IsZero (ux) && JSM.IsZero (uy)) { + var aBeg = bSector.CoordPosition (aSector.beg); + var aEnd = bSector.CoordPosition (aSector.end); + var bBeg = aSector.CoordPosition (bSector.beg); + var bEnd = aSector.CoordPosition (bSector.end); + if (aBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || aEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector || bBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || bEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector) { + return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + if (intersection !== undefined) { + if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + intersection = aSector.beg.Clone (); + } else if (aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + intersection = aSector.end.Clone (); + } else if (bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + intersection = bSector.beg.Clone (); + } else if (bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + intersection = bSector.end.Clone (); + } + } + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } + + return JSM.SectorSectorPosition2D.SectorsDontIntersect; + } + + var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + if (JSM.IsZero (denom)) { + return JSM.SectorSectorPosition2D.SectorsDontIntersect; + } + + ux /= denom; + uy /= denom; + if (JSM.IsLower (ux, 0.0) || JSM.IsGreater (ux, 1.0) || JSM.IsLower (uy, 0.0) || JSM.IsGreater (uy, 1.0)) { + return JSM.SectorSectorPosition2D.SectorsDontIntersect; + } + + if (intersection !== undefined) { + intersection.x = x1 + ux * (x2 - x1); + intersection.y = y1 + ux * (y2 - y1); + } + + if (JSM.IsEqual (ux, 0.0) || JSM.IsEqual (ux, 1.0) || JSM.IsEqual (uy, 0.0) || JSM.IsEqual (uy, 1.0)) { + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } + + return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint; +}; + +/** +* Function: Sector2D.ProjectCoord +* Description: Calculates the projected coordinate of the given coordinate. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {Coord2D} the projected coordinate +*/ +JSM.Sector2D.prototype.ProjectCoord = function (coord) +{ + var x = coord.x; + var y = coord.y; + + var beg = this.beg; + var end = this.end; + var x1 = beg.x; + var y1 = beg.y; + var x2 = end.x; + var y2 = end.y; + + var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + if (JSM.IsZero (denom)) { + return beg.Clone (); + } + + var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1)) / denom; + if (JSM.IsLower (u, 0.0)) { + return beg.Clone (); + } else if (JSM.IsGreater (u, 1.0)) { + return end.Clone (); + } + + var dir = JSM.CoordSub2D (end, beg).MultiplyScalar (u); + var result = JSM.CoordAdd2D (beg, dir); + return result; +}; + /** * Function: Sector2D.Clone * Description: Clones the sector. @@ -59,7 +259,6 @@ JSM.Sector = function (beg, end) this.end = end; }; - /** * Function: Sector.Set * Description: Sets the sector. @@ -84,6 +283,54 @@ JSM.Sector.prototype.GetLength = function () return this.beg.DistanceTo (this.end); }; +/** +* Function: Sector.CoordPosition +* Description: Calculates the position of the sector and the given coordinate. +* Parameters: +* coord {Coord} the coordinate +* Returns: +* {CoordSectorPosition} the result +*/ +JSM.Sector.prototype.CoordPosition = function (coord) +{ + var x = coord.x; + var y = coord.y; + var z = coord.z; + + var a = this.beg; + var b = JSM.CoordSub (this.end, this.beg); + + var x1 = a.x; + var y1 = a.y; + var z1 = a.z; + var x2 = a.x + b.x; + var y2 = a.y + b.y; + var z2 = a.z + b.z; + + var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); + if (JSM.IsZero (denom)) { + if (a.IsEqual (coord)) { + return JSM.CoordSectorPosition.CoordOnSectorEndCoord; + } + return JSM.CoordSectorPosition.CoordOutsideOfSector; + } + + var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; + var bu = b.Clone ().MultiplyScalar (u); + var c = JSM.CoordAdd (a, bu); + var distance = coord.DistanceTo (c); + if (JSM.IsZero (distance)) { + if (JSM.IsLower (u, 0.0) || JSM.IsGreater (u, 1.0)) { + return JSM.CoordSectorPosition.CoordOutsideOfSector; + } else if (JSM.IsEqual (u, 0.0) || JSM.IsEqual (u, 1.0)) { + return JSM.CoordSectorPosition.CoordOnSectorEndCoord; + } + return JSM.CoordSectorPosition.CoordInsideOfSector; + } + + return JSM.CoordSectorPosition.CoordOutsideOfSector; +}; + /** * Function: Sector.Clone * Description: Clones the sector. @@ -94,3 +341,26 @@ JSM.Sector.prototype.Clone = function () { return new JSM.Sector (this.beg.Clone (), this.end.Clone ()); }; + +/** +* Function: GetSectorSegmentation +* Description: Returns the segmented coordinates of a sector. +* Parameters: +* sector {Sector} the sector +* segmentation {integer} the segmentation +* coords {Coord[*]} (out) the result coordinates +*/ +JSM.GetSectorSegmentation = function (sector, segmentation, coords) +{ + var direction = JSM.CoordSub (sector.end, sector.beg); + var length = sector.beg.DistanceTo (sector.end); + var step = length / segmentation; + var distance = 0.0; + + var i, offseted; + for (i = 0; i <= segmentation; i++) { + offseted = sector.beg.Clone ().Offset (direction, distance); + coords.push (offseted); + distance += step; + } +}; diff --git a/src/geometry/sectorutils.js b/src/geometry/sectorutils.js deleted file mode 100644 index 0a8984df..00000000 --- a/src/geometry/sectorutils.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* Function: CoordSectorPosition2D -* Description: Calculates the position of a coordinate and a sector. -* Parameters: -* coord {Coord2D} the coordinate -* sector {Sector2D} the sector -* Returns: -* {string} 'CoordOnSectorEndCoord', 'CoordOutsideOfSector', or 'CoordInsideOfSector' -*/ -JSM.CoordSectorPosition2D = function (coord, sector) -{ - var x = coord.x; - var y = coord.y; - var x1 = sector.beg.x; - var y1 = sector.beg.y; - var x2 = sector.end.x; - var y2 = sector.end.y; - - var length = sector.GetLength (); - if (JSM.IsZero (length)) { - if (coord.IsEqual (sector.beg)) { - return 'CoordOnSectorEndCoord'; - } - - return 'CoordOutsideOfSector'; - } - - var u = ((x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)) / (length * length); - if (JSM.IsLower (u, 0.0) || JSM.IsGreater (u, 1.0)) { - return 'CoordOutsideOfSector'; - } - - var ux = x1 + u * (x2 - x1); - var uy = y1 + u * (y2 - y1); - if (!JSM.IsEqual (ux, x) || !JSM.IsEqual (uy, y)) { - return 'CoordOutsideOfSector'; - } - - if (JSM.IsEqual (u, 0.0) || JSM.IsEqual (u, 1.0)) { - return 'CoordOnSectorEndCoord'; - } - - return 'CoordInsideOfSector'; -}; - -/** -* Function: ProjectCoordToSector2D -* Description: Projects a coordinate to a sector. -* Parameters: -* coord {Coord2D} the coordinate -* sector {Sector2D} the sector -* Returns: -* {Coord2D} the projected coordinate -*/ -JSM.ProjectCoordToSector2D = function (coord, sector) -{ - var x = coord.x; - var y = coord.y; - - var beg = sector.beg; - var end = sector.end; - var x1 = beg.x; - var y1 = beg.y; - var x2 = end.x; - var y2 = end.y; - - var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); - if (JSM.IsZero (denom)) { - return beg; - } - - var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1)) / denom; - if (JSM.IsLower (u, 0.0)) { - return beg; - } else if (JSM.IsGreater (u, 1.0)) { - return end; - } - - var dir = JSM.CoordSub2D (end, beg); - dir.MultiplyScalar (u); - var result = JSM.CoordAdd2D (beg, dir); - return result; -}; - -/** -* Function: CoordSectorPosition -* Description: Calculates the position of a coordinate and a sector. -* Parameters: -* coord {Coord} the coordinate -* sector {Sector} the sector -* Returns: -* {string} 'CoordOnSectorEndCoord', 'CoordOutsideOfSector', or 'CoordInsideOfSector' -*/ -JSM.CoordSectorPosition = function (coord, sector) -{ - var x = coord.x; - var y = coord.y; - var z = coord.z; - - var a = sector.beg; - var b = JSM.CoordSub (sector.end, sector.beg); - - var x1 = a.x; - var y1 = a.y; - var z1 = a.z; - var x2 = a.x + b.x; - var y2 = a.y + b.y; - var z2 = a.z + b.z; - - var denom = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); - if (JSM.IsZero (denom)) { - if (a.IsEqual (coord)) { - return 'CoordOnSectorEndCoord'; - } - return 'CoordOutsideOfSector'; - } - - var u = ((x2 - x1) * (x - x1) + (y2 - y1) * (y - y1) + (z2 - z1) * (z - z1)) / denom; - var bu = b.Clone ().MultiplyScalar (u); - var c = JSM.CoordAdd (a, bu); - var distance = coord.DistanceTo (c); - if (JSM.IsZero (distance)) { - if (JSM.IsLower (u, 0.0) || JSM.IsGreater (u, 1.0)) { - return 'CoordOutsideOfSector'; - } else if (JSM.IsEqual (u, 0.0) || JSM.IsEqual (u, 1.0)) { - return 'CoordOnSectorEndCoord'; - } - return 'CoordInsideOfSector'; - } - - return 'CoordOutsideOfSector'; -}; - -/** -* Function: SectorSectorPosition2D -* Description: Calculates the position of two sectors. -* Parameters: -* aSector {Sector2D} the first sector -* bSector {Sector2D} the second sector -* Returns: -* {string} 'SectorsIntersectsCoincident', 'SectorsIntersectsEndPoint', 'SectorsIntersectsOnePoint', or 'SectorsDontIntersects' -*/ -JSM.SectorSectorPosition2D = function (aSector, bSector, intersection) -{ - var x1 = aSector.beg.x; - var y1 = aSector.beg.y; - var x2 = aSector.end.x; - var y2 = aSector.end.y; - var x3 = bSector.beg.x; - var y3 = bSector.beg.y; - var x4 = bSector.end.x; - var y4 = bSector.end.y; - - var ux = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var uy = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - - if (JSM.IsZero (ux) && JSM.IsZero (uy)) { - var aBeg = JSM.CoordSectorPosition2D (aSector.beg, bSector); - var aEnd = JSM.CoordSectorPosition2D (aSector.end, bSector); - var bBeg = JSM.CoordSectorPosition2D (bSector.beg, aSector); - var bEnd = JSM.CoordSectorPosition2D (bSector.end, aSector); - if (aBeg === 'CoordInsideOfSector' || aEnd === 'CoordInsideOfSector' || bBeg === 'CoordInsideOfSector' || bEnd === 'CoordInsideOfSector') { - return 'SectorsIntersectsCoincident'; - } else if (aBeg === 'CoordOnSectorEndCoord' && aEnd === 'CoordOnSectorEndCoord' && bBeg === 'CoordOnSectorEndCoord' && bEnd === 'CoordOnSectorEndCoord') { - return 'SectorsIntersectsCoincident'; - } else if (aBeg === 'CoordOnSectorEndCoord' || aEnd === 'CoordOnSectorEndCoord' || bBeg === 'CoordOnSectorEndCoord' || bEnd === 'CoordOnSectorEndCoord') { - if (intersection !== undefined) { - if (aBeg === 'CoordOnSectorEndCoord') { - intersection = aSector.beg; - } else if (aEnd === 'CoordOnSectorEndCoord') { - intersection = aSector.end; - } else if (bBeg === 'CoordOnSectorEndCoord') { - intersection = bSector.beg; - } else if (bEnd === 'CoordOnSectorEndCoord') { - intersection = bSector.end; - } - } - return 'SectorsIntersectsEndPoint'; - } - - return 'SectorsDontIntersects'; - } - - var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - if (JSM.IsZero (denom)) { - return 'SectorsDontIntersects'; - } - - ux /= denom; - uy /= denom; - if (JSM.IsLower (ux, 0.0) || JSM.IsGreater (ux, 1.0) || JSM.IsLower (uy, 0.0) || JSM.IsGreater (uy, 1.0)) { - return 'SectorsDontIntersects'; - } - - if (intersection !== undefined) { - intersection.x = x1 + ux * (x2 - x1); - intersection.y = y1 + ux * (y2 - y1); - } - - if (JSM.IsEqual (ux, 0.0) || JSM.IsEqual (ux, 1.0) || JSM.IsEqual (uy, 0.0) || JSM.IsEqual (uy, 1.0)) { - return 'SectorsIntersectsEndPoint'; - } - - return 'SectorsIntersectsOnePoint'; -}; - -/** -* Function: GetSectorSegmentation -* Description: Returns the segmented coordinates of a sector. -* Parameters: -* sector {Sector} the sector -* segmentation {integer} the segmentation -* coords {Coord[*]} (out) the result coordinates -*/ -JSM.GetSectorSegmentation = function (sector, segmentation, coords) -{ - var direction = JSM.CoordSub (sector.end, sector.beg); - var length = sector.beg.DistanceTo (sector.end); - var step = length / segmentation; - var distance = 0.0; - - var i, offseted; - for (i = 0; i <= segmentation; i++) { - offseted = sector.beg.Clone ().Offset (direction, distance); - coords.push (offseted); - distance += step; - } -}; diff --git a/src/geometry/transformation.js b/src/geometry/transformation.js index f24725a3..f0214fea 100644 --- a/src/geometry/transformation.js +++ b/src/geometry/transformation.js @@ -65,3 +65,150 @@ JSM.Transformation.prototype.Clone = function () result.matrix = JSM.MatrixClone (this.matrix); return result; }; + +/** +* Function: IdentityTransformation +* Description: Generates an identity transformation. +* Returns: +* {Transformation} the result +*/ +JSM.IdentityTransformation = function () +{ + var transformation = new JSM.Transformation (); + transformation.matrix = JSM.MatrixIdentity (); + return transformation; +}; + +/** +* Function: TranslationTransformation +* Description: Generates a translation transformation. +* Parameters: +* translation {Vector} the translation vector +* Returns: +* {Transformation} the result +*/ +JSM.TranslationTransformation = function (translation) +{ + var transformation = new JSM.Transformation (); + transformation.matrix = JSM.MatrixTranslation (translation.x, translation.y, translation.z); + return transformation; +}; + +/** +* Function: OffsetTransformation +* Description: Generates an offset transformation. +* Parameters: +* direction {Vector} the direction of the offset +* distance {number} the distance of the offset +* Returns: +* {Transformation} the result +*/ +JSM.OffsetTransformation = function (direction, distance) +{ + var normal = direction.Clone ().Normalize (); + var translation = normal.Clone ().MultiplyScalar (distance); + return JSM.TranslationTransformation (translation); +}; + +/** +* Function: RotationTransformation +* Description: Generates a rotation transformation. +* Parameters: +* axis {Vector} the axis of the rotation +* angle {number} the angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Transformation} the result +*/ +JSM.RotationTransformation = function (axis, angle, origo) +{ + var transformation = new JSM.Transformation (); + transformation.matrix = JSM.MatrixRotation (axis, angle, origo); + return transformation; +}; + +/** +* Function: RotationXTransformation +* Description: Generates a rotation transformation around the x axis. +* Parameters: +* angle {number} the angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Transformation} the result +*/ +JSM.RotationXTransformation = function (angle, origo) +{ + var transformation = new JSM.Transformation (); + if (origo === undefined || origo === null) { + transformation.matrix = JSM.MatrixRotationX (angle); + } else { + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); + transformation.Append (JSM.RotationXTransformation (angle)); + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); + } + return transformation; +}; + +/** +* Function: RotationYTransformation +* Description: Generates a rotation transformation around the y axis. +* Parameters: +* angle {number} the angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Transformation} the result +*/ +JSM.RotationYTransformation = function (angle, origo) +{ + var transformation = new JSM.Transformation (); + if (origo === undefined || origo === null) { + transformation.matrix = JSM.MatrixRotationY (angle); + } else { + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); + transformation.Append (JSM.RotationYTransformation (angle)); + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); + } + return transformation; +}; + +/** +* Function: RotationZTransformation +* Description: Generates a rotation transformation around the z axis. +* Parameters: +* angle {number} the angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Transformation} the result +*/ +JSM.RotationZTransformation = function (angle, origo) +{ + var transformation = new JSM.Transformation (); + if (origo === undefined || origo === null) { + transformation.matrix = JSM.MatrixRotationZ (angle); + } else { + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); + transformation.Append (JSM.RotationZTransformation (angle)); + transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); + } + return transformation; +}; + +/** +* Function: RotationXYZTransformation +* Description: Generates a rotation transformation around all axis in x, y, z order. +* Parameters: +* xAngle {number} the x angle of the rotation +* yAngle {number} the y angle of the rotation +* zAngle {number} the z angle of the rotation +* origo {Coord} the origo of the rotation +* Returns: +* {Transformation} the result +*/ +JSM.RotationXYZTransformation = function (xAngle, yAngle, zAngle, origo) +{ + var transformation = new JSM.Transformation (); + transformation.Append (JSM.RotationXTransformation (xAngle, origo)); + transformation.Append (JSM.RotationYTransformation (yAngle, origo)); + transformation.Append (JSM.RotationZTransformation (zAngle, origo)); + return transformation; +}; diff --git a/src/geometry/transformationutils.js b/src/geometry/transformationutils.js deleted file mode 100644 index b94ed15d..00000000 --- a/src/geometry/transformationutils.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* Function: IdentityTransformation -* Description: Generates an identity transformation. -* Returns: -* {Transformation} the result -*/ -JSM.IdentityTransformation = function () -{ - var transformation = new JSM.Transformation (); - transformation.matrix = JSM.MatrixIdentity (); - return transformation; -}; - -/** -* Function: TranslationTransformation -* Description: Generates a translation transformation. -* Parameters: -* translation {Vector} the translation vector -* Returns: -* {Transformation} the result -*/ -JSM.TranslationTransformation = function (translation) -{ - var transformation = new JSM.Transformation (); - transformation.matrix = JSM.MatrixTranslation (translation.x, translation.y, translation.z); - return transformation; -}; - -/** -* Function: OffsetTransformation -* Description: Generates an offset transformation. -* Parameters: -* direction {Vector} the direction of the offset -* distance {number} the distance of the offset -* Returns: -* {Transformation} the result -*/ -JSM.OffsetTransformation = function (direction, distance) -{ - var normal = direction.Clone ().Normalize (); - var translation = normal.Clone ().MultiplyScalar (distance); - return JSM.TranslationTransformation (translation); -}; - -/** -* Function: RotationTransformation -* Description: Generates a rotation transformation. -* Parameters: -* axis {Vector} the axis of the rotation -* angle {number} the angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Transformation} the result -*/ -JSM.RotationTransformation = function (axis, angle, origo) -{ - var transformation = new JSM.Transformation (); - transformation.matrix = JSM.MatrixRotation (axis, angle, origo); - return transformation; -}; - -/** -* Function: RotationXTransformation -* Description: Generates a rotation transformation around the x axis. -* Parameters: -* angle {number} the angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Transformation} the result -*/ -JSM.RotationXTransformation = function (angle, origo) -{ - var transformation = new JSM.Transformation (); - if (origo === undefined || origo === null) { - transformation.matrix = JSM.MatrixRotationX (angle); - } else { - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); - transformation.Append (JSM.RotationXTransformation (angle)); - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); - } - return transformation; -}; - -/** -* Function: RotationYTransformation -* Description: Generates a rotation transformation around the y axis. -* Parameters: -* angle {number} the angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Transformation} the result -*/ -JSM.RotationYTransformation = function (angle, origo) -{ - var transformation = new JSM.Transformation (); - if (origo === undefined || origo === null) { - transformation.matrix = JSM.MatrixRotationY (angle); - } else { - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); - transformation.Append (JSM.RotationYTransformation (angle)); - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); - } - return transformation; -}; - -/** -* Function: RotationZTransformation -* Description: Generates a rotation transformation around the z axis. -* Parameters: -* angle {number} the angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Transformation} the result -*/ -JSM.RotationZTransformation = function (angle, origo) -{ - var transformation = new JSM.Transformation (); - if (origo === undefined || origo === null) { - transformation.matrix = JSM.MatrixRotationZ (angle); - } else { - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (-origo.x, -origo.y, -origo.z))); - transformation.Append (JSM.RotationZTransformation (angle)); - transformation.Append (JSM.TranslationTransformation (new JSM.Vector (origo.x, origo.y, origo.z))); - } - return transformation; -}; - -/** -* Function: RotationXYZTransformation -* Description: Generates a rotation transformation around all axis in x, y, z order. -* Parameters: -* xAngle {number} the x angle of the rotation -* yAngle {number} the y angle of the rotation -* zAngle {number} the z angle of the rotation -* origo {Coord} the origo of the rotation -* Returns: -* {Transformation} the result -*/ -JSM.RotationXYZTransformation = function (xAngle, yAngle, zAngle, origo) -{ - var transformation = new JSM.Transformation (); - transformation.Append (JSM.RotationXTransformation (xAngle, origo)); - transformation.Append (JSM.RotationYTransformation (yAngle, origo)); - transformation.Append (JSM.RotationZTransformation (zAngle, origo)); - return transformation; -}; diff --git a/src/modeler/body.js b/src/modeler/body.js index 13f45863..4a8d1e88 100644 --- a/src/modeler/body.js +++ b/src/modeler/body.js @@ -472,12 +472,12 @@ JSM.Body.prototype.Transform = function (transformation) } if (this.coords !== null) { - var absoluteSystem = JSM.CoordSystemToAbsoluteCoords (this.coords); - absoluteSystem.origo = transformation.Apply (absoluteSystem.origo); - absoluteSystem.e1 = transformation.Apply (absoluteSystem.e1); - absoluteSystem.e2 = transformation.Apply (absoluteSystem.e2); - absoluteSystem.e3 = transformation.Apply (absoluteSystem.e3); - this.coords = JSM.CoordSystemToDirectionVectors (absoluteSystem); + this.coords.ToAbsoluteCoords (); + this.coords.origo = transformation.Apply (this.coords.origo); + this.coords.e1 = transformation.Apply (this.coords.e1); + this.coords.e2 = transformation.Apply (this.coords.e2); + this.coords.e3 = transformation.Apply (this.coords.e3); + this.coords.ToDirectionVectors (); } }; diff --git a/src/modeler/bodyutils.js b/src/modeler/bodyutils.js index 93889972..31013791 100644 --- a/src/modeler/bodyutils.js +++ b/src/modeler/bodyutils.js @@ -369,7 +369,7 @@ JSM.MergeCoplanarPolygons = function (body) var coplanarPgons = []; var angle; JSM.TraversePgonsAlongEdges (pgonIndex, adjacency, function (currentIndex) { - angle = JSM.GetVectorsAngle (pgonNormals[pgonIndex], pgonNormals[currentIndex]); + angle = pgonNormals[pgonIndex].AngleTo (pgonNormals[currentIndex]); if (JSM.IsEqual (angle, 0.0)) { coplanarPgons.push (currentIndex); processedPgons[currentIndex] = true; diff --git a/src/modeler/cututils.js b/src/modeler/cututils.js index 7a3bec9e..e53b3753 100644 --- a/src/modeler/cututils.js +++ b/src/modeler/cututils.js @@ -21,7 +21,7 @@ JSM.CutBodyByPlane = function (body, plane) { direction = JSM.CoordSub (polygon[to], polygon[from]).Normalize (); line = new JSM.Line (polygon[from], direction); - intersection = JSM.LinePlaneIntersection (line, plane); + intersection = plane.LineIntersection (line); rawResult.push (new JSM.Coord (intersection.x, intersection.y, intersection.z)); rawIndexTable.push (-1); } @@ -35,8 +35,8 @@ JSM.CutBodyByPlane = function (body, plane) var i, position, vertex; for (i = 0; i < count; i++) { vertex = polygon[i]; - position = JSM.CoordPlanePosition (vertex, plane); - front.push (position !== 'CoordAtBackOfPlane'); + position = plane.CoordPosition (vertex); + front.push (position !== JSM.CoordPlanePosition.CoordAtBackOfPlane); if (i > 0 && front[i - 1] !== front[i]) { needCut = true; } diff --git a/src/modeler/generator.js b/src/modeler/generator.js index 0c1b383b..c0122607 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -1179,7 +1179,7 @@ JSM.GenerateLineShell = function (basePolyLine, direction, height, width, withSt nextDir = JSM.CoordSub (basePolyLine[next], basePolyLine[curr]); prevDir = JSM.CoordSub (basePolyLine[prev], basePolyLine[curr]); - angle = JSM.GetVectorsAngle (nextDir, prevDir) / 2.0; + angle = nextDir.AngleTo (prevDir) / 2.0; if (JSM.CoordOrientation (basePolyLine[prev], basePolyLine[curr], basePolyLine[next], direction) == JSM.Orientation.Clockwise) { angle = Math.PI - angle; } @@ -1735,14 +1735,14 @@ JSM.GenerateRevolved = function (polyLine, axis, angle, segmentation, withTopAnd var avgRadius = 0.0; var projected; for (i = 0; i < count; i++) { - projected = JSM.ProjectCoordToLine (polyLine[i], axisLine); + projected = axisLine.ProjectCoord (polyLine[i]); avgRadius = avgRadius + projected.DistanceTo (polyLine[i]); } avgRadius = avgRadius / count; var origo = new JSM.Coord (axis.beg.x, axis.beg.y, axis.beg.z); var baseLine = new JSM.Line (origo, axisDir); - var projectedToBaseLine = JSM.ProjectCoordToLine (polyLine[0], baseLine); + var projectedToBaseLine = baseLine.ProjectCoord (polyLine[0]); var xDirection = JSM.CoordSub (polyLine[0], projectedToBaseLine).Normalize (); result.SetCylindricalTextureProjection (origo, avgRadius, xDirection, axisNormalDir); diff --git a/src/modeler/textureutils.js b/src/modeler/textureutils.js index d186e602..98cd64a6 100644 --- a/src/modeler/textureutils.js +++ b/src/modeler/textureutils.js @@ -19,9 +19,9 @@ JSM.CalculatePlanarTextureCoord = function (coord, system) var xzPlane = JSM.GetPlaneFromCoordAndDirection (system.origo, e2); var yzPlane = JSM.GetPlaneFromCoordAndDirection (system.origo, e1); - var projected = JSM.ProjectCoordToPlane (coord, xyPlane); - result.x = JSM.CoordPlaneSignedDistance (projected, yzPlane); - result.y = JSM.CoordPlaneSignedDistance (projected, xzPlane); + var projected = xyPlane.ProjectCoord (coord); + result.x = yzPlane.CoordSignedDistance (projected); + result.y = xzPlane.CoordSignedDistance (projected); return result; }; @@ -114,13 +114,13 @@ JSM.CalculateCylindricalTextureCoord = function (coord, normal, system) var result = new JSM.Coord2D (0.0, 0.0); var e3Direction = system.e3.Clone ().Normalize (); - if (JSM.VectorsAreCollinear (e3Direction, normal)) { + if (e3Direction.IsCollinearWith (normal)) { result = JSM.CalculateCubicTextureCoord (coord, normal, system); return [result, 0.0]; } var baseLine = new JSM.Line (system.origo, e3Direction); - var projectedCoord = JSM.ProjectCoordToLine (coord, baseLine); + var projectedCoord = baseLine.ProjectCoord (coord); var projectedDistance = JSM.CoordSignedDistance (system.origo, projectedCoord, e3Direction); var e1Direction = system.e1.Clone ().Normalize (); @@ -209,7 +209,7 @@ JSM.CalculatePolygonCylindricalTextureCoords = function (body, index, normal) } var e3Direction = system.e3.Clone ().Normalize (); - if (JSM.VectorsAreCollinear (e3Direction, normal)) { + if (e3Direction.IsCollinearWith (normal)) { return result; } diff --git a/src/viewer/navigation.js b/src/viewer/navigation.js index 17f5d1eb..7aa16938 100644 --- a/src/viewer/navigation.js +++ b/src/viewer/navigation.js @@ -126,7 +126,7 @@ JSM.Navigation.prototype.Orbit = function (angleX, angleY) var differentCenter = !this.orbitCenter.IsEqual (this.camera.center); if (this.cameraFixUp) { - var originalAngle = JSM.GetVectorsAngle (viewDirection, this.camera.up); + var originalAngle = viewDirection.AngleTo (this.camera.up); var newAngle = originalAngle + radAngleY; if (JSM.IsGreater (newAngle, 0.0) && JSM.IsLower (newAngle, Math.PI)) { this.camera.eye.Rotate (horizontalDirection, -radAngleY, this.orbitCenter); diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index ce643c41..b25878ef 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -15,16 +15,11 @@ unitTest.AddSourceFile ('../../src/geometry/coordutils.js'); unitTest.AddSourceFile ('../../src/geometry/matrix.js'); unitTest.AddSourceFile ('../../src/geometry/coordsystem.js'); unitTest.AddSourceFile ('../../src/geometry/sector.js'); -unitTest.AddSourceFile ('../../src/geometry/sectorutils.js'); unitTest.AddSourceFile ('../../src/geometry/line.js'); -unitTest.AddSourceFile ('../../src/geometry/lineutils.js'); unitTest.AddSourceFile ('../../src/geometry/box.js'); -unitTest.AddSourceFile ('../../src/geometry/boxutils.js'); unitTest.AddSourceFile ('../../src/geometry/sphere.js'); unitTest.AddSourceFile ('../../src/geometry/transformation.js'); -unitTest.AddSourceFile ('../../src/geometry/transformationutils.js'); unitTest.AddSourceFile ('../../src/geometry/plane.js'); -unitTest.AddSourceFile ('../../src/geometry/planeutils.js'); unitTest.AddSourceFile ('../../src/geometry/projection.js'); unitTest.AddSourceFile ('../../src/geometry/convexhull.js'); unitTest.AddSourceFile ('../../src/geometry/polygon.js'); diff --git a/test/unittest/references/generator_circle.svg b/test/unittest/references/generator_circle.svg new file mode 100644 index 00000000..6c3ed4c2 --- /dev/null +++ b/test/unittest/references/generator_circle.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/unittest/references/generator_cone1.svg b/test/unittest/references/generator_cone1.svg new file mode 100644 index 00000000..55ecc982 --- /dev/null +++ b/test/unittest/references/generator_cone1.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_cone2.svg b/test/unittest/references/generator_cone2.svg new file mode 100644 index 00000000..ab775646 --- /dev/null +++ b/test/unittest/references/generator_cone2.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_cuboid.svg b/test/unittest/references/generator_cuboid.svg new file mode 100644 index 00000000..3546ac8d --- /dev/null +++ b/test/unittest/references/generator_cuboid.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_cuboidsides.svg b/test/unittest/references/generator_cuboidsides.svg new file mode 100644 index 00000000..ab3211b0 --- /dev/null +++ b/test/unittest/references/generator_cuboidsides.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/unittest/references/generator_cylinder.svg b/test/unittest/references/generator_cylinder.svg new file mode 100644 index 00000000..c1d783ce --- /dev/null +++ b/test/unittest/references/generator_cylinder.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_cylindershell.svg b/test/unittest/references/generator_cylindershell.svg new file mode 100644 index 00000000..45a9de2c --- /dev/null +++ b/test/unittest/references/generator_cylindershell.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_function.svg b/test/unittest/references/generator_function.svg new file mode 100644 index 00000000..78d7b06d --- /dev/null +++ b/test/unittest/references/generator_function.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_functionsolid.svg b/test/unittest/references/generator_functionsolid.svg new file mode 100644 index 00000000..60289904 --- /dev/null +++ b/test/unittest/references/generator_functionsolid.svg @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_grid.svg b/test/unittest/references/generator_grid.svg new file mode 100644 index 00000000..3186c3e1 --- /dev/null +++ b/test/unittest/references/generator_grid.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_lineshell.svg b/test/unittest/references/generator_lineshell.svg new file mode 100644 index 00000000..9de20f11 --- /dev/null +++ b/test/unittest/references/generator_lineshell.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_pie.svg b/test/unittest/references/generator_pie.svg new file mode 100644 index 00000000..c0838bd3 --- /dev/null +++ b/test/unittest/references/generator_pie.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_polytorus.svg b/test/unittest/references/generator_polytorus.svg new file mode 100644 index 00000000..85b9fa88 --- /dev/null +++ b/test/unittest/references/generator_polytorus.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_prism.svg b/test/unittest/references/generator_prism.svg new file mode 100644 index 00000000..c09a6742 --- /dev/null +++ b/test/unittest/references/generator_prism.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/unittest/references/generator_prismshell.svg b/test/unittest/references/generator_prismshell.svg new file mode 100644 index 00000000..668d37cf --- /dev/null +++ b/test/unittest/references/generator_prismshell.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_rectangle.svg b/test/unittest/references/generator_rectangle.svg new file mode 100644 index 00000000..638a07b4 --- /dev/null +++ b/test/unittest/references/generator_rectangle.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/test/unittest/references/generator_revolved1.svg b/test/unittest/references/generator_revolved1.svg new file mode 100644 index 00000000..a86cbec2 --- /dev/null +++ b/test/unittest/references/generator_revolved1.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_revolved2.svg b/test/unittest/references/generator_revolved2.svg new file mode 100644 index 00000000..ee699993 --- /dev/null +++ b/test/unittest/references/generator_revolved2.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_ruled.svg b/test/unittest/references/generator_ruled.svg new file mode 100644 index 00000000..f8948c30 --- /dev/null +++ b/test/unittest/references/generator_ruled.svg @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_segmentedcuboid.svg b/test/unittest/references/generator_segmentedcuboid.svg new file mode 100644 index 00000000..fb0d75e3 --- /dev/null +++ b/test/unittest/references/generator_segmentedcuboid.svg @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_segmentedrectangle.svg b/test/unittest/references/generator_segmentedrectangle.svg new file mode 100644 index 00000000..f947a323 --- /dev/null +++ b/test/unittest/references/generator_segmentedrectangle.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_sphere.svg b/test/unittest/references/generator_sphere.svg new file mode 100644 index 00000000..9aea21a3 --- /dev/null +++ b/test/unittest/references/generator_sphere.svg @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_squaregrid.svg b/test/unittest/references/generator_squaregrid.svg new file mode 100644 index 00000000..6ebe0ecf --- /dev/null +++ b/test/unittest/references/generator_squaregrid.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_torus.svg b/test/unittest/references/generator_torus.svg new file mode 100644 index 00000000..d94fe735 --- /dev/null +++ b/test/unittest/references/generator_torus.svg @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_triangulatedsphere.svg b/test/unittest/references/generator_triangulatedsphere.svg new file mode 100644 index 00000000..f079ca90 --- /dev/null +++ b/test/unittest/references/generator_triangulatedsphere.svg @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/references/generator_tube.svg b/test/unittest/references/generator_tube.svg new file mode 100644 index 00000000..2932ecf2 --- /dev/null +++ b/test/unittest/references/generator_tube.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index b25faaac..29276de5 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -90,7 +90,7 @@ generalSuite.AddTest ('VectorTest', function (test) { var vector1 = new JSM.Vector (1.0, 0.0, 0.0); var vector2 = new JSM.Vector (0.0, 1.0, 0.0); - test.Assert (JSM.IsEqual (JSM.GetVectorsAngle (vector1, vector2), 90.0 * JSM.DegRad)); + test.Assert (JSM.IsEqual (vector1.AngleTo (vector2), 90.0 * JSM.DegRad)); var vector = new JSM.Vector (1.0, 0.0, 0.0); test.Assert (JSM.IsEqual (vector.Length (), 1.0)); @@ -114,9 +114,9 @@ generalSuite.AddTest ('VectorTest', function (test) { var coord = new JSM.Coord (1.0, 2.0, 3.0); var normal = new JSM.Coord (0.0, 1.0, 0.0); - var origo = new JSM.Coord (0.0, 0.0, 0.0); - var coord2D = JSM.GetCoord2DFromCoord (coord, origo, normal); - test.Assert (coord2D.IsEqual (new JSM.Coord (1.0, -3.0))); + var coord2D = coord.ToCoord2D (normal); + test.Assert (coord.IsEqual (new JSM.Coord (1.0, 2.0, 3.0))); + test.Assert (coord2D.IsEqual (new JSM.Coord2D (1.0, -3.0))); var coords = [ new JSM.Coord (0.0, 0.0, 0.0), @@ -155,8 +155,8 @@ generalSuite.AddTest ('VectorTest', function (test) { var vector1 = new JSM.Vector (1.0, 0.0, 0.0); var vector2 = new JSM.Vector (0.0, 1.0, 0.0); - test.Assert (JSM.IsEqual (JSM.GetVectorsAngle (vector1, vector2), Math.PI / 2.0)); - test.Assert (JSM.IsEqual (JSM.GetVectorsAngle (vector2, vector1), Math.PI / 2.0)); + test.Assert (JSM.IsEqual (vector1.AngleTo (vector2), Math.PI / 2.0)); + test.Assert (JSM.IsEqual (vector2.AngleTo (vector1), Math.PI / 2.0)); var coord1 = new JSM.Vector (0.0, 0.0, 0.0); var coord2 = new JSM.Vector (1.0, 0.0, 0.0); @@ -578,25 +578,25 @@ generalSuite.AddTest ('CoordLinePositionTest', function (test) var start2D = new JSM.Coord2D (1.0, 1.0); var direction2D = new JSM.Coord2D (1.0, 0.0); var line2D = new JSM.Line2D (start2D, direction2D); - test.Assert (JSM.CoordLinePosition2D (new JSM.Coord2D (0.0, 0.0), line2D) == 'CoordAtLineRight'); - test.Assert (JSM.CoordLinePosition2D (new JSM.Coord2D (0.0, 2.0), line2D) == 'CoordAtLineLeft'); - test.Assert (JSM.CoordLinePosition2D (new JSM.Coord2D (0.0, 1.0), line2D) == 'CoordOnLine'); + test.Assert (line2D.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordLinePosition2D.CoordAtLineRight); + test.Assert (line2D.CoordPosition (new JSM.Coord2D (0.0, 2.0)) == JSM.CoordLinePosition2D.CoordAtLineLeft); + test.Assert (line2D.CoordPosition (new JSM.Coord2D (0.0, 1.0)) == JSM.CoordLinePosition2D.CoordOnLine); var start = new JSM.Coord (1.0, 1.0, 1.0); var direction = new JSM.Coord (1.0, 0.0, 0.0); var line = new JSM.Line (start, direction); var projected = new JSM.Coord (0.0, 0.0, 0.0); - test.Assert (JSM.CoordLinePosition (new JSM.Coord (0.0, 0.0, 0.0), line, projected) == 'CoordOutsideOfLine'); + test.Assert (line.CoordPosition (new JSM.Coord (0.0, 0.0, 0.0), projected) == JSM.CoordLinePosition.CoordOutsideOfLine); test.Assert (projected.IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); - test.Assert (JSM.CoordLinePosition (new JSM.Coord (1.0, 1.0, 1.0), line, projected) == 'CoordOnLine'); + test.Assert (line.CoordPosition (new JSM.Coord (1.0, 1.0, 1.0), projected) == JSM.CoordLinePosition.CoordOnLine); test.Assert (projected.IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); - test.Assert (JSM.CoordLinePosition (new JSM.Coord (2.0, 1.0, 1.0), line, projected) == 'CoordOnLine'); + test.Assert (line.CoordPosition (new JSM.Coord (2.0, 1.0, 1.0), projected) == JSM.CoordLinePosition.CoordOnLine); test.Assert (projected.IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); - test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (0.0, 0.0, 0.0), line).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); - test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (1.0, 1.0, 1.0), line).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); - test.Assert (JSM.ProjectCoordToLine (new JSM.Coord (2.0, 1.0, 1.0), line).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); + test.Assert (line.ProjectCoord (new JSM.Coord (0.0, 0.0, 0.0)).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (line.ProjectCoord (new JSM.Coord (1.0, 1.0, 1.0)).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (line.ProjectCoord (new JSM.Coord (2.0, 1.0, 1.0)).IsEqual (new JSM.Coord (2.0, 1.0, 1.0))); var line1 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0)); var line2 = new JSM.Line (new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0)); @@ -609,32 +609,32 @@ generalSuite.AddTest ('CoordLinePositionTest', function (test) var line9 = new JSM.Line (new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (-1.0, 1.0, 1.0)); var intersection = new JSM.Coord (0.0, 0.0, 0.0); - test.Assert (JSM.LineLinePosition (line1, line1, intersection) == 'LinesIntersectsCoincident'); - test.Assert (JSM.LineLinePosition (line1, line2, intersection) == 'LinesIntersectsCoincident'); - test.Assert (JSM.LineLinePosition (line1, line7, intersection) == 'LinesIntersectsCoincident'); - test.Assert (JSM.LineLinePosition (line2, line7, intersection) == 'LinesIntersectsCoincident'); - test.Assert (JSM.LineLinePosition (line3, line7, intersection) == 'LinesDontIntersects'); - test.Assert (JSM.LineLinePosition (line4, line7, intersection) == 'LinesDontIntersects'); - test.Assert (JSM.LineLinePosition (line5, line7, intersection) == 'LinesDontIntersects'); - test.Assert (JSM.LineLinePosition (line6, line7, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line1.LinePosition (line1, intersection) == JSM.LineLinePosition.LinesIntersectsCoincident); + test.Assert (line1.LinePosition (line2, intersection) == JSM.LineLinePosition.LinesIntersectsCoincident); + test.Assert (line1.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesIntersectsCoincident); + test.Assert (line2.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesIntersectsCoincident); + test.Assert (line3.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesDontIntersect); + test.Assert (line4.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesDontIntersect); + test.Assert (line5.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesDontIntersect); + test.Assert (line6.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.LineLinePosition (line1, line3, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line1.LinePosition (line3, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.LineLinePosition (line1, line4, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line1.LinePosition (line4, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (2.0, 0.0, 0.0))); - test.Assert (JSM.LineLinePosition (line1, line5, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line1.LinePosition (line5, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.LineLinePosition (line2, line3, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line2.LinePosition (line3, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 1.0, 0.0))); - test.Assert (JSM.LineLinePosition (line2, line4, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line2.LinePosition (line4, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (2.0, 1.0, 0.0))); - test.Assert (JSM.LineLinePosition (line2, line5, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line2.LinePosition (line5, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); - test.Assert (JSM.LineLinePosition (line5, line6, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line5.LinePosition (line6, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.LineLinePosition (line6, line7, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line6.LinePosition (line7, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.LineLinePosition (line8, line9, intersection) == 'LinesIntersectsOnePoint'); + test.Assert (line8.LinePosition (line9, intersection) == JSM.LineLinePosition.LinesIntersectsOnePoint); test.Assert (intersection.IsEqual (new JSM.Coord (0.5, 0.5, 0.5))); }); @@ -645,83 +645,83 @@ generalSuite.AddTest ('CoordSectorPositionTest', function (test) var sector3 = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 1.0, 1.0)); var sector4 = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (42.0, 0.0, 0.0)); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 1.0), sector1) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, -1.0), sector1) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.25, 0.0, 0.0), sector1) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.5, 0.0, 0.0), sector1) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.75, 0.0, 0.0), sector1) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 0.0), sector1) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.0, 0.0, 0.0), sector1) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (-0.1, 0.0, 0.0), sector1) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.1, 0.0, 0.0), sector1) == 'CoordOutsideOfSector'); - - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.0, 0.0, 0.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 0.0), sector2) == 'CoordOnSectorEndCoord'); - - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, -1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.25, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.5, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.75, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 0.0), sector3) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.0, 1.0, 1.0), sector3) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.0, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (-0.1, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.1, 0.0, 0.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.5, 0.5, 0.5), sector3) == 'CoordInsideOfSector'); - - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 1.0), sector4) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, -1.0), sector4) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.25, 0.0, 0.0), sector4) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.5, 0.0, 0.0), sector4) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.75, 0.0, 0.0), sector4) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (0.0, 0.0, 0.0), sector4) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.0, 0.0, 0.0), sector4) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (-0.1, 0.0, 0.0), sector4) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (1.1, 0.0, 0.0), sector4) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (42, 0.0, 0.0), sector4) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition (new JSM.Coord (42.1, 0.0, 0.0), sector4) == 'CoordOutsideOfSector'); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.0, 0.0, 1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.0, 0.0, -1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.25, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.5, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.75, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (0.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector1.CoordPosition (new JSM.Coord (1.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector1.CoordPosition (new JSM.Coord (-0.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord (1.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + + test.Assert (sector2.CoordPosition (new JSM.Coord (1.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord (0.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + + test.Assert (sector3.CoordPosition (new JSM.Coord (0.0, 0.0, 1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.0, 0.0, -1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.25, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.5, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.75, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector3.CoordPosition (new JSM.Coord (1.0, 1.0, 1.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector3.CoordPosition (new JSM.Coord (1.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (-0.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (1.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord (0.5, 0.5, 0.5)) == JSM.CoordSectorPosition.CoordInsideOfSector); + + test.Assert (sector4.CoordPosition (new JSM.Coord (0.0, 0.0, 1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (0.0, 0.0, -1.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (0.25, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (0.5, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (0.75, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (0.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector4.CoordPosition (new JSM.Coord (1.0, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (-0.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (1.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordInsideOfSector); + test.Assert (sector4.CoordPosition (new JSM.Coord (42, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOnSectorEndCoord); + test.Assert (sector4.CoordPosition (new JSM.Coord (42.1, 0.0, 0.0)) == JSM.CoordSectorPosition.CoordOutsideOfSector); }); generalSuite.AddTest ('CoordSectorPosition2DTest', function (test) { var coord = new JSM.Coord2D (1.0, 0.0); var sector = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); - test.Assert (JSM.CoordSectorPosition2D (coord, sector) == 'CoordOutsideOfSector'); + test.Assert (sector.CoordPosition (coord) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); var sector1 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (1.0, 2.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (4.0, 3.0)); var sector3 = new JSM.Sector2D (new JSM.Coord2D (1.0, 1.0), new JSM.Coord2D (3.0, 1.0)); var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (0.0, 0.0), sector1) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.0, 2.0), sector1) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.0, 2.001), sector1) == 'CoordOutsideOfSector'); - - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (0.0, 0.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (7.0, 5.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (-2.0, 2.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (2.0, 2.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (3.0, 2.5), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (2.0, 3.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (3.0, 3.0), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.0, 2.0), sector2) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (4.0, 3.0), sector2) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (2.5, 2.5), sector2) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.75, 2.25), sector2) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (2.5, 2.501), sector2) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.75, 2.26), sector2) == 'CoordOutsideOfSector'); - - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (4.0, 1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (3.001, 1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (0.0, 1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (0.999, 1.0), sector3) == 'CoordOutsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.0, 1.0), sector3) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (3.0, 1.0), sector3) == 'CoordOnSectorEndCoord'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.1, 1.0), sector3) == 'CoordInsideOfSector'); - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (1.123456789, 1.0), sector3) == 'CoordInsideOfSector'); - - test.Assert (JSM.CoordSectorPosition2D (new JSM.Coord2D (0.0, 0.0), sector4) == 'CoordOutsideOfSector'); + test.Assert (sector1.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector1.CoordPosition (new JSM.Coord2D (1.0, 2.0)) == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.Assert (sector1.CoordPosition (new JSM.Coord2D (1.0, 2.001)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + + test.Assert (sector2.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (7.0, 5.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (-2.0, 2.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (3.0, 2.5)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (2.0, 3.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (1.0, 2.0)) == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (4.0, 3.0)) == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (2.5, 2.5)) == JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (1.75, 2.25)) == JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (2.5, 2.501)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector2.CoordPosition (new JSM.Coord2D (1.75, 2.26)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + + test.Assert (sector3.CoordPosition (new JSM.Coord2D (4.0, 1.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (3.001, 1.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (0.0, 1.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (0.999, 1.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (3.0, 1.0)) == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (1.1, 1.0)) == JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.Assert (sector3.CoordPosition (new JSM.Coord2D (1.123456789, 1.0)) == JSM.CoordSectorPosition2D.CoordInsideOfSector); + + test.Assert (sector4.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); }); generalSuite.AddTest ('ProjectCoordToSector2DTest', function (test) @@ -731,35 +731,35 @@ generalSuite.AddTest ('ProjectCoordToSector2DTest', function (test) var sector3 = new JSM.Sector2D (new JSM.Coord2D (1.0, 1.0), new JSM.Coord2D (3.0, 1.0)); var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.001), sector1).IsEqual (new JSM.Coord2D (1.0, 2.0))); - - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector2).IsEqual (new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (7.0, 5.0), sector2).IsEqual (new JSM.Coord2D (4.0, 3.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (-2.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1, 2))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1.9, 2.3))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 2.5), sector2).IsEqual (new JSM.Coord2D (2.95, 2.65))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 3.0), sector2).IsEqual (new JSM.Coord2D (2.2, 2.4))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 3.0), sector2).IsEqual (new JSM.Coord2D (3.1, 2.7))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 2.0), sector2).IsEqual (new JSM.Coord2D (1.0, 2.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 3.0), sector2).IsEqual (new JSM.Coord2D (4.0, 3.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.5), sector2).IsEqual (new JSM.Coord2D (2.5, 2.5))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.25), sector2).IsEqual (new JSM.Coord2D (1.75, 2.25))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.5, 2.501), sector2).IsEqual (new JSM.Coord2D (2.5003, 2.5001))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.75, 2.26), sector2).IsEqual (new JSM.Coord2D (1.753, 2.251))); - - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (4.0, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.001, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.999, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.0, 1.0), sector3).IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (3.0, 1.0), sector3).IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.1, 1.0), sector3).IsEqual (new JSM.Coord2D (1.1, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (2.0, 0.0), sector3).IsEqual (new JSM.Coord2D (2.0, 1.0))); - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (1.123456789, 1.0), sector3).IsEqual (new JSM.Coord2D (1.123456789, 1.0))); - - test.Assert (JSM.ProjectCoordToSector2D (new JSM.Coord2D (0.0, 0.0), sector4).IsEqual (new JSM.Coord2D (0.0, 1.0))); + test.Assert (sector1.ProjectCoord (new JSM.Coord2D (0.0, 0.0)).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector1.ProjectCoord (new JSM.Coord2D (1.0, 2.0)).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector1.ProjectCoord (new JSM.Coord2D (1.0, 2.001)).IsEqual (new JSM.Coord2D (1.0, 2.0))); + + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (0.0, 0.0)).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (7.0, 5.0)).IsEqual (new JSM.Coord2D (4.0, 3.0))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (-2.0, 2.0)).IsEqual (new JSM.Coord2D (1, 2))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (2.0, 2.0)).IsEqual (new JSM.Coord2D (1.9, 2.3))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (3.0, 2.5)).IsEqual (new JSM.Coord2D (2.95, 2.65))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (2.0, 3.0)).IsEqual (new JSM.Coord2D (2.2, 2.4))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (3.0, 3.0)).IsEqual (new JSM.Coord2D (3.1, 2.7))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (1.0, 2.0)).IsEqual (new JSM.Coord2D (1.0, 2.0))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (4.0, 3.0)).IsEqual (new JSM.Coord2D (4.0, 3.0))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (2.5, 2.5)).IsEqual (new JSM.Coord2D (2.5, 2.5))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (1.75, 2.25)).IsEqual (new JSM.Coord2D (1.75, 2.25))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (2.5, 2.501)).IsEqual (new JSM.Coord2D (2.5003, 2.5001))); + test.Assert (sector2.ProjectCoord (new JSM.Coord2D (1.75, 2.26)).IsEqual (new JSM.Coord2D (1.753, 2.251))); + + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (4.0, 1.0)).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (3.001, 1.0)).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (0.0, 1.0)).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (0.999, 1.0)).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (1.0, 1.0)).IsEqual (new JSM.Coord2D (1.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (3.0, 1.0)).IsEqual (new JSM.Coord2D (3.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (1.1, 1.0)).IsEqual (new JSM.Coord2D (1.1, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (2.0, 0.0)).IsEqual (new JSM.Coord2D (2.0, 1.0))); + test.Assert (sector3.ProjectCoord (new JSM.Coord2D (1.123456789, 1.0)).IsEqual (new JSM.Coord2D (1.123456789, 1.0))); + + test.Assert (sector4.ProjectCoord (new JSM.Coord2D (0.0, 0.0)).IsEqual (new JSM.Coord2D (0.0, 1.0))); }); generalSuite.AddTest ('SectorSectorPositionTest', function (test) @@ -771,7 +771,7 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector1 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (0.0, 2.0), new JSM.Coord2D (1.0, 2.0)); - test.Assert (JSM.SectorSectorPosition2D (sector1, sector2) == 'SectorsDontIntersects'); + test.Assert (sector1.SectorPosition (sector2) == JSM.SectorSectorPosition2D.SectorsDontIntersect); var sector1 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (1.0, 2.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (4.0, 3.0)); @@ -779,50 +779,50 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var intersection = new JSM.Coord2D (0.0, 0.0); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 0.0, 1.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 1.0, 0.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == 'SectorsIntersectsEndPoint'); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == 'SectorsIntersectsEndPoint'); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 1.0, 3.0, 1.0)) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (3.0, 1.0, 1.0, 1.0)) == 'SectorsIntersectsCoincident'); - - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 0.0, 1.0, 1.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 0.0, 1.0, 2.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (3.0, 0.0, 3.0, 1.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (3.0, 0.0, 3.0, 2.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (2.0, 0.0, 4.0, 2.0)) == 'SectorsIntersectsEndPoint'); - - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (-1.0, 1.0, 0.0, 1.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (4.0, 1.0, 5.0, 1.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 0.0, 2.0, 0.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 0.0, 3.0, 0.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (1.0, 2.0, 3.0, 2.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 1.0, 1.0, 1.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (3.0, 1.0, 4.0, 1.0)) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (0.0, 1.0, 2.0, 1.0)) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (2.0, 1.0, 2.5, 1.0)) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (2.0, 1.0, 3.0, 1.0)) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (2.0, 1.0, 4.0, 1.0)) == 'SectorsIntersectsCoincident'); - - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (4.0, 1.0, 5.0, 1.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (sector3, GetSector2D (-1.0, 1.0, -3.0, 1.0)) == 'SectorsDontIntersects'); - - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (-1.0, 1.0, 0.0, 1.0), sector3) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (4.0, 1.0, 5.0, 1.0), sector3) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (0.0, 0.0, 2.0, 0.0), sector3) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (1.0, 0.0, 3.0, 0.0), sector3) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (1.0, 2.0, 3.0, 2.0), sector3) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (0.0, 1.0, 1.0, 1.0), sector3) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (3.0, 1.0, 4.0, 1.0), sector3) == 'SectorsIntersectsEndPoint'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (0.0, 1.0, 2.0, 1.0), sector3) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (2.0, 1.0, 2.5, 1.0), sector3) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (2.0, 1.0, 3.0, 1.0), sector3) == 'SectorsIntersectsCoincident'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (2.0, 1.0, 4.0, 1.0), sector3) == 'SectorsIntersectsCoincident'); - - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (0.0, 0.0, 1.0, 1.0), GetSector2D (3.0, 0.0, 3.0, 3.0)) == 'SectorsDontIntersects'); - test.Assert (JSM.SectorSectorPosition2D (GetSector2D (3.0, 0.0, 3.0, 3.0), GetSector2D (0.0, 0.0, 1.0, 1.0)) == 'SectorsDontIntersects'); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 0.0, 4.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + + test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 2.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 3.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 2.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 2.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 2.5, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, -3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + + test.Assert (GetSector2D (-1.0, 1.0, 0.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (4.0, 1.0, 5.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 0.0, 2.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 0.0, 3.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 2.0, 3.0, 2.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 1.0, 1.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (3.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (0.0, 1.0, 2.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 2.5, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 3.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.Assert (GetSector2D (0.0, 0.0, 1.0, 1.0).SectorPosition (GetSector2D (3.0, 0.0, 3.0, 3.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (3.0, 0.0, 3.0, 3.0).SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); }); generalSuite.AddTest ('BoxTest', function (test) @@ -888,10 +888,10 @@ generalSuite.AddTest ('PlaneTest', function (test) plane3 = plane3b; } - test.Assert (JSM.CoordPlanePosition (coord1, plane1) == 'CoordOnPlane'); - test.Assert (JSM.CoordPlanePosition (coord1, plane2) == 'CoordOnPlane'); - test.Assert (JSM.CoordPlanePosition (coord1b, plane3) == 'CoordInFrontOfPlane'); - test.Assert (JSM.CoordPlanePosition (coord1, plane3) == 'CoordAtBackOfPlane'); + test.Assert (plane1.CoordPosition (coord1) == JSM.CoordPlanePosition.CoordOnPlane); + test.Assert (plane2.CoordPosition (coord1) == JSM.CoordPlanePosition.CoordOnPlane); + test.Assert (plane3.CoordPosition (coord1b) == JSM.CoordPlanePosition.CoordInFrontOfPlane); + test.Assert (plane3.CoordPosition (coord1) == JSM.CoordPlanePosition.CoordAtBackOfPlane); test.Assert (JSM.IsEqual (JSM.CoordPlaneSignedDirectionalDistance (coord1, new JSM.Coord (1.0, 0.0, 0.0), plane1), 0.0)); test.Assert (JSM.IsEqual (JSM.CoordPlaneSignedDirectionalDistance (coord1, new JSM.Coord (1.0, 0.0, 0.0), plane2), 0.0)); @@ -900,40 +900,40 @@ generalSuite.AddTest ('PlaneTest', function (test) test.Assert (JSM.IsEqual (JSM.CoordPlaneSignedDirectionalDistance (coord1b, new JSM.Coord (0.0, 1.0, 1.0), plane3), 1.4142135623)); test.Assert (JSM.IsEqual (JSM.CoordPlaneDirectionalDistance (coord1, new JSM.Coord (0.0, 1.0, 1.0), plane3), 1.4142135623)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord1, plane1), 0.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord1, plane2), 0.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord1, plane3), 1.0)); + test.Assert (JSM.IsEqual (plane1.CoordDistance (coord1), 0.0)); + test.Assert (JSM.IsEqual (plane2.CoordDistance (coord1), 0.0)); + test.Assert (JSM.IsEqual (plane3.CoordDistance (coord1), 1.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord2, plane1), 0.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord2, plane2), 1.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord2, plane3), 1.0)); + test.Assert (JSM.IsEqual (plane1.CoordDistance (coord2), 0.0)); + test.Assert (JSM.IsEqual (plane2.CoordDistance (coord2), 1.0)); + test.Assert (JSM.IsEqual (plane3.CoordDistance (coord2), 1.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord3, plane1), 1.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord3, plane2), 1.0)); - test.Assert (JSM.IsEqual (JSM.CoordPlaneDistance (coord3, plane3), 0.0)); + test.Assert (JSM.IsEqual (plane1.CoordDistance (coord3), 1.0)); + test.Assert (JSM.IsEqual (plane2.CoordDistance (coord3), 1.0)); + test.Assert (JSM.IsEqual (plane3.CoordDistance (coord3), 0.0)); - test.Assert (JSM.ProjectCoordToPlane (coord1, plane1).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.ProjectCoordToPlane (coord1, plane2).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.ProjectCoordToPlane (coord1, plane3).IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); + test.Assert (plane1.ProjectCoord (coord1).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (plane2.ProjectCoord (coord1).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (plane3.ProjectCoord (coord1).IsEqual (new JSM.Coord (0.0, 0.0, 1.0))); - test.Assert (JSM.ProjectCoordToPlane (coord2, plane1).IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); - test.Assert (JSM.ProjectCoordToPlane (coord2, plane2).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); - test.Assert (JSM.ProjectCoordToPlane (coord2, plane3).IsEqual (new JSM.Coord (1.0, 0.0, 1.0))); + test.Assert (plane1.ProjectCoord (coord2).IsEqual (new JSM.Coord (1.0, 0.0, 0.0))); + test.Assert (plane2.ProjectCoord (coord2).IsEqual (new JSM.Coord (0.0, 0.0, 0.0))); + test.Assert (plane3.ProjectCoord (coord2).IsEqual (new JSM.Coord (1.0, 0.0, 1.0))); - test.Assert (JSM.ProjectCoordToPlane (coord3, plane1).IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); - test.Assert (JSM.ProjectCoordToPlane (coord3, plane2).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); - test.Assert (JSM.ProjectCoordToPlane (coord3, plane3).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); + test.Assert (plane1.ProjectCoord (coord3).IsEqual (new JSM.Coord (1.0, 1.0, 0.0))); + test.Assert (plane2.ProjectCoord (coord3).IsEqual (new JSM.Coord (0.0, 1.0, 1.0))); + test.Assert (plane3.ProjectCoord (coord3).IsEqual (new JSM.Coord (1.0, 1.0, 1.0))); var line1 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (1.0, 0.0, 0.0)); var line2 = new JSM.Line (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Vector (0.0, 0.0, 1.0)); var line3 = new JSM.Line (new JSM.Coord (1.0, 2.0, 3.0), new JSM.Vector (0.0, 0.0, 1.0)); - test.Assert (JSM.LinePlanePosition (line1, plane1) == 'LineParallelToPlane'); - test.Assert (JSM.LinePlanePosition (line2, plane1) == 'LineIntersectsPlane'); + test.Assert (plane1.LinePosition (line1) == JSM.LinePlanePosition.LineParallelToPlane); + test.Assert (plane1.LinePosition (line2) == JSM.LinePlanePosition.LineIntersectsPlane); var intersection = new JSM.Coord (0.0, 0.0, 0.0); - test.Assert (JSM.LinePlanePosition (line3, plane1, intersection) == 'LineIntersectsPlane'); + test.Assert (plane1.LinePosition (line3, intersection) == JSM.LinePlanePosition.LineIntersectsPlane); test.Assert (intersection.IsEqual (new JSM.Coord (1.0, 2.0, 0.0))); - test.Assert (JSM.LinePlaneIntersection (line3, plane1).IsEqual (new JSM.Coord (1.0, 2.0, 0.0))); + test.Assert (plane1.LineIntersection (line3).IsEqual (new JSM.Coord (1.0, 2.0, 0.0))); } }); diff --git a/test/unittest/tests/visual.js b/test/unittest/tests/visual.js index 8f8c31c5..19e13175 100644 --- a/test/unittest/tests/visual.js +++ b/test/unittest/tests/visual.js @@ -160,4 +160,66 @@ visualSuite.AddTest ('BooleanOperationTest', function (test) test.Assert (DrawAndCheck (body, 'Wireframe', 'csg_intersection_03.svg')); }); +visualSuite.AddTest ('GeneratorFunctionTest', function (test) +{ + function Test (body, name) + { + return DrawAndCheck (body, 'Wireframe', 'generator_' + name + '.svg') + } + + var exampleFunc = function (x, y) + { + return x * x + y * y; + }; + + var polyLine = [ + new JSM.Coord (0, 0, 0), + new JSM.Coord (1, 0, 0), + new JSM.Coord (1, 1, 0) + ]; + + var polyLine2 = [ + new JSM.Coord (0.5, 0, 0), + new JSM.Coord (1, 0.5, 0), + new JSM.Coord (1, 1, 0) + ]; + + var polyLine2D = [ + new JSM.Coord2D (0, 0), + new JSM.Coord2D (1, 0), + new JSM.Coord2D (1, 1) + ]; + + var circlePoints1 = JSM.GenerateCirclePoints (1, 10); + var circlePoints2 = JSM.GenerateCirclePoints (0.5, 10, new JSM.Coord (0, 0, 0.5)); + var circlePoints3 = JSM.GenerateCirclePoints (0.2, 10, new JSM.Coord (0, 0, 1)); + + test.Assert (Test (JSM.GenerateCircle (1, 10), 'circle')); + test.Assert (Test (JSM.GenerateCone (0.5, 1, 1, 10, true, false), 'cone1')); + test.Assert (Test (JSM.GenerateCone (0, 1, 1, 10, true, false), 'cone2')); + test.Assert (Test (JSM.GenerateCuboid (1, 1, 1), 'cuboid')); + test.Assert (Test (JSM.GenerateCuboidSides (1, 1, 1, [1, 0, 0, 0, 0, 1]), 'cuboidsides')); + test.Assert (Test (JSM.GenerateCylinder (0.5, 1, 10, true, false), 'cylinder')); + test.Assert (Test (JSM.GenerateCylinderShell (0.5, 1, 0.1, 10, true, false), 'cylindershell')); + test.Assert (Test (JSM.GenerateFunctionSurface (exampleFunc, new JSM.Coord2D (-0.5, -0.5), new JSM.Coord2D (0.5, 0.5), 10, false), 'function')); + test.Assert (Test (JSM.GenerateFunctionSurfaceSolid (exampleFunc, new JSM.Coord2D (-0.5, -0.5), new JSM.Coord2D (0.5, 0.5), 10, false, 0.5), 'functionsolid')); + test.Assert (Test (JSM.GenerateGrid (1, 1, 10, 10, false), 'grid')); + test.Assert (Test (JSM.GenerateLineShell (polyLine, new JSM.Vector (0, 0, 1), 1, 0.1, true, true), 'lineshell')); + test.Assert (Test (JSM.GeneratePie (0.5, 0.2, Math.PI * 3 / 2, 10, true, false), 'pie')); + test.Assert (Test (JSM.GeneratePolyTorus (polyLine2D, 0.5, 10, false), 'polytorus')); + test.Assert (Test (JSM.GeneratePrism (polyLine, new JSM.Vector (0, 0, 1), 1, true), 'prism')); + test.Assert (Test (JSM.GeneratePrismShell (polyLine, new JSM.Vector (0, 0, 1), 1, 0.1, true), 'prismshell')); + test.Assert (Test (JSM.GenerateRectangle (1, 1), 'rectangle')); + test.Assert (Test (JSM.GenerateRevolved (polyLine2, new JSM.Sector (new JSM.Coord (0, 0, 0), new JSM.Coord (0, 1, 0)), Math.PI * 3 / 2, 10, true, 'None'), 'revolved1')); + test.Assert (Test (JSM.GenerateRevolved (polyLine2, new JSM.Sector (new JSM.Coord (0, 0, 0), new JSM.Coord (0, 1, 0)), 2 * Math.PI, 10, true, 'None'), 'revolved2')); + test.Assert (Test (JSM.GenerateRuledFromSectors (new JSM.Sector (new JSM.Coord (0, 0, 0), new JSM.Coord (1, 0, 0)), new JSM.Sector (new JSM.Coord (0, 1, 0), new JSM.Coord (0, 1, 1)), 10, 10, false), 'ruled')); + test.Assert (Test (JSM.GenerateSegmentedCuboid (1, 1, 1, 5), 'segmentedcuboid')); + test.Assert (Test (JSM.GenerateSegmentedRectangle (1, 1, 3, 5), 'segmentedrectangle')); + test.Assert (Test (JSM.GenerateSphere (0.5, 10, false), 'sphere')); + test.Assert (Test (JSM.GenerateSquareGrid (1, 5, false), 'squaregrid')); + test.Assert (Test (JSM.GenerateTorus (0.5, 0.2, 10, 10, false), 'torus')); + test.Assert (Test (JSM.GenerateTriangulatedSphere (0.5, 2, false), 'triangulatedsphere')); + test.Assert (Test (JSM.GenerateTube ([circlePoints1, circlePoints2, circlePoints3], true), 'tube')); +}); + } diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index 097340a5..43cf81b5 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 0394bb83..8eab81c1 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index f71aa8f0..2f23c80c 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index 216f6d84..59c073ed 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index a2f30e78..0997393c 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 5206916c..66e62917 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -23,16 +23,11 @@ - - - - - diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index d8487461..d7464344 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -23,16 +23,11 @@ - - - - - diff --git a/tools/files.txt b/tools/files.txt index 0d0df2e6..128a1cd9 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -11,16 +11,11 @@ ../src/geometry/matrix.js ../src/geometry/coordsystem.js ../src/geometry/sector.js -../src/geometry/sectorutils.js ../src/geometry/line.js -../src/geometry/lineutils.js ../src/geometry/box.js -../src/geometry/boxutils.js ../src/geometry/sphere.js ../src/geometry/transformation.js -../src/geometry/transformationutils.js ../src/geometry/plane.js -../src/geometry/planeutils.js ../src/geometry/projection.js ../src/geometry/convexhull.js ../src/geometry/polygon.js From 756007c107360f825365adcd4c0037d2f7866605 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 18 Jul 2015 08:27:00 +0200 Subject: [PATCH 10/27] Move JSPolygon's polygon class to here (currently exists the old one, too). --- build/jsmodeler.js | 185 +- documentation/jsmdoc/include/jsmdoc.json | 65 +- documentation/olddemo/include/tridemo.js | 2 +- sandbox/3dsdump.html | 6 +- sandbox/bezier.html | 6 +- sandbox/beziercurve.html | 6 +- sandbox/bspline.html | 6 +- sandbox/charts.html | 6 +- sandbox/convexhull.html | 6 +- sandbox/coplanar.html | 6 +- sandbox/csg.html | 6 +- sandbox/csg2.html | 6 +- sandbox/curvedprism.html | 6 +- sandbox/docimages.html | 6 +- sandbox/doublesided.html | 6 +- sandbox/githublogo.html | 6 +- sandbox/heightmap.html | 6 +- sandbox/hiddenline.html | 6 +- sandbox/importer.html | 6 +- sandbox/jsonimport.html | 6 +- sandbox/jsonimporttexture.html | 6 +- sandbox/minimal.html | 6 +- sandbox/minimal2.html | 6 +- sandbox/octree.html | 6 +- sandbox/pointcloud.html | 6 +- sandbox/pointcloudjson.html | 6 +- sandbox/print.html | 6 +- sandbox/prismwithhole.html | 6 +- sandbox/randommat.html | 6 +- sandbox/renderer.html | 6 +- sandbox/revolved.html | 6 +- sandbox/smartbuilder.html | 6 +- sandbox/smartbuilder2.html | 6 +- sandbox/solids.html | 6 +- sandbox/specular.html | 6 +- sandbox/svgonthefly.html | 6 +- sandbox/svgtomodel.html | 6 +- sandbox/svgtomodeltexture.html | 6 +- sandbox/tasks.html | 6 +- sandbox/texture.html | 6 +- sandbox/tictactoecanvas.html | 6 +- sandbox/triangulate.html | 6 +- sandbox/triangulatewithhole.html | 6 +- sandbox/tube.html | 6 +- sandbox/undermouse.html | 6 +- sandbox/viewer.html | 6 +- src/extras/drawing.js | 8 +- src/extras/svgtomodel.js | 2 +- src/geometry/coordutils.js | 14 - src/geometry/{polygon.js => oldpolygon.js} | 82 +- .../{polygonutils.js => oldpolygonutils.js} | 48 +- src/geometry/polygon2d.js | 533 +++++ src/geometry/sector.js | 139 +- src/geometry/triangulation.js | 248 +++ test/unittest/jsmodelertest.js | 8 +- test/unittest/tests/geometry.js | 294 ++- test/unittest/tests/polygon.js | 1274 ++++++++++++ test/unittest/tests/triangulation.js | 1758 +++++++++++++++++ test/viewertest/cameratest.html | 6 +- test/viewertest/csgtest.html | 6 +- test/viewertest/importtest.html | 6 +- test/viewertest/svgtomodeltest.html | 6 +- test/viewertest/texturetest.html | 6 +- test/viewertest/viewertest.html | 6 +- test/viewertest/viewertypes.html | 6 +- tools/files.txt | 6 +- 66 files changed, 4600 insertions(+), 366 deletions(-) rename src/geometry/{polygon.js => oldpolygon.js} (72%) rename src/geometry/{polygonutils.js => oldpolygonutils.js} (96%) create mode 100644 src/geometry/polygon2d.js create mode 100644 src/geometry/triangulation.js create mode 100644 test/unittest/tests/polygon.js create mode 100644 test/unittest/tests/triangulation.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index ca06f06e..3bf7dd13 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -16,20 +16,19 @@ JSM.Coord.prototype.Normalize=function(){var a=this.Length();JSM.IsPositive(a)&& JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,l=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*l;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*l;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*l;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this};JSM.Coord.prototype.ToString=function(){return"("+this.x+", "+this.y+", "+this.z+")"}; JSM.Coord.prototype.ToCoord2D=function(a){var b=new JSM.Coord(0,0,0),c=new JSM.Vector(0,0,1),d=JSM.VectorCross(a,c);a=a.AngleTo(c);b=this.Clone().Rotate(d,a,b);return new JSM.Coord2D(b.x,b.y)};JSM.Coord.prototype.Clone=function(){return new JSM.Coord(this.x,this.y,this.z)};JSM.Vector=JSM.Coord;JSM.CoordFromArray=function(a){return new JSM.Coord(a[0],a[1],a[2])};JSM.CoordToArray=function(a){return[a.x,a.y,a.z]};JSM.CoordAdd=function(a,b){return new JSM.Coord(a.x+b.x,a.y+b.y,a.z+b.z)}; JSM.CoordSub=function(a,b){return new JSM.Coord(a.x-b.x,a.y-b.y,a.z-b.z)};JSM.VectorDot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};JSM.VectorCross=function(a,b){var c=new JSM.Vector(0,0,0);c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};JSM.MatrixDeterminant2x2=function(a,b,c,d){return a*d-b*c}; -JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,l){var k=JSM.MatrixDeterminant2x2(e,f,g,l);f=JSM.MatrixDeterminant2x2(d,f,h,l);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*k-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,l,k,m,n,p,q,t,s){var u=JSM.MatrixDeterminant3x3(f,h,g,k,m,n,q,t,s),v=JSM.MatrixDeterminant3x3(e,h,g,l,m,n,p,t,s);g=JSM.MatrixDeterminant3x3(e,f,g,l,k,n,p,q,s);e=JSM.MatrixDeterminant3x3(e,f,h,l,k,m,p,q,t);return u*a-v*b+g*c-e*d}; -JSM.Orientation={Invalid:0,CounterClockwise:1,Clockwise:2};JSM.Complexity={Invalid:0,Convex:1,Concave:2};JSM.MidCoord2D=function(a,b){return new JSM.Coord2D((a.x+b.x)/2,(a.y+b.y)/2)};JSM.CoordOrientation2D=function(a,b,c){var d=a.x;a=a.y;var e=b.x;b=b.y;var f=c.x;c=c.y;d=d*b+a*f+e*c-b*f-a*e-d*c;return JSM.IsPositive(d)?JSM.Orientation.CounterClockwise:JSM.IsNegative(d)?JSM.Orientation.Clockwise:JSM.Orientation.Invalid}; -JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c};JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a};JSM.MidCoord=function(a,b){return new JSM.Coord((a.x+b.x)/2,(a.y+b.y)/2,(a.z+b.z)/2)};JSM.CoordSignedDistance=function(a,b,c){var d=JSM.CoordSub(b,a);a=a.DistanceTo(b);c=d.AngleTo(c);JSM.IsPositive(c)&&(a=-a);return a}; -JSM.GetVectorsFullAngle=function(a,b,c){var d=a.AngleTo(b),e=new JSM.Coord(0,0,0);JSM.CoordOrientation(a,e,b,c)==JSM.Orientation.Clockwise&&(d=2*Math.PI-d);return d};JSM.CoordOrientation=function(a,b,c,d){a=a.ToCoord2D(d);b=b.ToCoord2D(d);c=c.ToCoord2D(d);c=JSM.CoordOrientation2D(a,b,c);a=new JSM.Vector(0,0,1);d=d.AngleTo(a);JSM.IsEqual(d,Math.PI)&&(c==JSM.Orientation.CounterClockwise?c=JSM.Orientation.Clockwise:c==JSM.Orientation.Clockwise&&(c=JSM.Orientation.CounterClockwise));return c}; -JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d};JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return a.AngleTo(b)*c};JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c}; -JSM.CalculateCentroid=function(a){var b=a.length,c=new JSM.Coord(0,0,0);if(1<=b){var d;for(d=0;da?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],u=a[14],v=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*s;r[2]=c*g+d*m+e*q+f*u;r[3]=c*l+d*n+e*t+f*v;return r}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],u=a[14],v=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*r+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=t*r+s*x+u*L+v*N;F[13]=t*w+s*A+u*H+v*O;F[14]=t*y+s*B+u*C+v*J;F[15]=t*z+s*K+u*E+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*h-c*f)*(n*a-p*s)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*s-n*q)+(d*l-e*g)*(k*t-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,r=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*t-m*q,A=k*s-n*q,B=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,C=u*H-v*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(t*z-s*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(s*r-q*z-a*v)/C;E[7]=(k*z-n*r+p* -v)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-t*r+a*u)/C;E[11]=(m*r-k*y-p*u)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(t*v-q*w-s*u)/C;E[15]=(k*w-m*v+n*u)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],s=a[11],t=a[13],v=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*t;r[2]=c*g+d*m+e*q+f*v;r[3]=c*l+d*n+e*s+f*u;return r}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],s=a[12],t=a[13],v=a[14],u=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*r+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ +p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=s*r+t*x+v*L+u*N;F[13]=s*w+t*A+v*H+u*O;F[14]=s*y+t*B+v*C+u*J;F[15]=s*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];return(b*h-c*f)*(n*a-p*t)-(b*g-d*f)*(m*a-p*s)+(b*l-e*f)*(m*t-n*s)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*t-n*q)+(d*l-e*g)*(k*s-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];var v=b*h-c*f,u=b*g-d*f,r=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*s-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*s,L=m*a-p*s,H=n*a-p*t,C=v*H-u*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(s*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*r-q*z-a*u)/C;E[7]=(k*z-n*r+p* +u)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-s*r+a*v)/C;E[11]=(m*r-k*y-p*v)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(s*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; @@ -37,14 +36,17 @@ JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.ToDirectionVectors=function(){this.e1=JSM.CoordSub(this.e1,this.origo);this.e2=JSM.CoordSub(this.e2,this.origo);this.e3=JSM.CoordSub(this.e3,this.origo);return this};JSM.CoordSystem.prototype.ToAbsoluteCoords=function(){this.e1=JSM.CoordAdd(this.e1,this.origo);this.e2=JSM.CoordAdd(this.e2,this.origo);this.e3=JSM.CoordAdd(this.e3,this.origo);return this}; -JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2}; -JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; +JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.OldSectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3}; +JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; -JSM.Sector2D.prototype.SectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| -f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.SectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? -(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint):JSM.SectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.SectorSectorPosition2D.SectorsDontIntersect;m/=h;n/=h;if(JSM.IsLower(m, -0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.SectorSectorPosition2D.SectorsIntersectEndPoint:JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| +f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? +(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=h;n/= +h;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, +q=f.y,s=h.x,t=h.y,v=g.x,u=g.y,r=(v-s)*(n-t)-(u-t)*(m-s),w=(p-m)*(n-t)-(q-n)*(m-s),s=(u-t)*(p-m)-(v-s)*(q-n);if(JSM.IsZero(s)){if(JSM.IsZero(r)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=r/s;w/=s;if(JSM.IsLower(h, +0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: @@ -76,30 +78,55 @@ JSM.ConvexHull3D=function(a){function b(){this.position=null}function c(){this.t a.tri1!=b&&a.tri2!=b&&(-1==a.tri1?a.tri1=b:-1==a.tri2&&(a.tri2=b));return f}function h(a,b,c,e){var g=a.triangles.length,h=f(a,g,b,c),k=f(a,g,c,e),g=f(a,g,e,b),l=new d;l.vertices=[b,c,e];l.edges=[h,k,g];l.valid=!0;a.triangles.push(l);return a.triangles.length-1}function g(a,b,c){a=a.edges[c];a.tri1==b?a.tri1=-1:a.tri2==b&&(a.tri2=-1)}function l(a,b,c,d,e){c=a.vertices[c].position;d=a.vertices[d].position;e=a.vertices[e].position;a=JSM.CoordSub(a.vertices[b].position,e);b=JSM.CoordSub(c,e);c=JSM.CoordSub(d, e);return JSM.VectorDot(a,JSM.VectorCross(b,c))/6}function k(a,b){var c=[],d,e;for(d=0;dn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qf)return e;var h,g,l,k,m;for(h=0;ha)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;c=c+this.contours[b].VertexCount();)c+=this.contours[b].VertexCount(),b+=1;return this.GetContourVertex(b,a-c)};JSM.ContourPolygon2D.prototype.VertexCount=function(){var a=0,b;for(b=0;bg))if(3==g)f.push(h.map);else{g=c(h.polygon);if(null===g)return null;void 0!==b&&null!==b&&b(h.polygon,g);h=d(h,g);e.push(h.resultData1);e.push(h.resultData2)}return f};JSM.TriangulateSimpleConcavePolygon=function(a){return JSM.TriangulateSimpleConcavePolygonDiagonal(a)}; +JSM.TriangulateSimplePolygon=function(a){if(null===a)return null;var b=a.VertexCount();return 3>b?null:3==b?[[0,1,2]]:a.GetComplexity()==JSM.Complexity.Convex?JSM.TriangulateSimpleConvexPolygon(a):JSM.TriangulateSimpleConcavePolygon(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; +JSM.OldPolygon2D.prototype.SetVertex=function(a,b,c){this.vertices[a].Set(b,c)};JSM.OldPolygon2D.prototype.VertexCount=function(){return this.vertices.length};JSM.OldPolygon2D.prototype.Clear=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.Clone=function(){var a=new JSM.OldPolygon2D,b;for(b=0;b=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& (g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var h=[],g,l,k;for(g=0;gb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;ck;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== @@ -162,19 +189,19 @@ JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b) JSM.CalculatePolygonCylindricalTextureCoords=function(a,b,c){var d=[],e=[],f=a.GetPolygon(b),h=a.GetTextureProjectionCoords(),g;for(b=0;be;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),u.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(u)}}var f=new JSM.Body;(function(){var d; +JSM.GeneratePrismWithHole=function(a,b,c,d){function e(){var b=0,c=[],d;for(d=0;de;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),v.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(v)}}var f=new JSM.Body;(function(){var d; for(d=0;dw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bf.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; @@ -270,14 +297,14 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,t,s,u,v,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;u=41728;v=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ -255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ +JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,s,t,v,u,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;s=19;t=41472;v=41728;u=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==s?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ ", "+d+")",3),n.ambient=V(a,b,p)):b==h?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= -W(a,b,p)):b==s?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else D("Skip chunk ("+c.toString(16)+", "+d+")",4), a.Skip(d-6)})}function ca(a,b,c){D("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?D("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?D("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):D("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){D("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==B?ca(a,b,c):(D("Skip chunk ("+ b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), -parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],s;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== +parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],s=[],t;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; @@ -393,11 +420,11 @@ JSM.GenerateTruncatedIcosidodecahedron=function(){var a=new JSM.Body,b=(1+Math.s [18,22,46,70,66,42]);JSM.AddPolygonToBody(a,[20,44,68,71,47,23]);JSM.AddPolygonToBody(a,[72,112,88,104,80,96]);JSM.AddPolygonToBody(a,[73,97,83,107,90,114]);JSM.AddPolygonToBody(a,[74,98,81,105,91,115]);JSM.AddPolygonToBody(a,[75,99,82,106,89,113]);JSM.AddPolygonToBody(a,[76,118,94,109,85,100]);JSM.AddPolygonToBody(a,[78,117,93,108,84,102]);JSM.AddPolygonToBody(a,[79,103,87,111,95,119]);JSM.AddPolygonToBody(a,[86,101,77,116,92,110]);JSM.AddPolygonToBody(a,[0,2,26,74,115,67,64,112,72,24]);JSM.AddPolygonToBody(a, [1,25,73,114,66,70,118,76,28,4]);JSM.AddPolygonToBody(a,[3,27,75,113,65,69,117,78,30,6]);JSM.AddPolygonToBody(a,[5,7,31,79,119,71,68,116,77,29]);JSM.AddPolygonToBody(a,[8,10,34,82,99,51,48,96,80,32]);JSM.AddPolygonToBody(a,[9,33,81,98,50,54,102,84,36,12]);JSM.AddPolygonToBody(a,[11,35,83,97,49,53,101,86,38,14]);JSM.AddPolygonToBody(a,[13,15,39,87,103,55,52,100,85,37]);JSM.AddPolygonToBody(a,[16,18,42,90,107,59,56,104,88,40]);JSM.AddPolygonToBody(a,[17,41,89,106,58,62,110,92,44,20]);JSM.AddPolygonToBody(a, [19,43,91,105,57,61,109,94,46,22]);JSM.AddPolygonToBody(a,[21,23,47,95,111,63,60,108,93,45]);return a}; -JSM.GenerateSnubDodecahedron=function(){var a=new JSM.Body,b=(1+Math.sqrt(5))/2,c=Math.pow(b/2+0.5*Math.sqrt(b-5/27),1/3)+Math.pow(b/2-0.5*Math.sqrt(b-5/27),1/3),d=c-1/c,e=c*b+Math.pow(b,2)+b/c,c=2*d,f=2*e,h=d+e/b+b,g=-(d*b)+e+1/b,l=d/b+e*b-1,k=-(d/b)+e*b+1,m=-d+e/b-b,n=d*b+e-1/b,p=-(d/b)+e*b-1,q=d-e/b-b,t=d*b+e+1/b,s=d+e/b-b,u=d*b-e+1/b,b=d/b+e*b+1;JSM.AddVertexToBody(a,+c,2,-f);JSM.AddVertexToBody(a,+c,-2,+f);JSM.AddVertexToBody(a,-c,2,+f);JSM.AddVertexToBody(a,-c,-2,-f);JSM.AddVertexToBody(a,2, +JSM.GenerateSnubDodecahedron=function(){var a=new JSM.Body,b=(1+Math.sqrt(5))/2,c=Math.pow(b/2+0.5*Math.sqrt(b-5/27),1/3)+Math.pow(b/2-0.5*Math.sqrt(b-5/27),1/3),d=c-1/c,e=c*b+Math.pow(b,2)+b/c,c=2*d,f=2*e,h=d+e/b+b,g=-(d*b)+e+1/b,l=d/b+e*b-1,k=-(d/b)+e*b+1,m=-d+e/b-b,n=d*b+e-1/b,p=-(d/b)+e*b-1,q=d-e/b-b,s=d*b+e+1/b,t=d+e/b-b,v=d*b-e+1/b,b=d/b+e*b+1;JSM.AddVertexToBody(a,+c,2,-f);JSM.AddVertexToBody(a,+c,-2,+f);JSM.AddVertexToBody(a,-c,2,+f);JSM.AddVertexToBody(a,-c,-2,-f);JSM.AddVertexToBody(a,2, -f,+c);JSM.AddVertexToBody(a,-2,+f,+c);JSM.AddVertexToBody(a,2,+f,-c);JSM.AddVertexToBody(a,-2,-f,-c);JSM.AddVertexToBody(a,-f,+c,2);JSM.AddVertexToBody(a,+f,+c,-2);JSM.AddVertexToBody(a,+f,-c,2);JSM.AddVertexToBody(a,-f,-c,-2);JSM.AddVertexToBody(a,+h,+g,-l);JSM.AddVertexToBody(a,+h,-g,+l);JSM.AddVertexToBody(a,-h,+g,+l);JSM.AddVertexToBody(a,-h,-g,-l);JSM.AddVertexToBody(a,+g,-l,+h);JSM.AddVertexToBody(a,-g,+l,+h);JSM.AddVertexToBody(a,+g,+l,-h);JSM.AddVertexToBody(a,-g,-l,-h);JSM.AddVertexToBody(a, -l,+h,+g);JSM.AddVertexToBody(a,+l,+h,-g);JSM.AddVertexToBody(a,+l,-h,+g);JSM.AddVertexToBody(a,-l,-h,-g);JSM.AddVertexToBody(a,+k,+m,-n);JSM.AddVertexToBody(a,+k,-m,+n);JSM.AddVertexToBody(a,-k,+m,+n);JSM.AddVertexToBody(a,-k,-m,-n);JSM.AddVertexToBody(a,+m,-n,+k);JSM.AddVertexToBody(a,-m,+n,+k);JSM.AddVertexToBody(a,+m,+n,-k);JSM.AddVertexToBody(a,-m,-n,-k);JSM.AddVertexToBody(a,-n,+k,+m);JSM.AddVertexToBody(a,+n,+k,-m);JSM.AddVertexToBody(a,+n,-k,+m);JSM.AddVertexToBody(a,-n,-k,-m);JSM.AddVertexToBody(a, -+p,+q,-t);JSM.AddVertexToBody(a,+p,-q,+t);JSM.AddVertexToBody(a,-p,+q,+t);JSM.AddVertexToBody(a,-p,-q,-t);JSM.AddVertexToBody(a,+q,-t,+p);JSM.AddVertexToBody(a,-q,+t,+p);JSM.AddVertexToBody(a,+q,+t,-p);JSM.AddVertexToBody(a,-q,-t,-p);JSM.AddVertexToBody(a,-t,+p,+q);JSM.AddVertexToBody(a,+t,+p,-q);JSM.AddVertexToBody(a,+t,-p,+q);JSM.AddVertexToBody(a,-t,-p,-q);JSM.AddVertexToBody(a,+s,+u,-b);JSM.AddVertexToBody(a,+s,-u,+b);JSM.AddVertexToBody(a,-s,+u,+b);JSM.AddVertexToBody(a,-s,-u,-b);JSM.AddVertexToBody(a, -+u,-b,+s);JSM.AddVertexToBody(a,-u,+b,+s);JSM.AddVertexToBody(a,+u,+b,-s);JSM.AddVertexToBody(a,-u,-b,-s);JSM.AddVertexToBody(a,-b,+s,+u);JSM.AddVertexToBody(a,+b,+s,-u);JSM.AddVertexToBody(a,+b,-s,+u);JSM.AddVertexToBody(a,-b,-s,-u);JSM.AddPolygonToBody(a,[0,3,51]);JSM.AddPolygonToBody(a,[0,30,12]);JSM.AddPolygonToBody(a,[0,48,3]);JSM.AddPolygonToBody(a,[0,51,30]);JSM.AddPolygonToBody(a,[1,2,50]);JSM.AddPolygonToBody(a,[1,28,13]);JSM.AddPolygonToBody(a,[1,49,2]);JSM.AddPolygonToBody(a,[1,50,28]); ++p,+q,-s);JSM.AddVertexToBody(a,+p,-q,+s);JSM.AddVertexToBody(a,-p,+q,+s);JSM.AddVertexToBody(a,-p,-q,-s);JSM.AddVertexToBody(a,+q,-s,+p);JSM.AddVertexToBody(a,-q,+s,+p);JSM.AddVertexToBody(a,+q,+s,-p);JSM.AddVertexToBody(a,-q,-s,-p);JSM.AddVertexToBody(a,-s,+p,+q);JSM.AddVertexToBody(a,+s,+p,-q);JSM.AddVertexToBody(a,+s,-p,+q);JSM.AddVertexToBody(a,-s,-p,-q);JSM.AddVertexToBody(a,+t,+v,-b);JSM.AddVertexToBody(a,+t,-v,+b);JSM.AddVertexToBody(a,-t,+v,+b);JSM.AddVertexToBody(a,-t,-v,-b);JSM.AddVertexToBody(a, ++v,-b,+t);JSM.AddVertexToBody(a,-v,+b,+t);JSM.AddVertexToBody(a,+v,+b,-t);JSM.AddVertexToBody(a,-v,-b,-t);JSM.AddVertexToBody(a,-b,+t,+v);JSM.AddVertexToBody(a,+b,+t,-v);JSM.AddVertexToBody(a,+b,-t,+v);JSM.AddVertexToBody(a,-b,-t,-v);JSM.AddPolygonToBody(a,[0,3,51]);JSM.AddPolygonToBody(a,[0,30,12]);JSM.AddPolygonToBody(a,[0,48,3]);JSM.AddPolygonToBody(a,[0,51,30]);JSM.AddPolygonToBody(a,[1,2,50]);JSM.AddPolygonToBody(a,[1,28,13]);JSM.AddPolygonToBody(a,[1,49,2]);JSM.AddPolygonToBody(a,[1,50,28]); JSM.AddPolygonToBody(a,[2,29,14]);JSM.AddPolygonToBody(a,[2,49,29]);JSM.AddPolygonToBody(a,[3,31,15]);JSM.AddPolygonToBody(a,[3,48,31]);JSM.AddPolygonToBody(a,[4,7,55]);JSM.AddPolygonToBody(a,[4,34,16]);JSM.AddPolygonToBody(a,[4,52,7]);JSM.AddPolygonToBody(a,[4,55,34]);JSM.AddPolygonToBody(a,[5,6,54]);JSM.AddPolygonToBody(a,[5,32,17]);JSM.AddPolygonToBody(a,[5,53,6]);JSM.AddPolygonToBody(a,[5,54,32]);JSM.AddPolygonToBody(a,[6,33,18]);JSM.AddPolygonToBody(a,[6,53,33]);JSM.AddPolygonToBody(a,[7,35, 19]);JSM.AddPolygonToBody(a,[7,52,35]);JSM.AddPolygonToBody(a,[8,11,59]);JSM.AddPolygonToBody(a,[8,26,20]);JSM.AddPolygonToBody(a,[8,56,11]);JSM.AddPolygonToBody(a,[8,59,26]);JSM.AddPolygonToBody(a,[9,10,58]);JSM.AddPolygonToBody(a,[9,24,21]);JSM.AddPolygonToBody(a,[9,57,10]);JSM.AddPolygonToBody(a,[9,58,24]);JSM.AddPolygonToBody(a,[10,25,22]);JSM.AddPolygonToBody(a,[10,57,25]);JSM.AddPolygonToBody(a,[11,27,23]);JSM.AddPolygonToBody(a,[11,56,27]);JSM.AddPolygonToBody(a,[12,18,21]);JSM.AddPolygonToBody(a, [12,21,24]);JSM.AddPolygonToBody(a,[12,30,18]);JSM.AddPolygonToBody(a,[13,16,22]);JSM.AddPolygonToBody(a,[13,22,25]);JSM.AddPolygonToBody(a,[13,28,16]);JSM.AddPolygonToBody(a,[14,17,20]);JSM.AddPolygonToBody(a,[14,20,26]);JSM.AddPolygonToBody(a,[14,29,17]);JSM.AddPolygonToBody(a,[15,19,23]);JSM.AddPolygonToBody(a,[15,23,27]);JSM.AddPolygonToBody(a,[15,31,19]);JSM.AddPolygonToBody(a,[16,34,22]);JSM.AddPolygonToBody(a,[17,32,20]);JSM.AddPolygonToBody(a,[18,33,21]);JSM.AddPolygonToBody(a,[19,35,23]); @@ -419,12 +446,12 @@ JSM.GenerateCumulatedIcosahedron=function(a){var b=new JSM.Body,c=(1+Math.sqrt(5 JSM.GeneratePentakisDodecahedron=function(){var a=Math.sqrt((65+22*Math.sqrt(5))/5)/19;return JSM.GenerateCumulatedDodecahedron(a)};JSM.GenerateSmallStellatedDodecahedron=function(){var a=Math.sqrt((5+2*Math.sqrt(5))/5);return JSM.GenerateCumulatedDodecahedron(a)};JSM.GenerateGreatDodecahedron=function(){var a=Math.sqrt(3)*(Math.sqrt(5)-3)/6;return JSM.GenerateCumulatedIcosahedron(a)};JSM.GenerateSmallTriambicIcosahedron=function(){var a=Math.sqrt(15)/15;return JSM.GenerateCumulatedIcosahedron(a)}; JSM.GenerateGreatStellatedDodecahedron=function(){var a=Math.sqrt(3)*(3+Math.sqrt(5))/6;return JSM.GenerateCumulatedIcosahedron(a)};JSM.GenerateSmallTriakisOctahedron=function(){var a=Math.sqrt(3)-2*Math.sqrt(6)/3;return JSM.GenerateCumulatedOctahedron(a)};JSM.GenerateStellaOctangula=function(){var a=Math.sqrt(6)/3;return JSM.GenerateCumulatedOctahedron(a)};JSM.GenerateTriakisTetrahedron=function(){var a=Math.sqrt(6)/15;return JSM.GenerateCumulatedTetrahedron(a)}; JSM.LegoDimensions=function(){this.legoWidth=0.78;this.legoSmallHeight=0.32;this.legoLargeHeight=0.96;this.legoWallWidth=0.16;this.legoCylinderWidth=0.5;this.legoCylinderHeight=0.17;this.legoBottomSmallCylinderWidth=0.3;this.legoBottomLargeCylinderWidth=0.6;this.legoBottomLargeCylinderWallWidth=0.1}; -JSM.GenerateLegoBrick=function(a,b,c,d,e,f,h){function g(a,b){var c,d;for(c=0;cr;r++)v[r].z=n-c;r=JSM.GeneratePrism(v,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rr;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0g&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0 - - + + + + diff --git a/sandbox/bezier.html b/sandbox/bezier.html index 916957c1..cf752609 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index 95f1896a..ca24cc45 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/bspline.html b/sandbox/bspline.html index fcc066d2..6f73275d 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/charts.html b/sandbox/charts.html index 8c028135..59458150 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index d7d99b85..c4eef96d 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 3e19fc28..9b848705 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/csg.html b/sandbox/csg.html index d17d048e..34a3cc72 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/csg2.html b/sandbox/csg2.html index d9260bde..4742ae25 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index 8cbbbe9d..159ce967 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/docimages.html b/sandbox/docimages.html index d09889af..7cf03fc4 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index b97c61d1..db471198 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index c1727c3a..b66c9ebf 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index 73f6298a..86065ac3 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index b7f3e0de..82cd8fe0 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/importer.html b/sandbox/importer.html index 88d1187a..e078db15 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index 21734a9e..97e04de8 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index c00ab9d3..5206bec5 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/minimal.html b/sandbox/minimal.html index ed76d204..afb86484 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index b0ccb83c..ca5442af 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/octree.html b/sandbox/octree.html index 485dc951..9ca2e54c 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 834234cc..f98bbe41 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index 88b6819e..42ab93dc 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/print.html b/sandbox/print.html index 610a065a..8bf362cf 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index 399db324..f24f4f46 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/randommat.html b/sandbox/randommat.html index 16ea4040..69f64f00 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/renderer.html b/sandbox/renderer.html index a35574cc..250cedc7 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/revolved.html b/sandbox/revolved.html index 1644ed3d..73d80cf2 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index efab5cbd..a8c120fa 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index 926f1cb2..37039343 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/solids.html b/sandbox/solids.html index 44bbfd28..8139af55 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/specular.html b/sandbox/specular.html index 5d18c97f..083052dc 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index ac74c2be..c1f5bfa0 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index 8cca080d..2277075b 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 039c71af..6c0b13fb 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/tasks.html b/sandbox/tasks.html index 93bd1bc8..a4f6bdfa 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/texture.html b/sandbox/texture.html index b0916791..e907a037 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index c2d6f404..945b471f 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -27,8 +27,10 @@ - - + + + + diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index 7ea5e625..831e026c 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/triangulatewithhole.html b/sandbox/triangulatewithhole.html index 3f11ab06..a1a41aa8 100644 --- a/sandbox/triangulatewithhole.html +++ b/sandbox/triangulatewithhole.html @@ -29,8 +29,10 @@ - - + + + + diff --git a/sandbox/tube.html b/sandbox/tube.html index fa1d7645..d846328b 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index bf39f25c..206e983d 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 08fedea0..0f091ae0 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -28,8 +28,10 @@ - - + + + + diff --git a/src/extras/drawing.js b/src/extras/drawing.js index 9850f86f..914c4954 100644 --- a/src/extras/drawing.js +++ b/src/extras/drawing.js @@ -62,7 +62,7 @@ JSM.CanvasDrawer.prototype.DrawLine = function (from, to) * Function: CanvasDrawer.DrawPolygon * Description: Draws a polygon to the target. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * color {string} the hex color string * contour {boolean} need to draw contour */ @@ -168,7 +168,7 @@ JSM.SVGDrawer.prototype.DrawLine = function (from, to) * Function: SVGDrawer.DrawPolygon * Description: Draws a polygon to the target. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * color {string} the hex color string * contour {boolean} need to draw contour */ @@ -222,7 +222,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, function GetProjectedPolygonFromBody (polygon) { - var projectedPolygon = new JSM.Polygon2D (); + var projectedPolygon = new JSM.OldPolygon2D (); var i, coord; for (i = 0; i < polygon.VertexIndexCount (); i++) { coord = body.GetVertexPosition (polygon.GetVertexIndex (i)); @@ -233,7 +233,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, function GetProjectedPolygonFromPolygon (polygon) { - var projectedPolygon = new JSM.Polygon2D (); + var projectedPolygon = new JSM.OldPolygon2D (); var i, coord; for (i = 0; i < polygon.VertexCount (); i++) { coord = polygon.GetVertex (i); diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index 76f56d07..f6ec91ea 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -181,7 +181,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) return result; } - var result = new JSM.ContourPolygon2D (); + var result = new JSM.OldContourPolygon2D (); var dummySVG = document.createElementNS ('http://www.w3.org/2000/svg', 'svg'); diff --git a/src/geometry/coordutils.js b/src/geometry/coordutils.js index e5ce1f2f..147eaaba 100644 --- a/src/geometry/coordutils.js +++ b/src/geometry/coordutils.js @@ -12,20 +12,6 @@ JSM.Orientation = { Clockwise : 2 }; -/** -* Enum: Complexity -* Description: Complexity of polygon. -* Values: -* {Invalid} invalid polygon -* {Convex} convex polygon -* {Concave} concave polygon -*/ -JSM.Complexity = { - Invalid : 0, - Convex : 1, - Concave : 2 -}; - /** * Function: MidCoord2D * Description: Calculates the coordinate in the middle of two coordinates. diff --git a/src/geometry/polygon.js b/src/geometry/oldpolygon.js similarity index 72% rename from src/geometry/polygon.js rename to src/geometry/oldpolygon.js index 9e1032a4..9f1dce2c 100644 --- a/src/geometry/polygon.js +++ b/src/geometry/oldpolygon.js @@ -1,79 +1,79 @@ /** -* Class: Polygon2D +* Class: OldPolygon2D * Description: Represents a 2D polygon. */ -JSM.Polygon2D = function () +JSM.OldPolygon2D = function () { this.vertices = []; }; /** -* Function: Polygon2D.AddVertex +* Function: OldPolygon2D.AddVertex * Description: Adds a vertex to the polygon. * Parameters: * x {number} the x coordinate of the vertex * y {number} the y coordinate of the vertex */ -JSM.Polygon2D.prototype.AddVertex = function (x, y) +JSM.OldPolygon2D.prototype.AddVertex = function (x, y) { this.vertices.push (new JSM.Coord2D (x, y)); }; /** -* Function: Polygon2D.GetVertex +* Function: OldPolygon2D.GetVertex * Description: Returns the vertex with the given index. * Parameters: * index {integer} the index of the vertex * Returns: * {Coord2D} the vertex */ -JSM.Polygon2D.prototype.GetVertex = function (index) +JSM.OldPolygon2D.prototype.GetVertex = function (index) { return this.vertices[index]; }; /** -* Function: Polygon2D.SetVertex +* Function: OldPolygon2D.SetVertex * Description: Modifies the coordinates of an existing vertex. * Parameters: * index {integer} the index of the vertex * x {number} the x coordinate of the vertex * y {number} the y coordinate of the vertex */ -JSM.Polygon2D.prototype.SetVertex = function (index, x, y) +JSM.OldPolygon2D.prototype.SetVertex = function (index, x, y) { this.vertices[index].Set (x, y); }; /** -* Function: Polygon2D.VertexCount +* Function: OldPolygon2D.VertexCount * Description: Returns the vertex count of the polygon. * Returns: * {integer} vertex count */ -JSM.Polygon2D.prototype.VertexCount = function () +JSM.OldPolygon2D.prototype.VertexCount = function () { return this.vertices.length; }; /** -* Function: Polygon2D.Clear +* Function: OldPolygon2D.Clear * Description: Makes the polygon empty. */ -JSM.Polygon2D.prototype.Clear = function () +JSM.OldPolygon2D.prototype.Clear = function () { this.vertices = []; }; /** -* Function: Polygon2D.Clone +* Function: OldPolygon2D.Clone * Description: Clones the polygon. * Returns: -* {Polygon2D} a cloned instance +* {OldPolygon2D} a cloned instance */ -JSM.Polygon2D.prototype.Clone = function () +JSM.OldPolygon2D.prototype.Clone = function () { - var result = new JSM.Polygon2D (); + var result = new JSM.OldPolygon2D (); var i; for (i = 0; i < this.vertices.length; i++) { result.vertices.push (this.vertices[i].Clone ()); @@ -82,39 +82,39 @@ JSM.Polygon2D.prototype.Clone = function () }; /** -* Class: ContourPolygon2D +* Class: OldContourPolygon2D * Description: Represents a 2D polygon with more contours. */ -JSM.ContourPolygon2D = function () +JSM.OldContourPolygon2D = function () { this.polygons = []; }; /** -* Function: ContourPolygon2D.AddVertex +* Function: OldContourPolygon2D.AddVertex * Description: Adds a vertex to a contour of the polygon. * Parameters: * contour {integer} the index of the contour * x {number} the x coordinate of the vertex * y {number} the y coordinate of the vertex */ -JSM.ContourPolygon2D.prototype.AddVertex = function (contour, x, y) +JSM.OldContourPolygon2D.prototype.AddVertex = function (contour, x, y) { if (this.polygons[contour] === undefined) { - this.polygons[contour] = new JSM.Polygon2D (); + this.polygons[contour] = new JSM.OldPolygon2D (); } this.polygons[contour].AddVertex (x, y); }; /** -* Function: ContourPolygon2D.VertexCount +* Function: OldContourPolygon2D.VertexCount * Description: Returns the vertex count of a contour of the polygon. * Parameters: * contour {integer} the index of the contour * Returns: * {integer} vertex count */ -JSM.ContourPolygon2D.prototype.VertexCount = function (contour) +JSM.OldContourPolygon2D.prototype.VertexCount = function (contour) { if (this.polygons[contour] === undefined) { return 0; @@ -123,7 +123,7 @@ JSM.ContourPolygon2D.prototype.VertexCount = function (contour) }; /** -* Function: ContourPolygon2D.GetVertex +* Function: OldContourPolygon2D.GetVertex * Description: Returns the vertex of a contour with the given index. * Parameters: * contour {integer} the index of the contour @@ -131,13 +131,13 @@ JSM.ContourPolygon2D.prototype.VertexCount = function (contour) * Returns: * {Coord2D} the vertex */ -JSM.ContourPolygon2D.prototype.GetVertex = function (contour, index) +JSM.OldContourPolygon2D.prototype.GetVertex = function (contour, index) { return this.polygons[contour].GetVertex (index); }; /** -* Function: ContourPolygon2D.SetVertex +* Function: OldContourPolygon2D.SetVertex * Description: Modifies the coordinates of an existing vertex of a contour. * Parameters: * contour {integer} the index of the contour @@ -145,62 +145,62 @@ JSM.ContourPolygon2D.prototype.GetVertex = function (contour, index) * x {number} the x coordinate of the vertex * y {number} the y coordinate of the vertex */ -JSM.ContourPolygon2D.prototype.SetVertex = function (contour, index, x, y) +JSM.OldContourPolygon2D.prototype.SetVertex = function (contour, index, x, y) { this.polygons[contour].SetVertex (index, x, y); }; /** -* Function: ContourPolygon2D.AddContour +* Function: OldContourPolygon2D.AddContour * Description: Adds new contour to the polygon. */ -JSM.ContourPolygon2D.prototype.AddContour = function () +JSM.OldContourPolygon2D.prototype.AddContour = function () { - this.polygons.push (new JSM.Polygon2D ()); + this.polygons.push (new JSM.OldPolygon2D ()); }; /** -* Function: ContourPolygon2D.ContourCount +* Function: OldContourPolygon2D.ContourCount * Description: Returns the contour count of the polygon. * Returns: * {integer} contour count */ -JSM.ContourPolygon2D.prototype.ContourCount = function () +JSM.OldContourPolygon2D.prototype.ContourCount = function () { return this.polygons.length; }; /** -* Function: ContourPolygon2D.GetContour +* Function: OldContourPolygon2D.GetContour * Description: Returns the contour with the given index. * Parameters: * contour {integer} the index of the contour * Returns: -* {Polygon2D} the contour +* {OldPolygon2D} the contour */ -JSM.ContourPolygon2D.prototype.GetContour = function (contour) +JSM.OldContourPolygon2D.prototype.GetContour = function (contour) { return this.polygons[contour]; }; /** -* Function: ContourPolygon2D.Clear +* Function: OldContourPolygon2D.Clear * Description: Makes the polygon empty. */ -JSM.ContourPolygon2D.prototype.Clear = function () +JSM.OldContourPolygon2D.prototype.Clear = function () { this.polygons = []; }; /** -* Function: ContourPolygon2D.Clone +* Function: OldContourPolygon2D.Clone * Description: Clones the polygon. * Returns: -* {ContourPolygon2D} a cloned instance +* {OldContourPolygon2D} a cloned instance */ -JSM.ContourPolygon2D.prototype.Clone = function () +JSM.OldContourPolygon2D.prototype.Clone = function () { - var result = new JSM.ContourPolygon2D (); + var result = new JSM.OldContourPolygon2D (); var i; for (i = 0; i < this.polygons.length; i++) { result.polygons.push (this.polygons[i].Clone ()); diff --git a/src/geometry/polygonutils.js b/src/geometry/oldpolygonutils.js similarity index 96% rename from src/geometry/polygonutils.js rename to src/geometry/oldpolygonutils.js index 0dec93b3..8b8ca469 100644 --- a/src/geometry/polygonutils.js +++ b/src/geometry/oldpolygonutils.js @@ -4,11 +4,11 @@ * Parameters: * vertices {Coord2D[*]} the vertices * Returns: -* {Polygon2D} the result +* {OldPolygon2D} the result */ JSM.CreatePolygonFromVertices = function (vertices) { - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); var i, current; for (i = 0; i < vertices.length; i++) { @@ -25,7 +25,7 @@ JSM.CreatePolygonFromVertices = function (vertices) * Calculates the signed area of a polygon. The result is positive if the polygon has * counter clockwise orientation, negative if it has clockwise orientation. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {number} the result */ @@ -49,7 +49,7 @@ JSM.PolygonSignedArea2D = function (polygon) * Function: PolygonArea2D * Description: Calculates the area of a polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {number} the result */ @@ -62,7 +62,7 @@ JSM.PolygonArea2D = function (polygon) * Function: PolygonOrientation2D * Description: Calculates the orientation of a polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {Orientation} the result */ @@ -82,7 +82,7 @@ JSM.PolygonOrientation2D = function (polygon) * Function: ChangePolygonOrientation2D * Description: Reverses the orientation of a polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon */ JSM.ChangePolygonOrientation2D = function (polygon) { @@ -102,7 +102,7 @@ JSM.ChangePolygonOrientation2D = function (polygon) * Parameters: * vertices {Coord2D[*]} the vertices * Returns: -* {Polygon2D} the result +* {OldPolygon2D} the result */ JSM.CreateCCWPolygonFromVertices = function (vertices) { @@ -117,7 +117,7 @@ JSM.CreateCCWPolygonFromVertices = function (vertices) * Function: PolygonComplexity2D * Description: Calculates the complexity of a polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {Complexity} the result */ @@ -163,7 +163,7 @@ JSM.PolygonComplexity2D = function (polygon) * Description: Calculates the position of a coordinate and a polygon. * Parameters: * coord {Coord} the coordinate -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {string} 'CoordOutsideOfPolygon', 'CoordInsideOfPolygon', or 'CoordOnPolygonEdge' */ @@ -201,14 +201,14 @@ JSM.CoordPolygonPosition2D = function (coord, polygon) sector = new JSM.Sector2D (current, next); intersection = new JSM.Coord2D (0.0, 0.0); - ssp = ray.SectorPosition (sector, intersection); - if (ssp === JSM.SectorSectorPosition2D.SectorsDontIntersect) { + ssp = ray.OldSectorPosition (sector, intersection); + if (ssp === JSM.OldSectorSectorPosition2D.SectorsDontIntersect) { continue; } - if (ssp === JSM.SectorSectorPosition2D.SectorsIntersectOnePoint) { + if (ssp === JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint) { intersections++; - } else if (ssp === JSM.SectorSectorPosition2D.SectorsIntersectEndPoint) { + } else if (ssp === JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint) { if (intersection.IsEqual (sector.beg)) { if (JSM.IsGreater (sector.beg.y, sector.end.y)) { intersections++; @@ -234,7 +234,7 @@ JSM.CoordPolygonPosition2D = function (coord, polygon) * Determines if a sector intersects a polygon. The sides next to the starting and * ending vertices will be skipped. To avoid this, give -1 for these values. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * sector {Sector2D} the sector * from {integer} index of starting vertex * end {integer} index of ending vertex @@ -254,8 +254,8 @@ JSM.SectorIntersectsPolygon2D = function (polygon, sector, from, to) } currentSector = new JSM.Sector2D (polygon.GetVertex (sectorBeg), polygon.GetVertex (sectorEnd)); - position = sector.SectorPosition (currentSector); - if (position !== JSM.SectorSectorPosition2D.SectorsDontIntersect) { + position = sector.OldSectorPosition (currentSector); + if (position !== JSM.OldSectorSectorPosition2D.SectorsDontIntersect) { return true; } } @@ -270,7 +270,7 @@ JSM.SectorIntersectsPolygon2D = function (polygon, sector, from, to) * sector between the vertices does not intersects any side of the polygon and the sector * lies fully inside the polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * from {integer} index of starting vertex * end {integer} index of ending vertex * Returns: @@ -336,7 +336,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) for (i = 0; i < contourCount; i++) { from = contourEnds[i] + 1; to = contourEnds[i + 1]; - polygon = new JSM.Polygon2D (); + polygon = new JSM.OldPolygon2D (); for (j = from; j < to; j++) { vertex = vertices[j]; polygon.AddVertex (vertex.x, vertex.y); @@ -372,7 +372,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) return true; } - var originalPolygon = new JSM.Polygon2D (); + var originalPolygon = new JSM.OldPolygon2D (); var i, j, vertex; for (i = 0; i < resultIndices.length; i++) { vertex = vertices[resultIndices[i]]; @@ -511,7 +511,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) * Triangulates a polygon. The result defines triangles as an * array of arrays with three original vertex indices. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * Returns: * {integer[3][*]} the result */ @@ -658,7 +658,7 @@ JSM.PolygonTriangulate2D = function (polygon) continue; } - currentPolygon2D = new JSM.Polygon2D (); + currentPolygon2D = new JSM.OldPolygon2D (); for (j = 0; j < currentVertexCount; j++) { vertex = workPolygon.GetVertex (currentPolygon[j]); currentPolygon2D.AddVertex (vertex.x, vertex.y); @@ -688,7 +688,7 @@ JSM.PolygonTriangulate2D = function (polygon) * Checks a triangulation created with PolygonTriangulate2D. It checks if * the area of triangles equal to the area of the original polygon. * Parameters: -* polygon {Polygon2D} the polygon +* polygon {OldPolygon2D} the polygon * triangles {integer[3][*]} the triangulation * Returns: * {boolean} the result @@ -705,7 +705,7 @@ JSM.CheckTriangulation2D = function (polygon, triangles) return false; } - currentTriangle = new JSM.Polygon2D (); + currentTriangle = new JSM.OldPolygon2D (); for (j = 0; j < triangle.length; j++) { vertex = polygon.GetVertex (triangle[j]); currentTriangle.AddVertex (vertex.x, vertex.y); @@ -768,7 +768,7 @@ JSM.CreatePolygonWithHole = function (vertices) */ JSM.PolygonTriangulate = function (polygon) { - var polygon2D = new JSM.Polygon2D (); + var polygon2D = new JSM.OldPolygon2D (); var normal = JSM.CalculateNormal (polygon.vertices); var vertexCount = polygon.VertexCount (); diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js new file mode 100644 index 00000000..126eeb07 --- /dev/null +++ b/src/geometry/polygon2d.js @@ -0,0 +1,533 @@ +JSM.Complexity = { + Invalid : 0, + Convex : 1, + Concave : 2, + Complex : 3 +}; + +JSM.PointPosition = { + OnVertex : 0, + OnEdge : 1, + Inside : 2, + Outside : 3 +}; + +JSM.SectorPosition = { + IntersectionOnePoint : 0, + IntersectionCoincident : 1, + IntersectionOnVertex : 2, + NoIntersection : 3 +}; + +JSM.Polygon2D = function () +{ + this.vertices = null; + this.cache = null; + this.Clear (); +}; + +JSM.Polygon2D.prototype.AddVertex = function (x, y) +{ + this.AddVertexCoord (new JSM.Coord2D (x, y)); +}; + +JSM.Polygon2D.prototype.AddVertexCoord = function (coord) +{ + this.vertices.push (coord); + this.ClearCache (); +}; + +JSM.Polygon2D.prototype.GetVertex = function (index) +{ + return this.vertices[index]; +}; + +JSM.Polygon2D.prototype.VertexCount = function () +{ + return this.vertices.length; +}; + +JSM.Polygon2D.prototype.EnumerateVertices = function (from, to, callback) +{ + var count = this.vertices.length; + var index = from; + callback (index); + while (index != to) { + index = (index + 1) % count; + callback (index); + } +}; + +JSM.Polygon2D.prototype.GetNextVertex = function (index) +{ + var count = this.vertices.length; + return (index < count - 1 ? index + 1 : 0); +}; + +JSM.Polygon2D.prototype.GetPrevVertex = function (index) +{ + var count = this.vertices.length; + return (index > 0 ? index - 1 : count - 1); +}; + +JSM.Polygon2D.prototype.ShiftVertices = function (count) +{ + var i; + for (i = 0; i < count; i++) { + this.vertices.push (this.vertices.shift ()); + } + this.ClearCache (); +}; + +JSM.Polygon2D.prototype.GetSignedArea = function () +{ + if (this.cache.signedArea !== null) { + return this.cache.signedArea; + } + + var count = this.vertices.length; + var result = 0.0; + if (count >= 3) { + var i, current, next; + for (i = 0; i < count; i++) { + current = this.vertices[i]; + next = this.vertices[(i + 1) % count]; + result += current.x * next.y - next.x * current.y; + } + result *= 0.5; + } + + this.cache.signedArea = result; + return result; +}; + +JSM.Polygon2D.prototype.GetArea = function () +{ + var signedArea = this.GetSignedArea (); + return Math.abs (signedArea); +}; + +JSM.Polygon2D.prototype.GetOrientation = function () +{ + if (this.cache.orientation !== null) { + return this.cache.orientation; + } + + var result = JSM.Orientation.Invalid; + if (this.vertices.length >= 3) { + var signedArea = this.GetSignedArea (); + if (JSM.IsPositive (signedArea)) { + result = JSM.Orientation.CounterClockwise; + } else if (JSM.IsNegative (signedArea)) { + result = JSM.Orientation.Clockwise; + } + } + + this.cache.orientation = result; + return result; +}; + +JSM.Polygon2D.prototype.GetVertexOrientation = function (index) +{ + if (this.cache.vertexOrientations[index] !== undefined) { + return this.cache.vertexOrientations[index]; + } + + var prev = this.vertices[this.GetPrevVertex (index)]; + var curr = this.vertices[index]; + var next = this.vertices[this.GetNextVertex (index)]; + + var result = JSM.CoordOrientation2D (prev, curr, next); + this.cache.vertexOrientations[index] = result; + return result; +}; + +JSM.Polygon2D.prototype.IsConvexVertex = function (index) +{ + var orientation = this.GetOrientation (); + var vertexOrientation = this.GetVertexOrientation (index); + if (vertexOrientation == JSM.Orientation.Invalid) { + return false; + } + return vertexOrientation == orientation; +}; + +JSM.Polygon2D.prototype.IsConcaveVertex = function (index) +{ + var orientation = this.GetOrientation (); + var vertexOrientation = this.GetVertexOrientation (index); + if (vertexOrientation == JSM.Orientation.Invalid) { + return false; + } + return vertexOrientation != orientation; +}; + +JSM.Polygon2D.prototype.PointPosition = function (coord) +{ + function IntersectionCount (coord, beg, end) + { + function GetIntersection (coord, beg, end) + { + var result = new JSM.Coord2D (beg.x, coord.y); + if (!JSM.IsEqual (beg.y, coord.y)) { + var yMoveRatio = Math.abs ((beg.y - coord.y) / (end.y - beg.y)); + result.x = beg.x + (end.x - beg.x) * yMoveRatio; + } + return result; + } + + var begYDist = beg.y - coord.y; + var endYDist = end.y - coord.y; + + var begBelow = JSM.IsNegative (begYDist); + var begAbove = JSM.IsPositive (begYDist); + var endBelow = JSM.IsNegative (endYDist); + var endAbove = JSM.IsPositive (endYDist); + if ((begBelow && endBelow) || (begAbove && endAbove)) { + return 0; + } + + var begOnLine = !begBelow && !begAbove; + var endOnLine = !endBelow && !endAbove; + if (begOnLine && endOnLine) { + return 0; + } + + var intersection = GetIntersection (coord, beg, end); + if (JSM.IsLower (intersection.x, coord.x)) { + return 0; + } else if (JSM.IsGreater (intersection.x, coord.x)) { + if (begOnLine || endOnLine) { + var upwardEdge = JSM.IsGreater (end.y, beg.y); + if (begOnLine && upwardEdge || endOnLine && !upwardEdge) { + return 1; + } + return 0; + } + return 1; + } + return 1; + } + + var vertexCount = this.vertices.length; + var intersections = 0; + var i, edgeFrom, edgeTo, sector, position; + for (i = 0; i < vertexCount; i++) { + edgeFrom = this.vertices[i]; + edgeTo = this.vertices[(i + 1) % vertexCount]; + sector = new JSM.Sector2D (edgeFrom, edgeTo); + position = sector.CoordPosition (coord); + if (position == JSM.CoordSectorPosition2D.CoordInsideOfSector) { + return JSM.PointPosition.OnEdge; + } else if (position == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { + return JSM.PointPosition.OnVertex; + } + intersections += IntersectionCount (coord, edgeFrom, edgeTo); + } + + if (intersections % 2 !== 0) { + return JSM.PointPosition.Inside; + } + return JSM.PointPosition.Outside; +}; + +JSM.Polygon2D.prototype.SectorPosition = function (beg, end, begIndex, endIndex) +{ + var result = JSM.SectorPosition.NoIntersection; + var vertexCount = this.vertices.length; + if (vertexCount < 3) { + return result; + } + + var i, edgeBegIndex, edgeEndIndex, edgeBeg, edgeEnd; + var sector1, sector2, position; + for (i = 0; i < vertexCount; i++) { + edgeBegIndex = i; + edgeEndIndex = (i + 1) % vertexCount; + edgeBeg = this.vertices[edgeBegIndex]; + edgeEnd = this.vertices[edgeEndIndex]; + if (edgeBegIndex == begIndex || edgeEndIndex == begIndex || edgeBegIndex == endIndex || edgeEndIndex == endIndex) { + continue; + } + sector1 = new JSM.Sector2D (edgeBeg, edgeEnd); + sector2 = new JSM.Sector2D (beg, end); + position = sector1.SectorPosition (sector2); + if (position == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint) { + return JSM.SectorPosition.IntersectionOnePoint; + } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectCoincident) { + return JSM.SectorPosition.IntersectionCoincident; + } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint) { + result = JSM.SectorPosition.IntersectionOnVertex; + } + } + + return result; +}; + +JSM.Polygon2D.prototype.IsDiagonal = function (from, to) +{ + function DiagonalIntersectsAnyEdges (polygon, from, to) + { + var fromVertex = polygon.GetVertex (from); + var toVertex = polygon.GetVertex (to); + var position = polygon.SectorPosition (fromVertex, toVertex, from, to); + if (position != JSM.SectorPosition.NoIntersection) { + return true; + } + return false; + } + + function DiagonalInsideOfPolygon (polygon, from, to) + { + var fromVertex = polygon.GetVertex (from); + var toVertex = polygon.GetVertex (to); + var midCoord = new JSM.Coord2D ( + (fromVertex.x + toVertex.x) / 2.0, + (fromVertex.y + toVertex.y) / 2.0 + ); + var position = polygon.PointPosition (midCoord); + return position == JSM.PointPosition.Inside; + } + + if (from == to) { + return false; + } + + if (this.GetPrevVertex (from) == to || this.GetNextVertex (from) == to) { + return false; + } + + var fromVertex = this.vertices[from]; + var toVertex = this.vertices[to]; + if (fromVertex.IsEqual (toVertex)) { + return false; + } + + if (DiagonalIntersectsAnyEdges (this, from, to)) { + return false; + } + + if (!DiagonalInsideOfPolygon (this, from, to)) { + return false; + } + + return true; +}; + +JSM.Polygon2D.prototype.GetComplexity = function () +{ + if (this.cache.complexity !== null) { + return this.cache.complexity; + } + + var count = this.vertices.length; + if (count < 3) { + return JSM.Complexity.Invalid; + } + + var result = JSM.Complexity.Invalid; + var polygonOrientain = this.GetOrientation (); + if (polygonOrientain != JSM.Orientation.Invalid) { + result = JSM.Complexity.Convex; + var i; + for (i = 0; i < count; i++) { + if (this.IsConcaveVertex (i)) { + result = JSM.Complexity.Concave; + break; + } + } + } + + this.cache.complexity = result; + return result; +}; + +JSM.Polygon2D.prototype.ToJson = function () +{ + var result = { + vertices : [] + }; + var i, vertex; + for (i = 0; i < this.vertices.length; i++) { + vertex = this.vertices[i]; + result.vertices.push ([vertex.x, vertex.y]); + } + return result; +}; + +JSM.Polygon2D.prototype.FromJson = function (json) +{ + this.Clear (); + var i, vertex; + for (i = 0; i < json.vertices.length; i++) { + vertex = json.vertices[i]; + this.AddVertex (vertex[0], vertex[1]); + } +}; + +JSM.Polygon2D.prototype.Clone = function () +{ + var result = new JSM.Polygon2D (); + var i, vertex; + for (i = 0; i < this.vertices.length; i++) { + vertex = this.vertices[i]; + result.AddVertex (vertex.x, vertex.y); + } + return result; +}; + +JSM.Polygon2D.prototype.Clear = function () +{ + this.vertices = []; + this.ClearCache (); +}; + +JSM.Polygon2D.prototype.ClearCache = function () +{ + this.cache = { + signedArea : null, + orientation : null, + vertexOrientations : {}, + complexity : null + }; +}; + +JSM.ContourPolygon2D = function () +{ + this.contours = null; + this.Clear (); +}; + +JSM.ContourPolygon2D.prototype.AddVertex = function (x, y) +{ + this.lastContour.AddVertex (x, y); +}; + +JSM.ContourPolygon2D.prototype.AddVertexCoord = function (coord) +{ + this.lastContour.AddVertexCoord (coord); +}; + +JSM.ContourPolygon2D.prototype.GetVertex = function (index) +{ + var contourIndex = 0; + var currentIndex = 0; + while (index >= currentIndex + this.contours[contourIndex].VertexCount ()) { + currentIndex += this.contours[contourIndex].VertexCount (); + contourIndex += 1; + } + var vertexIndex = index - currentIndex; + return this.GetContourVertex (contourIndex, vertexIndex); +}; + +JSM.ContourPolygon2D.prototype.VertexCount = function () +{ + var vertexCount = 0; + var i; + for (i = 0; i < this.contours.length; i++) { + vertexCount += this.contours[i].VertexCount (); + } + return vertexCount; +}; + +JSM.ContourPolygon2D.prototype.AddContour = function (contour) +{ + if (contour === undefined || contour === null) { + this.lastContour = new JSM.Polygon2D (); + } else { + this.lastContour = contour; + } + this.contours.push (this.lastContour); +}; + +JSM.ContourPolygon2D.prototype.GetContourVertex = function (contourIndex, vertexIndex) +{ + return this.contours[contourIndex].GetVertex (vertexIndex); +}; + +JSM.ContourPolygon2D.prototype.GetContour = function (index) +{ + return this.contours[index]; +}; + +JSM.ContourPolygon2D.prototype.ContourCount = function () +{ + return this.contours.length; +}; + +JSM.ContourPolygon2D.prototype.GetSignedArea = function () +{ + var area = 0.0; + var i; + for (i = 0; i < this.contours.length; i++) { + area += this.contours[i].GetSignedArea (); + } + return area; +}; + +JSM.ContourPolygon2D.prototype.GetArea = function () +{ + var signedArea = this.GetSignedArea (); + return Math.abs (signedArea); +}; + +JSM.ContourPolygon2D.prototype.GetOrientation = function () +{ + if (this.lastContour === null) { + return JSM.Orientation.Invalid; + } + var orientation = this.contours[0].GetOrientation (); + if (this.contours.length == 1) { + return orientation; + } + if (orientation == JSM.Orientation.Invalid) { + return JSM.Orientation.Invalid; + } + var i, contourOrientation; + for (i = 1; i < this.contours.length; i++) { + contourOrientation = this.contours[i].GetOrientation (); + if (contourOrientation == JSM.Orientation.Invalid) { + return JSM.Orientation.Invalid; + } + if (orientation == contourOrientation) { + return JSM.Orientation.Invalid; + } + } + return orientation; +}; + +JSM.ContourPolygon2D.prototype.GetComplexity = function () +{ + if (this.lastContour === null) { + return JSM.Complexity.Invalid; + } + if (this.contours.length == 1) { + return this.contours[0].GetComplexity (); + } + var i, contourComplexity; + for (i = 1; i < this.contours.length; i++) { + contourComplexity = this.contours[i].GetComplexity (); + if (contourComplexity == JSM.Complexity.Invalid) { + return JSM.Complexity.Invalid; + } + } + return JSM.Complexity.Complex; +}; + +JSM.ContourPolygon2D.prototype.Clear = function () +{ + this.contours = []; + this.lastContour = null; +}; + +JSM.ContourPolygon2D.prototype.Clone = function () +{ + var result = new JSM.ContourPolygon2D (); + var i, contour; + for (i = 0; i < this.contours.length; i++) { + contour = this.contours[i]; + result.AddContour (contour.Clone ()); + } + return result; + +}; diff --git a/src/geometry/sector.js b/src/geometry/sector.js index 43cd18d3..45720a5b 100644 --- a/src/geometry/sector.js +++ b/src/geometry/sector.js @@ -12,6 +12,22 @@ JSM.CoordSectorPosition2D = { CoordOutsideOfSector : 2 }; +/** +* Enum: OldSectorSectorPosition2D +* Description: Position of two sectors. +* Values: +* {SectorsDontIntersect} sectors do not intersect +* {SectorsIntersectCoincident} sectors intersect coincident +* {SectorsIntersectEndPoint} sectors intersect at end point +* {SectorsIntersectOnePoint} sectors intersect one point +*/ +JSM.OldSectorSectorPosition2D = { + SectorsDontIntersect : 0, + SectorsIntersectCoincident : 1, + SectorsIntersectEndPoint : 2, + SectorsIntersectOnePoint : 3 +}; + /** * Enum: SectorSectorPosition2D * Description: Position of two sectors. @@ -124,15 +140,15 @@ JSM.Sector2D.prototype.CoordPosition = function (coord) }; /** -* Function: Sector2D.SectorPosition +* Function: Sector2D.OldSectorPosition * Description: Calculates the position of the sector and the given sector. * Parameters: * sector {Sector2D} the sector * intersection {Coord2D} (out) the intersection point if it exists * Returns: -* {SectorSectorPosition2D} the result +* {OldSectorSectorPosition2D} the result */ -JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) +JSM.Sector2D.prototype.OldSectorPosition = function (sector, intersection) { var aSector = this; var bSector = sector; @@ -154,9 +170,9 @@ JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) var bBeg = aSector.CoordPosition (bSector.beg); var bEnd = aSector.CoordPosition (bSector.end); if (aBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || aEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector || bBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || bEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector) { - return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + return JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident; } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + return JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident; } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { if (intersection !== undefined) { if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { @@ -169,21 +185,21 @@ JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) intersection = bSector.end.Clone (); } } - return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + return JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint; } - return JSM.SectorSectorPosition2D.SectorsDontIntersect; + return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; } var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); if (JSM.IsZero (denom)) { - return JSM.SectorSectorPosition2D.SectorsDontIntersect; + return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; } ux /= denom; uy /= denom; if (JSM.IsLower (ux, 0.0) || JSM.IsGreater (ux, 1.0) || JSM.IsLower (uy, 0.0) || JSM.IsGreater (uy, 1.0)) { - return JSM.SectorSectorPosition2D.SectorsDontIntersect; + return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; } if (intersection !== undefined) { @@ -192,9 +208,112 @@ JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) } if (JSM.IsEqual (ux, 0.0) || JSM.IsEqual (ux, 1.0) || JSM.IsEqual (uy, 0.0) || JSM.IsEqual (uy, 1.0)) { - return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + return JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint; + } + + return JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint; +}; + +/** +* Function: Sector2D.SectorPosition +* Description: Calculates the position of the sector and the given sector. +* Parameters: +* sector {Sector2D} the sector +* intersection {Coord2D} (out) the intersection point if it exists +* Returns: +* {SectorSectorPosition2D} the result +*/ +JSM.Sector2D.prototype.SectorPosition = function (sector, intersection) +{ + function IsOnSegment (beg, end, coord) + { + if (!coord.IsEqual (beg) && !coord.IsEqual (end) && + JSM.IsLowerOrEqual (coord.x, Math.max (beg.x, end.x)) && + JSM.IsLowerOrEqual (coord.y, Math.max (beg.y, end.y)) && + JSM.IsGreaterOrEqual (coord.x, Math.min (beg.x, end.x)) && + JSM.IsGreaterOrEqual (coord.y, Math.min (beg.y, end.y))) + { + return true; + } + return false; } + var calcIntersection = (intersection !== undefined && intersection !== null); + + var aBeg = this.beg; + var aEnd = this.end; + var bBeg = sector.beg; + var bEnd = sector.end; + + var equalBeg = aBeg.IsEqual (bBeg) || aBeg.IsEqual (bEnd); + var equalEnd = aEnd.IsEqual (bBeg) || aEnd.IsEqual (bEnd); + if (equalBeg && equalEnd) { + return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + } + + var x1 = aBeg.x; + var y1 = aBeg.y; + var x2 = aEnd.x; + var y2 = aEnd.y; + var x3 = bBeg.x; + var y3 = bBeg.y; + var x4 = bEnd.x; + var y4 = bEnd.y; + + var numeratorA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numeratorB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + if (JSM.IsZero (denominator)) { + if (JSM.IsZero (numeratorA) && JSM.IsZero (numeratorB)) { + if (IsOnSegment (aBeg, aEnd, bBeg) || + IsOnSegment (aBeg, aEnd, bEnd) || + IsOnSegment (bBeg, bEnd, aBeg) || + IsOnSegment (bBeg, bEnd, aEnd)) + { + return JSM.SectorSectorPosition2D.SectorsIntersectCoincident; + } else if (equalBeg) { + if (calcIntersection) { + intersection.x = aBeg.x; + intersection.y = aBeg.y; + } + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } else if (equalEnd) { + if (calcIntersection) { + intersection.x = aEnd.x; + intersection.y = aEnd.y; + } + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } + } + return JSM.SectorSectorPosition2D.SectorsDontIntersect; + } + + var distA = numeratorA / denominator; + var distB = numeratorB / denominator; + if (JSM.IsLower (distA, 0.0) || JSM.IsGreater (distA, 1.0) || + JSM.IsLower (distB, 0.0) || JSM.IsGreater (distB, 1.0)) + { + return JSM.SectorSectorPosition2D.SectorsDontIntersect; + } + + if (equalBeg) { + if (calcIntersection) { + intersection.x = aBeg.x; + intersection.y = aBeg.y; + } + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } else if (equalEnd) { + if (calcIntersection) { + intersection.x = aEnd.x; + intersection.y = aEnd.y; + } + return JSM.SectorSectorPosition2D.SectorsIntersectEndPoint; + } + + if (calcIntersection) { + intersection.x = x1 + distA * (x2 - x1); + intersection.y = y1 + distA * (y2 - y1); + } return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint; }; diff --git a/src/geometry/triangulation.js b/src/geometry/triangulation.js new file mode 100644 index 00000000..898f3494 --- /dev/null +++ b/src/geometry/triangulation.js @@ -0,0 +1,248 @@ +JSM.ConvertPolygonToSimplePolygon = function (inputPolygon) +{ + function AddContour (inputPolygon, resultPolygon, holeIndex, conversionData) + { + function GetEntryPoint (inputPolygon, resultPolygon, holeIndex, conversionData) + { + function IsEntryPoint (inputPolygon, resultPolygon, resultVertex, holeVertex, conversionData) + { + function SegmentIntersectsPolygon (polygon, segmentBeg, segmentEnd) + { + var position = polygon.SectorPosition (segmentBeg, segmentEnd, -1, -1); + if (position == JSM.SectorPosition.IntersectionOnePoint || position == JSM.SectorPosition.IntersectionCoincident) { + return true; + } + return false; + } + + if (SegmentIntersectsPolygon (resultPolygon, resultVertex, holeVertex)) { + return false; + } + + var i, hole; + for (i = 1; i < inputPolygon.ContourCount (); i++) { + if (conversionData.addedHoles[i] !== undefined) { + continue; + } + hole = inputPolygon.GetContour (i); + if (SegmentIntersectsPolygon (hole, resultVertex, holeVertex)) { + return false; + } + } + + return true; + } + + function IsExistingEntryPosition (coord, conversionData) + { + var i; + for (i = 0; i < conversionData.entryPositions.length; i++) { + if (coord.IsEqual (conversionData.entryPositions[i])) { + return true; + } + } + return false; + } + + var holePolygon = inputPolygon.GetContour (holeIndex); + var resultVertexIndex, holeVertexIndex, resultVertex, holeVertex; + for (resultVertexIndex = 0; resultVertexIndex < resultPolygon.VertexCount (); resultVertexIndex++) { + for (holeVertexIndex = 0; holeVertexIndex < holePolygon.VertexCount (); holeVertexIndex++) { + resultVertex = resultPolygon.GetVertex (resultVertexIndex); + holeVertex = holePolygon.GetVertex (holeVertexIndex); + if (IsEntryPoint (inputPolygon, resultPolygon, resultVertex, holeVertex, conversionData)) { + if (IsExistingEntryPosition (resultVertex, conversionData) || IsExistingEntryPosition (holeVertex, conversionData)) { + continue; + } + conversionData.entryPositions.push (resultVertex.Clone ()); + conversionData.entryPositions.push (holeVertex.Clone ()); + return { + beg : resultVertexIndex, + end : holeVertexIndex + }; + } + } + } + return null; + } + + function AddHole (resultPolygon, holePolygon, entryPoint) + { + var entryVertex = resultPolygon.GetVertex (entryPoint.beg).Clone (); + resultPolygon.ShiftVertices (entryPoint.beg + 1); + + var contourBeg = entryPoint.end; + var contourEnd = holePolygon.GetPrevVertex (contourBeg); + holePolygon.EnumerateVertices (contourBeg, contourEnd, function (index) { + resultPolygon.AddVertexCoord (holePolygon.GetVertex (index).Clone ()); + }); + resultPolygon.AddVertexCoord (holePolygon.GetVertex (contourBeg).Clone ()); + resultPolygon.AddVertexCoord (entryVertex); + } + + var entryPoint = GetEntryPoint (inputPolygon, resultPolygon, holeIndex, conversionData); + if (entryPoint === null) { + return false; + } + + var holePolygon = inputPolygon.GetContour (holeIndex); + AddHole (resultPolygon, holePolygon, entryPoint); + return true; + } + + var contourCount = inputPolygon.ContourCount (); + var mainContour = inputPolygon.GetContour (0); + var resultPolygon = mainContour.Clone (); + if (contourCount == 1) { + return resultPolygon; + } + + var holeQueue = []; + var holeIndex; + for (holeIndex = 1; holeIndex < contourCount; holeIndex++) { + holeQueue.push (holeIndex); + } + + var conversionData = { + addedHoles : {}, + entryPositions : [] + }; + while (holeQueue.length > 0) { + holeIndex = holeQueue.shift (); + if (AddContour (inputPolygon, resultPolygon, holeIndex, conversionData)) { + conversionData.addedHoles[holeIndex] = true; + } else { + holeQueue.push (holeIndex); + } + } + + return resultPolygon; +}; + +JSM.TriangulateSimpleConvexPolygon = function (polygon) +{ + var result = []; + var i; + for (i = 1; i < polygon.VertexCount () - 1; i++) { + result.push ([0, i, i + 1]); + } + return result; +}; + +JSM.TriangulateSimpleConcavePolygonDiagonal = function (inputPolygon, onProcess) +{ + function GetInitialVertexMap (count) + { + var result = []; + var i; + for (i = 0; i < count; i++) { + result[i] = i; + } + return result; + } + + function FindSplitDiagonal (polygon) + { + var count = polygon.VertexCount (); + var i, j; + for (i = 0; i < count; i++) { + for (j = 0; j < count; j++) { + if (i == j) { + continue; + } + if (polygon.IsDiagonal (i, j)) { + return { + beg : i, + end : j + }; + } + } + } + return null; + } + + function SplitPolygon (polygonData, diagonal) + { + var resultData1 = { + polygon : new JSM.Polygon2D (), + map : [] + }; + var resultData2 = { + polygon : new JSM.Polygon2D (), + map : [] + }; + polygonData.polygon.EnumerateVertices (diagonal.beg, diagonal.end, function (index) { + resultData1.polygon.AddVertexCoord (polygonData.polygon.GetVertex (index)); + resultData1.map.push (polygonData.map[index]); + }); + polygonData.polygon.EnumerateVertices (diagonal.end, diagonal.beg, function (index) { + resultData2.polygon.AddVertexCoord (polygonData.polygon.GetVertex (index)); + resultData2.map.push (polygonData.map[index]); + }); + return { + resultData1 : resultData1, + resultData2 : resultData2 + }; + } + + var polygonStack = []; + var count = inputPolygon.VertexCount (); + var inputMap = GetInitialVertexMap (count); + polygonStack.push ({ + polygon : inputPolygon, + map : inputMap + }); + + var result = []; + var polygonData, vertexCount, diagonal, resultData; + while (polygonStack.length > 0) { + polygonData = polygonStack.pop (); + vertexCount = polygonData.polygon.VertexCount (); + if (vertexCount < 3) { + continue; + } + if (vertexCount == 3) { + result.push (polygonData.map); + continue; + } + diagonal = FindSplitDiagonal (polygonData.polygon); + if (diagonal === null) { + return null; + } + if (onProcess !== undefined && onProcess !== null) { + onProcess (polygonData.polygon, diagonal); + } + resultData = SplitPolygon (polygonData, diagonal); + polygonStack.push (resultData.resultData1); + polygonStack.push (resultData.resultData2); + } + return result; +}; + +JSM.TriangulateSimpleConcavePolygon = function (polygon) +{ + return JSM.TriangulateSimpleConcavePolygonDiagonal (polygon); +}; + +JSM.TriangulateSimplePolygon = function (polygon) +{ + if (polygon === null) { + return null; + } + + var vertexCount = polygon.VertexCount (); + if (vertexCount < 3) { + return null; + } + + if (vertexCount == 3) { + return [[0, 1, 2]]; + } + + var complexity = polygon.GetComplexity (); + if (complexity == JSM.Complexity.Convex) { + return JSM.TriangulateSimpleConvexPolygon (polygon); + } + + return JSM.TriangulateSimpleConcavePolygon (polygon); +}; diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index b25878ef..495c7641 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -22,8 +22,10 @@ unitTest.AddSourceFile ('../../src/geometry/transformation.js'); unitTest.AddSourceFile ('../../src/geometry/plane.js'); unitTest.AddSourceFile ('../../src/geometry/projection.js'); unitTest.AddSourceFile ('../../src/geometry/convexhull.js'); -unitTest.AddSourceFile ('../../src/geometry/polygon.js'); -unitTest.AddSourceFile ('../../src/geometry/polygonutils.js'); +unitTest.AddSourceFile ('../../src/geometry/polygon2d.js'); +unitTest.AddSourceFile ('../../src/geometry/triangulation.js'); +unitTest.AddSourceFile ('../../src/geometry/oldpolygon.js'); +unitTest.AddSourceFile ('../../src/geometry/oldpolygonutils.js'); unitTest.AddSourceFile ('../../src/geometry/octree.js'); unitTest.AddSourceFile ('../../src/geometry/bsptree.js'); unitTest.AddSourceFile ('../../src/geometry/utilities.js'); @@ -78,6 +80,8 @@ unitTest.AddSourceFile ('../../src/three/threeviewer.js'); unitTest.AddTestFile ('tests/core.js'); unitTest.AddTestFile ('tests/geometry.js'); +unitTest.AddTestFile ('tests/polygon.js'); +unitTest.AddTestFile ('tests/triangulation.js'); unitTest.AddTestFile ('tests/modeler.js'); unitTest.AddTestFile ('tests/import.js'); unitTest.AddTestFile ('tests/extras.js'); diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index 29276de5..7942f2ac 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -724,6 +724,43 @@ generalSuite.AddTest ('CoordSectorPosition2DTest', function (test) test.Assert (sector4.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordSectorPosition2D.CoordOutsideOfSector); }); +generalSuite.AddTest ('CoordSectorPosition2DTest2', function (test) +{ + var coord1 = new JSM.Coord2D (0, 0); + var coord2 = new JSM.Coord2D (10, 10); + var sector = null; + + var i, beg, end; + for (i = 0; i < 2; i++) { + if (i === 0) { + beg = coord1; + end = coord2; + } else if (i === 1) { + beg = coord2; + end = coord1; + } + + sector = new JSM.Sector2D (beg, end); + + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(0, 0)), JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(10, 10)), JSM.CoordSectorPosition2D.CoordOnSectorEndCoord); + + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(-1, -1)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(11, 11)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(1, 2)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(2, 1)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(8, 9)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(9, 8)), JSM.CoordSectorPosition2D.CoordOutsideOfSector); + + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(2, 2)), JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(3, 3)), JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(5, 5)), JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(8, 8)), JSM.CoordSectorPosition2D.CoordInsideOfSector); + test.AssertEqual (sector.CoordPosition (new JSM.Coord2D(9, 9)), JSM.CoordSectorPosition2D.CoordInsideOfSector); + } +}); + generalSuite.AddTest ('ProjectCoordToSector2DTest', function (test) { var sector1 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (1.0, 2.0)); @@ -771,7 +808,7 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector1 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (0.0, 2.0), new JSM.Coord2D (1.0, 2.0)); - test.Assert (sector1.SectorPosition (sector2) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector1.OldSectorPosition (sector2) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); var sector1 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (1.0, 2.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (4.0, 3.0)); @@ -779,50 +816,185 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var intersection = new JSM.Coord2D (0.0, 0.0); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 0.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (sector3.SectorPosition (GetSector2D (1.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - - test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (2.0, 0.0, 4.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - - test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 2.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 3.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (1.0, 2.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 2.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 2.5, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 1.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 1.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + + test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 1.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 0.0, 4.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + + test.Assert (sector3.OldSectorPosition (GetSector2D (-1.0, 1.0, 0.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 2.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 3.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 2.0, 3.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 1.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 1.0, 4.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 1.0, 2.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 2.5, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 4.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, -3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.OldSectorPosition (GetSector2D (-1.0, 1.0, -3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (-1.0, 1.0, 0.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (4.0, 1.0, 5.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (0.0, 0.0, 2.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (1.0, 0.0, 3.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (1.0, 2.0, 3.0, 2.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (0.0, 1.0, 1.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (GetSector2D (3.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (GetSector2D (0.0, 1.0, 2.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 2.5, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 3.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (-1.0, 1.0, 0.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (4.0, 1.0, 5.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 0.0, 2.0, 0.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 0.0, 3.0, 0.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 2.0, 3.0, 2.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 1.0, 1.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (3.0, 1.0, 4.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (0.0, 1.0, 2.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 2.5, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 3.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 4.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (0.0, 0.0, 1.0, 1.0).SectorPosition (GetSector2D (3.0, 0.0, 3.0, 3.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (3.0, 0.0, 3.0, 3.0).SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 0.0, 1.0, 1.0).OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 3.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (3.0, 0.0, 3.0, 3.0).OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); +}); + +generalSuite.AddTest ('SectorSectorPositionTest2', function (test) +{ + function GetSectorsPosition (a, b, c, d, i) + { + var sector1 = new JSM.Sector2D (a, b); + var sector2 = new JSM.Sector2D (c, d); + return sector1.SectorPosition (sector2, i); + } + + var coord1 = new JSM.Coord2D (0.0, 0.0); + var coord2 = new JSM.Coord2D (1.0, 0.0); + var coord3 = new JSM.Coord2D (2.0, 0.0); + var coord4 = new JSM.Coord2D (3.0, 0.0); + + var coord5 = new JSM.Coord2D (0.0, 1.0); + var coord6 = new JSM.Coord2D (1.0, 1.0); + var coord7 = new JSM.Coord2D (2.0, 1.0); + var coord8 = new JSM.Coord2D (3.0, 1.0); + + var coord9 = new JSM.Coord2D (0.0, 2.0); + var coord10 = new JSM.Coord2D (1.0, 2.0); + var coord11 = new JSM.Coord2D (2.0, 2.0); + var coord12 = new JSM.Coord2D (3.0, 2.0); + + var intersection = new JSM.Coord2D (0.0, 0.0); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord1, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord1, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord1, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord3, coord4, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.AssertEqual (GetSectorsPosition (coord2, coord10, coord5, coord6, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord2, coord10, coord5, coord7, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + + test.AssertEqual (GetSectorsPosition (coord2, coord10, coord5, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord2, coord10, coord8, coord5, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord10, coord2, coord5, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord10, coord2, coord8, coord5, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + + test.AssertEqual (GetSectorsPosition (coord5, coord8, coord2, coord10, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord5, coord8, coord10, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord8, coord5, coord2, coord10, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + test.AssertEqual (GetSectorsPosition (coord8, coord5, coord10, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord6)); + + test.AssertEqual (GetSectorsPosition (coord1, coord1, coord1, coord1, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord1, coord1, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord1)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord3, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + + test.AssertEqual (GetSectorsPosition (coord1, coord3, coord2, coord4, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord1, coord3, coord4, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord3, coord1, coord2, coord4, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.AssertEqual (GetSectorsPosition (coord3, coord1, coord4, coord2, intersection), JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord3, coord4, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord4, coord3, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord2, coord1, coord3, coord4, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord2, coord1, coord4, coord3, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord5, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord7, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord5, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord2, coord3, coord5, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord6), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord7), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord8), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord3), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord7, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord3, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord3, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord3, coord7, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord3, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord4, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord8, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord1, coord5, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord1)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord3, coord7, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord3)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord4, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord4)); + + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord3, coord7, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord3)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord2, coord5, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord3, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord3)); + + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord6, coord3, intersection), JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (intersection.IsEqual (coord3)); + test.AssertEqual (GetSectorsPosition (coord1, coord2, coord2, coord8, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (intersection.IsEqual (coord2)); + test.AssertEqual (GetSectorsPosition (coord1, coord4, coord6, coord4, intersection), JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord6, coord2, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord5, coord1, coord2, coord6, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord5, coord1, coord6, coord2, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord2, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord1, coord5, coord8, coord2, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord5, coord1, coord2, coord8, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.AssertEqual (GetSectorsPosition (coord5, coord1, coord8, coord2, intersection), JSM.SectorSectorPosition2D.SectorsDontIntersect); }); generalSuite.AddTest ('BoxTest', function (test) @@ -1376,7 +1548,7 @@ var polygonSuite = unitTest.AddTestSuite ('GeometryPolygon'); polygonSuite.AddTest ('PolygonTest', function (test) { - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); polygon.AddVertex (0.0, 1.0); @@ -1391,14 +1563,14 @@ polygonSuite.AddTest ('PolygonTest', function (test) test.Assert (JSM.PolygonComplexity2D (polygon) == JSM.Complexity.Convex); test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.2, 0.2), polygon) == 'CoordInsideOfPolygon'); - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); var triangles = JSM.PolygonTriangulate2D (polygon); test.Assert (triangles.length == 0); - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); polygon.AddVertex (1.0, 1.0); @@ -1408,7 +1580,7 @@ polygonSuite.AddTest ('PolygonTest', function (test) test.Assert (triangles[0].toString () == '0,1,2'); test.Assert (JSM.CheckTriangulation2D (polygon, triangles) == true); - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); polygon.AddVertex (1.0, 1.0); @@ -1466,7 +1638,7 @@ polygonSuite.AddTest ('PolygonTest', function (test) polygonSuite.AddTest ('ContourPolygon2DTest', function (test) { - var polygon = new JSM.ContourPolygon2D (); + var polygon = new JSM.OldContourPolygon2D (); test.Assert (polygon.ContourCount () == 0); test.Assert (polygon.VertexCount (0) == 0); test.Assert (polygon.VertexCount (1) == 0); @@ -1525,7 +1697,7 @@ polygonSuite.AddTest ('ContourPolygon2DTest', function (test) polygonSuite.AddTest ('CoordPolygonPosition2DTest', function (test) { - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 2.0); polygon.AddVertex (0.0, 1.0); polygon.AddVertex (1.0, 1.0); @@ -1583,7 +1755,7 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) return result; } - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (3.0, 0.0); polygon.AddVertex (3.0, 2.0); @@ -1621,7 +1793,7 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 2, 2), 6, -1) == true); test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 2, 2), 6, 3) == false); - var polygon2 = new JSM.Polygon2D (); + var polygon2 = new JSM.OldPolygon2D (); polygon2.AddVertex (118, 121); polygon2.AddVertex (244, 89); polygon2.AddVertex (188, 222); @@ -1634,7 +1806,7 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (JSM.IsPolygonVertexVisible2D (polygon2, 1, 4) == false); - var polygon3 = new JSM.Polygon2D (); + var polygon3 = new JSM.OldPolygon2D (); polygon3.AddVertex (1, 0); polygon3.AddVertex (2, 0); polygon3.AddVertex (2, 1); @@ -1660,7 +1832,7 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (GetVisibleVertices (polygon3, 10).toString () == [4, 5, 8].toString ()); test.Assert (GetVisibleVertices (polygon3, 11).toString () == [1, 2, 4, 5, 6, 8, 9].toString ()); - var polygon4 = new JSM.Polygon2D (); + var polygon4 = new JSM.OldPolygon2D (); polygon4.AddVertex (0, 0); polygon4.AddVertex (3, 0); polygon4.AddVertex (3, 3); @@ -1672,7 +1844,7 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) { - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (3.0, 0.0); polygon.AddVertex (3.0, 2.0); @@ -1686,7 +1858,7 @@ polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) test.Assert (triangles[1].toString () == [0, 2, 3].toString ()); test.Assert (triangles[2].toString () == [0, 3, 4].toString ()); - var polygon2 = new JSM.Polygon2D (); + var polygon2 = new JSM.OldPolygon2D (); polygon2.AddVertex (0.0, 0.0); polygon2.AddVertex (3.0, 0.0); polygon2.AddVertex (3.0, 2.0); @@ -1706,7 +1878,7 @@ polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) test.Assert (triangles[4].toString () == [6, 0, 5].toString ()); test.Assert (triangles[5].toString () == [0, 6, 7].toString ()); - var polygon2cw = new JSM.Polygon2D (); + var polygon2cw = new JSM.OldPolygon2D (); polygon2cw.AddVertex (0.0, 0.0); polygon2cw.AddVertex (0.0, 2.0); polygon2cw.AddVertex (1.0, 2.0); @@ -1726,7 +1898,7 @@ polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) test.Assert (triangles[4].toString () == [1, 3, 0].toString ()); test.Assert (triangles[5].toString () == [7, 0, 3].toString ()); - var polygon3 = new JSM.Polygon2D (); + var polygon3 = new JSM.OldPolygon2D (); polygon3.AddVertex (0.0, 0.0); polygon3.AddVertex (5.0, 0.0); polygon3.AddVertex (5.0, 1.0); @@ -1758,7 +1930,7 @@ polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) test.Assert (triangles[10].toString () == [8, 10, 7].toString ()); test.Assert (triangles[11].toString () == [10, 8, 9].toString ()); - var polygon4 = new JSM.Polygon2D (); + var polygon4 = new JSM.OldPolygon2D (); polygon4.AddVertex (52, 221); polygon4.AddVertex (101, 89); polygon4.AddVertex (244, 89); @@ -1776,7 +1948,7 @@ polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) test.Assert (JSM.CheckTriangulation2D (polygon4, triangles)); test.Assert (triangles.length == 10); - var polygon5 = new JSM.Polygon2D (); + var polygon5 = new JSM.OldPolygon2D (); polygon5.AddVertex (1, 0); polygon5.AddVertex (2, 0); polygon5.AddVertex (2, 1); @@ -1852,7 +2024,7 @@ polygonSuite.AddTest ('PolygonOffsetTest', function (test) polygonSuite.AddTest ('PolygonWithHole2DTest', function (test) { - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); polygon.AddVertex (0, 0); polygon.AddVertex (3, 0); polygon.AddVertex (3, 3); @@ -1894,7 +2066,7 @@ polygonSuite.AddTest ('PolygonWithHole2DTest', function (test) test.Assert (triangles[6].toString () == [6, 3, 5].toString ()); test.Assert (triangles[7].toString () == [3, 6, 7].toString ()); - var polygon2 = new JSM.Polygon2D (); + var polygon2 = new JSM.OldPolygon2D (); polygon2.AddVertex (0, 0); polygon2.AddVertex (6, 0); polygon2.AddVertex (6, 3); @@ -1932,7 +2104,7 @@ polygonSuite.AddTest ('PolygonWithHole2DTest', function (test) test.Assert (triangles[12].toString () == [9, 11, 6].toString ()); test.Assert (triangles[13].toString () == [11, 9, 10].toString ()); - var polygon3 = new JSM.Polygon2D (); + var polygon3 = new JSM.OldPolygon2D (); polygon3.AddVertex (0, 0); polygon3.AddVertex (5, 0); polygon3.AddVertex (2.5, 5); @@ -1959,7 +2131,7 @@ polygonSuite.AddTest ('CreatePolygonWithHole2DTest', function (test) { function CreatePolygon2D (vertices, indices) { - var result = new JSM.Polygon2D (); + var result = new JSM.OldPolygon2D (); var i, vertex; for (i = 0; i < indices.length; i++) { @@ -2218,7 +2390,7 @@ polygonSuite.AddTest ('TriangulationWithHole2DTest', function (test) { if (polygonIndices.toString () != refIndices.toString ()) { return false; } - var polygon = new JSM.Polygon2D (); + var polygon = new JSM.OldPolygon2D (); var i, vertex; for (i = 0; i < polygonIndices.length; i++) { vertex = basePolygon[polygonIndices[i]]; diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js new file mode 100644 index 00000000..f1c9f26f --- /dev/null +++ b/test/unittest/tests/polygon.js @@ -0,0 +1,1274 @@ +module.exports = function (unitTest) +{ + +var simpleSuite = unitTest.AddTestSuite ('PolygonTest'); + +simpleSuite.AddTest ('AddVertexTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + test.AssertEqual (polygon.VertexCount (), 3); + test.AssertEqual (polygon.GetVertex (0).x, 0.0); + test.AssertEqual (polygon.GetVertex (0).y, 0.0); + test.AssertEqual (polygon.GetVertex (1).x, 1.0); + test.AssertEqual (polygon.GetVertex (1).y, 0.0); + test.AssertEqual (polygon.GetVertex (2).x, 1.0); + test.AssertEqual (polygon.GetVertex (2).y, 1.0); + + polygon.Clear (); + test.AssertEqual (polygon.VertexCount (), 0); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertexCoord (new JSM.Coord2D (0.0, 0.0)); + polygon2.AddVertexCoord (new JSM.Coord2D (1.0, 0.0)); + polygon2.AddVertexCoord (new JSM.Coord2D (1.0, 1.0)); + test.AssertEqual (polygon2.VertexCount (), 3); + test.AssertEqual (polygon2.GetVertex (0).x, 0.0); + test.AssertEqual (polygon2.GetVertex (0).y, 0.0); + test.AssertEqual (polygon2.GetVertex (1).x, 1.0); + test.AssertEqual (polygon2.GetVertex (1).y, 0.0); + test.AssertEqual (polygon2.GetVertex (2).x, 1.0); + test.AssertEqual (polygon2.GetVertex (2).y, 1.0); +}); + +simpleSuite.AddTest ('CloneTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + + var cloned = polygon.Clone (); + test.AssertEqual (polygon.VertexCount (), cloned.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), cloned.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), cloned.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), cloned.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), cloned.GetComplexity ()); +}); + +simpleSuite.AddTest ('ShiftVerticesTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + + var vertex0 = new JSM.Coord2D (0.0, 0.0); + var vertex1 = new JSM.Coord2D (1.0, 0.0); + var vertex2 = new JSM.Coord2D (1.0, 1.0); + var vertex3 = new JSM.Coord2D (0.0, 1.0); + + polygon.AddVertexCoord (vertex0.Clone ()); + polygon.AddVertexCoord (vertex1.Clone ()); + polygon.AddVertexCoord (vertex2.Clone ()); + polygon.AddVertexCoord (vertex3.Clone ()); + + test.Assert (polygon.GetVertex (0).IsEqual (vertex0)); + test.Assert (polygon.GetVertex (1).IsEqual (vertex1)); + test.Assert (polygon.GetVertex (2).IsEqual (vertex2)); + test.Assert (polygon.GetVertex (3).IsEqual (vertex3)); + + polygon.ShiftVertices (1); + test.Assert (polygon.GetVertex (0).IsEqual (vertex1)); + test.Assert (polygon.GetVertex (1).IsEqual (vertex2)); + test.Assert (polygon.GetVertex (2).IsEqual (vertex3)); + test.Assert (polygon.GetVertex (3).IsEqual (vertex0)); + + polygon.ShiftVertices (2); + test.Assert (polygon.GetVertex (0).IsEqual (vertex3)); + test.Assert (polygon.GetVertex (1).IsEqual (vertex0)); + test.Assert (polygon.GetVertex (2).IsEqual (vertex1)); + test.Assert (polygon.GetVertex (3).IsEqual (vertex2)); + + polygon.ShiftVertices (3); + test.Assert (polygon.GetVertex (0).IsEqual (vertex2)); + test.Assert (polygon.GetVertex (1).IsEqual (vertex3)); + test.Assert (polygon.GetVertex (2).IsEqual (vertex0)); + test.Assert (polygon.GetVertex (3).IsEqual (vertex1)); +}); + +simpleSuite.AddTest ('EnumerateVerticesTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.5, 0.5); + polygon.AddVertex (0.0, 1.0); + + var vertices; + + vertices = []; + polygon.EnumerateVertices (0, 4, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [0, 1, 2, 3, 4].toString ()); + + vertices = []; + polygon.EnumerateVertices (0, 0, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [0].toString ()); + + vertices = []; + polygon.EnumerateVertices (0, 1, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [0, 1].toString ()); + + vertices = []; + polygon.EnumerateVertices (1, 0, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [1, 2, 3, 4, 0].toString ()); + + vertices = []; + polygon.EnumerateVertices (4, 0, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [4, 0].toString ()); + + vertices = []; + polygon.EnumerateVertices (3, 2, function (index) { + vertices.push (index); + }); + test.AssertEqual (vertices.toString (), [3, 4, 0, 1, 2].toString ()); + + test.AssertEqual (polygon.GetNextVertex (0), 1); + test.AssertEqual (polygon.GetNextVertex (1), 2); + test.AssertEqual (polygon.GetNextVertex (2), 3); + test.AssertEqual (polygon.GetNextVertex (3), 4); + test.AssertEqual (polygon.GetNextVertex (4), 0); + + test.AssertEqual (polygon.GetPrevVertex (0), 4); + test.AssertEqual (polygon.GetPrevVertex (1), 0); + test.AssertEqual (polygon.GetPrevVertex (2), 1); + test.AssertEqual (polygon.GetPrevVertex (3), 2); + test.AssertEqual (polygon.GetPrevVertex (4), 3); +}); + +simpleSuite.AddTest ('InvalidPolygonTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (0.0, 0.0); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + test.AssertEqual (polygon.GetVertexOrientation (0), JSM.Orientation.Invalid); + + polygon.AddVertex (1.0, 0.0); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + test.AssertEqual (polygon.GetVertexOrientation (1), JSM.Orientation.Invalid); + + polygon.AddVertex (2.0, 0.0); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + test.AssertEqual (polygon.GetVertexOrientation (2), JSM.Orientation.Invalid); +}); + +simpleSuite.AddTest ('ValidTriangleTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + + test.AssertEqualNum (polygon.GetSignedArea (), 0.5, JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), 0.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + test.AssertEqual (polygon.GetVertexOrientation (0), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetVertexOrientation (1), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetVertexOrientation (2), JSM.Orientation.CounterClockwise); + + test.AssertEqualNum (polygon2.GetSignedArea (), -0.5, JSM.Eps); + test.AssertEqualNum (polygon2.GetArea (), 0.5, JSM.Eps); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + test.AssertEqual (polygon2.GetVertexOrientation (0), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetVertexOrientation (1), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetVertexOrientation (2), JSM.Orientation.Clockwise); +}); + +simpleSuite.AddTest ('VertexOrientationTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.8, 0.2); + + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave); + test.AssertEqual (polygon.GetVertexOrientation (0), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetVertexOrientation (1), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetVertexOrientation (2), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetVertexOrientation (3), JSM.Orientation.Clockwise); + test.AssertEqual (polygon.IsConvexVertex (0), true); + test.AssertEqual (polygon.IsConvexVertex (1), true); + test.AssertEqual (polygon.IsConvexVertex (2), true); + test.AssertEqual (polygon.IsConvexVertex (3), false); + test.AssertEqual (polygon.IsConcaveVertex (0), false); + test.AssertEqual (polygon.IsConcaveVertex (1), false); + test.AssertEqual (polygon.IsConcaveVertex (2), false); + test.AssertEqual (polygon.IsConcaveVertex (3), true); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (0.8, 0.2); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Concave); + test.AssertEqual (polygon2.GetVertexOrientation (0), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetVertexOrientation (1), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon2.GetVertexOrientation (2), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetVertexOrientation (3), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.IsConvexVertex (0), true); + test.AssertEqual (polygon2.IsConvexVertex (1), false); + test.AssertEqual (polygon2.IsConvexVertex (2), true); + test.AssertEqual (polygon2.IsConvexVertex (3), true); + test.AssertEqual (polygon2.IsConcaveVertex (0), false); + test.AssertEqual (polygon2.IsConcaveVertex (1), true); + test.AssertEqual (polygon2.IsConcaveVertex (2), false); + test.AssertEqual (polygon2.IsConcaveVertex (3), false); + + var polygon3 = new JSM.Polygon2D (); + polygon3.AddVertex (0.0, 0.0); + polygon3.AddVertex (1.0, 0.0); + polygon3.AddVertex (2.0, 0.0); + polygon3.AddVertex (2.0, 1.0); + polygon3.AddVertex (1.8, 0.2); + + test.AssertEqual (polygon3.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon3.GetComplexity (), JSM.Complexity.Concave); + test.AssertEqual (polygon3.GetVertexOrientation (0), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon3.GetVertexOrientation (1), JSM.Orientation.Invalid); + test.AssertEqual (polygon3.GetVertexOrientation (2), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon3.GetVertexOrientation (3), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon3.GetVertexOrientation (4), JSM.Orientation.Clockwise); + test.AssertEqual (polygon3.IsConvexVertex (0), true); + test.AssertEqual (polygon3.IsConvexVertex (1), false); + test.AssertEqual (polygon3.IsConvexVertex (2), true); + test.AssertEqual (polygon3.IsConvexVertex (3), true); + test.AssertEqual (polygon3.IsConvexVertex (4), false); + test.AssertEqual (polygon3.IsConcaveVertex (0), false); + test.AssertEqual (polygon3.IsConcaveVertex (1), false); + test.AssertEqual (polygon3.IsConcaveVertex (2), false); + test.AssertEqual (polygon3.IsConcaveVertex (3), false); + test.AssertEqual (polygon3.IsConcaveVertex (4), true); +}); + +simpleSuite.AddTest ('ComplexityTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (0.0, 1.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + + test.AssertEqualNum (polygon.GetArea (), 1.0, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + test.AssertEqualNum (polygon2.GetArea (), 1.0, JSM.Eps); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + + polygon.AddVertex (-0.5, 0.5); + polygon2.AddVertex (0.5, -0.5); + + test.AssertEqualNum (polygon.GetArea (), 1.25, JSM.Eps); + test.AssertEqualNum (polygon2.GetArea (), 1.25, JSM.Eps); + + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + + polygon.AddVertex (0.5, 0.5); + polygon2.AddVertex (0.5, 0.5); + + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave); + + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Concave); + + var polygon3 = new JSM.Polygon2D (); + polygon3.AddVertex (0.0, 0.0); + polygon3.AddVertex (1.0, 0.0); + polygon3.AddVertex (1.0, 1.0); + polygon3.AddVertex (0.5, 0.5); + + test.AssertEqualNum (polygon3.GetArea (), 0.5, JSM.Eps); + test.AssertEqual (polygon3.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon3.GetComplexity (), JSM.Complexity.Convex); + + var polygon4 = new JSM.Polygon2D (); + polygon4.AddVertex (0.0, 0.0); + polygon4.AddVertex (1.0, 0.0); + polygon4.AddVertex (0.0, 1.0); + polygon4.AddVertex (-1.0, 0.0); + + test.AssertEqualNum (polygon4.GetArea (), 1.0, JSM.Eps); + test.AssertEqual (polygon4.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon4.GetComplexity (), JSM.Complexity.Convex); + + var polygon5 = new JSM.Polygon2D (); + polygon5.AddVertex (0.0, 0.0); + polygon5.AddVertex (1.0, 0.0); + polygon5.AddVertex (1.0, 1.0); + polygon5.AddVertex (0.6, 0.5); + + test.AssertEqualNum (polygon5.GetArea (), 0.45, JSM.Eps); + test.AssertEqual (polygon5.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon5.GetComplexity (), JSM.Complexity.Concave); + + var polygon6 = new JSM.Polygon2D (); + polygon6.AddVertex (0.0, 0.0); + polygon6.AddVertex (1.0, 0.0); + polygon6.AddVertex (2.0, 0.0); + polygon6.AddVertex (3.0, 0.0); + polygon6.AddVertex (3.0, 1.0); + + test.AssertEqualNum (polygon6.GetArea (), 1.5, JSM.Eps); + test.AssertEqual (polygon6.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon6.GetComplexity (), JSM.Complexity.Convex); +}); + +simpleSuite.AddTest ('JsonTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + var polygon2 = new JSM.Polygon2D (); + polygon2.FromJson (polygon.ToJson ()); + + test.AssertEqualNum (polygon.GetArea (), polygon2.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), polygon2.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), polygon2.GetComplexity ()); +}); + +var pointInPolygonSuite = unitTest.AddTestSuite ('PointInPolygonTest'); + +pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (2.0, 0.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (0.0, 2.0); + + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 0.0)), JSM.PointPosition.OnVertex); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 0.0)), JSM.PointPosition.OnVertex); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 2.0)), JSM.PointPosition.OnVertex); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 2.0)), JSM.PointPosition.OnVertex); + + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 0.0)), JSM.PointPosition.OnEdge); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 1.0)), JSM.PointPosition.OnEdge); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 2.0)), JSM.PointPosition.OnEdge); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 1.0)), JSM.PointPosition.OnEdge); + + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 1.0)), JSM.PointPosition.Inside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 1.0)), JSM.PointPosition.Outside); + + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 0.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 2.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 3.0)), JSM.PointPosition.Outside); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (0.0, 2.0); + polygon2.AddVertex (-1.0, 1.0); + + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.0, 1.0)), JSM.PointPosition.Inside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (2.0, 1.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.5, 0.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.5, 2.0)), JSM.PointPosition.Outside); +}); + +var diagonalSuite = unitTest.AddTestSuite ('IsDiagonalSuite'); + +diagonalSuite.AddTest ('IsDiagonalTest01', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (2.0, 0.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + test.AssertEqualNum (polygon.GetArea (), 3.0, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + test.AssertEqual (polygon.IsDiagonal (0, 4), true); + test.AssertEqual (polygon.IsDiagonal (0, 5), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + test.AssertEqual (polygon.IsDiagonal (1, 4), true); + test.AssertEqual (polygon.IsDiagonal (1, 5), true); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + test.AssertEqual (polygon.IsDiagonal (2, 4), true); + test.AssertEqual (polygon.IsDiagonal (2, 5), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); + test.AssertEqual (polygon.IsDiagonal (3, 4), false); + test.AssertEqual (polygon.IsDiagonal (3, 5), false); + + test.AssertEqual (polygon.IsDiagonal (4, 0), true); + test.AssertEqual (polygon.IsDiagonal (4, 1), true); + test.AssertEqual (polygon.IsDiagonal (4, 2), true); + test.AssertEqual (polygon.IsDiagonal (4, 3), false); + test.AssertEqual (polygon.IsDiagonal (4, 4), false); + test.AssertEqual (polygon.IsDiagonal (4, 5), false); + + test.AssertEqual (polygon.IsDiagonal (5, 0), false); + test.AssertEqual (polygon.IsDiagonal (5, 1), true); + test.AssertEqual (polygon.IsDiagonal (5, 2), false); + test.AssertEqual (polygon.IsDiagonal (5, 3), false); + test.AssertEqual (polygon.IsDiagonal (5, 4), false); + test.AssertEqual (polygon.IsDiagonal (5, 5), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest02', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.2, 0.2); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); + + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.8, 0.2); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest03', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (2.0, 0.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 0.1); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest04', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (0.0, 2.0); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + test.AssertEqual (polygon.IsDiagonal (0, 4), true); + test.AssertEqual (polygon.IsDiagonal (0, 5), true); + test.AssertEqual (polygon.IsDiagonal (0, 6), false); + test.AssertEqual (polygon.IsDiagonal (0, 7), false); + test.AssertEqual (polygon.IsDiagonal (0, 8), true); + test.AssertEqual (polygon.IsDiagonal (0, 9), true); + test.AssertEqual (polygon.IsDiagonal (0, 10), true); + test.AssertEqual (polygon.IsDiagonal (0, 11), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + test.AssertEqual (polygon.IsDiagonal (1, 4), true); + test.AssertEqual (polygon.IsDiagonal (1, 5), true); + test.AssertEqual (polygon.IsDiagonal (1, 6), false); + test.AssertEqual (polygon.IsDiagonal (1, 7), false); + test.AssertEqual (polygon.IsDiagonal (1, 8), true); + test.AssertEqual (polygon.IsDiagonal (1, 9), true); + test.AssertEqual (polygon.IsDiagonal (1, 10), false); + test.AssertEqual (polygon.IsDiagonal (1, 11), false); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + test.AssertEqual (polygon.IsDiagonal (2, 4), true); + test.AssertEqual (polygon.IsDiagonal (2, 5), false); + test.AssertEqual (polygon.IsDiagonal (2, 6), false); + test.AssertEqual (polygon.IsDiagonal (2, 7), false); + test.AssertEqual (polygon.IsDiagonal (2, 8), false); + test.AssertEqual (polygon.IsDiagonal (2, 9), false); + test.AssertEqual (polygon.IsDiagonal (2, 10), false); + test.AssertEqual (polygon.IsDiagonal (2, 11), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); + test.AssertEqual (polygon.IsDiagonal (3, 4), false); + test.AssertEqual (polygon.IsDiagonal (3, 5), false); + test.AssertEqual (polygon.IsDiagonal (3, 6), false); + test.AssertEqual (polygon.IsDiagonal (3, 7), false); + test.AssertEqual (polygon.IsDiagonal (3, 8), false); + test.AssertEqual (polygon.IsDiagonal (3, 9), false); + test.AssertEqual (polygon.IsDiagonal (3, 10), false); + test.AssertEqual (polygon.IsDiagonal (3, 11), false); + + test.AssertEqual (polygon.IsDiagonal (4, 0), true); + test.AssertEqual (polygon.IsDiagonal (4, 1), true); + test.AssertEqual (polygon.IsDiagonal (4, 2), true); + test.AssertEqual (polygon.IsDiagonal (4, 3), false); + test.AssertEqual (polygon.IsDiagonal (4, 4), false); + test.AssertEqual (polygon.IsDiagonal (4, 5), false); + test.AssertEqual (polygon.IsDiagonal (4, 6), false); + test.AssertEqual (polygon.IsDiagonal (4, 7), false); + test.AssertEqual (polygon.IsDiagonal (4, 8), false); + test.AssertEqual (polygon.IsDiagonal (4, 9), false); + test.AssertEqual (polygon.IsDiagonal (4, 10), false); + test.AssertEqual (polygon.IsDiagonal (4, 11), false); + + test.AssertEqual (polygon.IsDiagonal (5, 0), true); + test.AssertEqual (polygon.IsDiagonal (5, 1), true); + test.AssertEqual (polygon.IsDiagonal (5, 2), false); + test.AssertEqual (polygon.IsDiagonal (5, 3), false); + test.AssertEqual (polygon.IsDiagonal (5, 4), false); + test.AssertEqual (polygon.IsDiagonal (5, 5), false); + test.AssertEqual (polygon.IsDiagonal (5, 6), false); + test.AssertEqual (polygon.IsDiagonal (5, 7), true); + test.AssertEqual (polygon.IsDiagonal (5, 8), true); + test.AssertEqual (polygon.IsDiagonal (5, 9), false); + test.AssertEqual (polygon.IsDiagonal (5, 10), false); + test.AssertEqual (polygon.IsDiagonal (5, 11), false); + + test.AssertEqual (polygon.IsDiagonal (6, 0), false); + test.AssertEqual (polygon.IsDiagonal (6, 1), false); + test.AssertEqual (polygon.IsDiagonal (6, 2), false); + test.AssertEqual (polygon.IsDiagonal (6, 3), false); + test.AssertEqual (polygon.IsDiagonal (6, 4), false); + test.AssertEqual (polygon.IsDiagonal (6, 5), false); + test.AssertEqual (polygon.IsDiagonal (6, 6), false); + test.AssertEqual (polygon.IsDiagonal (6, 7), false); + test.AssertEqual (polygon.IsDiagonal (6, 8), true); + test.AssertEqual (polygon.IsDiagonal (6, 9), false); + test.AssertEqual (polygon.IsDiagonal (6, 10), false); + test.AssertEqual (polygon.IsDiagonal (6, 11), false); + + test.AssertEqual (polygon.IsDiagonal (7, 0), false); + test.AssertEqual (polygon.IsDiagonal (7, 1), false); + test.AssertEqual (polygon.IsDiagonal (7, 2), false); + test.AssertEqual (polygon.IsDiagonal (7, 3), false); + test.AssertEqual (polygon.IsDiagonal (7, 4), false); + test.AssertEqual (polygon.IsDiagonal (7, 5), true); + test.AssertEqual (polygon.IsDiagonal (7, 6), false); + test.AssertEqual (polygon.IsDiagonal (7, 7), false); + test.AssertEqual (polygon.IsDiagonal (7, 8), false); + test.AssertEqual (polygon.IsDiagonal (7, 9), false); + test.AssertEqual (polygon.IsDiagonal (7, 10), false); + test.AssertEqual (polygon.IsDiagonal (7, 11), false); + + test.AssertEqual (polygon.IsDiagonal (8, 0), true); + test.AssertEqual (polygon.IsDiagonal (8, 1), true); + test.AssertEqual (polygon.IsDiagonal (8, 2), false); + test.AssertEqual (polygon.IsDiagonal (8, 3), false); + test.AssertEqual (polygon.IsDiagonal (8, 4), false); + test.AssertEqual (polygon.IsDiagonal (8, 5), true); + test.AssertEqual (polygon.IsDiagonal (8, 6), true); + test.AssertEqual (polygon.IsDiagonal (8, 7), false); + test.AssertEqual (polygon.IsDiagonal (8, 8), false); + test.AssertEqual (polygon.IsDiagonal (8, 9), false); + test.AssertEqual (polygon.IsDiagonal (8, 10), false); + test.AssertEqual (polygon.IsDiagonal (8, 11), false); + + test.AssertEqual (polygon.IsDiagonal (9, 0), true); + test.AssertEqual (polygon.IsDiagonal (9, 1), true); + test.AssertEqual (polygon.IsDiagonal (9, 2), false); + test.AssertEqual (polygon.IsDiagonal (9, 3), false); + test.AssertEqual (polygon.IsDiagonal (9, 4), false); + test.AssertEqual (polygon.IsDiagonal (9, 5), false); + test.AssertEqual (polygon.IsDiagonal (9, 6), false); + test.AssertEqual (polygon.IsDiagonal (9, 7), false); + test.AssertEqual (polygon.IsDiagonal (9, 8), false); + test.AssertEqual (polygon.IsDiagonal (9, 9), false); + test.AssertEqual (polygon.IsDiagonal (9, 10), false); + test.AssertEqual (polygon.IsDiagonal (9, 11), true); + + test.AssertEqual (polygon.IsDiagonal (10, 0), true); + test.AssertEqual (polygon.IsDiagonal (10, 1), false); + test.AssertEqual (polygon.IsDiagonal (10, 2), false); + test.AssertEqual (polygon.IsDiagonal (10, 3), false); + test.AssertEqual (polygon.IsDiagonal (10, 4), false); + test.AssertEqual (polygon.IsDiagonal (10, 5), false); + test.AssertEqual (polygon.IsDiagonal (10, 6), false); + test.AssertEqual (polygon.IsDiagonal (10, 7), false); + test.AssertEqual (polygon.IsDiagonal (10, 8), false); + test.AssertEqual (polygon.IsDiagonal (10, 9), false); + test.AssertEqual (polygon.IsDiagonal (10, 10), false); + test.AssertEqual (polygon.IsDiagonal (10, 11), false); + + test.AssertEqual (polygon.IsDiagonal (11, 0), false); + test.AssertEqual (polygon.IsDiagonal (11, 1), false); + test.AssertEqual (polygon.IsDiagonal (11, 2), false); + test.AssertEqual (polygon.IsDiagonal (11, 3), false); + test.AssertEqual (polygon.IsDiagonal (11, 4), false); + test.AssertEqual (polygon.IsDiagonal (11, 5), false); + test.AssertEqual (polygon.IsDiagonal (11, 6), false); + test.AssertEqual (polygon.IsDiagonal (11, 7), false); + test.AssertEqual (polygon.IsDiagonal (11, 8), false); + test.AssertEqual (polygon.IsDiagonal (11, 9), true); + test.AssertEqual (polygon.IsDiagonal (11, 10), false); + test.AssertEqual (polygon.IsDiagonal (11, 11), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest05', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 5.0); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (3.0, 1.0); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + test.AssertEqual (polygon.IsDiagonal (0, 4), false); + test.AssertEqual (polygon.IsDiagonal (0, 5), false); + test.AssertEqual (polygon.IsDiagonal (0, 6), false); + test.AssertEqual (polygon.IsDiagonal (0, 7), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), false); + test.AssertEqual (polygon.IsDiagonal (1, 4), false); + test.AssertEqual (polygon.IsDiagonal (1, 5), false); + test.AssertEqual (polygon.IsDiagonal (1, 6), true); + test.AssertEqual (polygon.IsDiagonal (1, 7), false); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + test.AssertEqual (polygon.IsDiagonal (2, 4), false); + test.AssertEqual (polygon.IsDiagonal (2, 5), true); + test.AssertEqual (polygon.IsDiagonal (2, 6), true); + test.AssertEqual (polygon.IsDiagonal (2, 7), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), false); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); + test.AssertEqual (polygon.IsDiagonal (3, 4), false); + test.AssertEqual (polygon.IsDiagonal (3, 5), false); + test.AssertEqual (polygon.IsDiagonal (3, 6), false); + test.AssertEqual (polygon.IsDiagonal (3, 7), false); + + test.AssertEqual (polygon.IsDiagonal (4, 0), false); + test.AssertEqual (polygon.IsDiagonal (4, 1), false); + test.AssertEqual (polygon.IsDiagonal (4, 2), false); + test.AssertEqual (polygon.IsDiagonal (4, 3), false); + test.AssertEqual (polygon.IsDiagonal (4, 4), false); + test.AssertEqual (polygon.IsDiagonal (4, 5), false); + test.AssertEqual (polygon.IsDiagonal (4, 6), false); + test.AssertEqual (polygon.IsDiagonal (4, 7), false); + + test.AssertEqual (polygon.IsDiagonal (5, 0), false); + test.AssertEqual (polygon.IsDiagonal (5, 1), false); + test.AssertEqual (polygon.IsDiagonal (5, 2), true); + test.AssertEqual (polygon.IsDiagonal (5, 3), false); + test.AssertEqual (polygon.IsDiagonal (5, 4), false); + test.AssertEqual (polygon.IsDiagonal (5, 5), false); + test.AssertEqual (polygon.IsDiagonal (5, 6), false); + test.AssertEqual (polygon.IsDiagonal (5, 7), false); + + test.AssertEqual (polygon.IsDiagonal (6, 0), false); + test.AssertEqual (polygon.IsDiagonal (6, 1), true); + test.AssertEqual (polygon.IsDiagonal (6, 2), true); + test.AssertEqual (polygon.IsDiagonal (6, 3), false); + test.AssertEqual (polygon.IsDiagonal (6, 4), false); + test.AssertEqual (polygon.IsDiagonal (6, 5), false); + test.AssertEqual (polygon.IsDiagonal (6, 6), false); + test.AssertEqual (polygon.IsDiagonal (6, 7), false); + + test.AssertEqual (polygon.IsDiagonal (7, 0), false); + test.AssertEqual (polygon.IsDiagonal (7, 1), false); + test.AssertEqual (polygon.IsDiagonal (7, 2), false); + test.AssertEqual (polygon.IsDiagonal (7, 3), false); + test.AssertEqual (polygon.IsDiagonal (7, 4), false); + test.AssertEqual (polygon.IsDiagonal (7, 5), false); + test.AssertEqual (polygon.IsDiagonal (7, 6), false); + test.AssertEqual (polygon.IsDiagonal (7, 7), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest06', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (2.0, 0.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 0.1); + polygon.AddVertex (0.0, 1.0); + + test.AssertEqual (polygon.IsDiagonal (0, 0), false); + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); + test.AssertEqual (polygon.IsDiagonal (0, 3), false); + test.AssertEqual (polygon.IsDiagonal (0, 4), true); + test.AssertEqual (polygon.IsDiagonal (0, 5), false); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + test.AssertEqual (polygon.IsDiagonal (1, 4), true); + test.AssertEqual (polygon.IsDiagonal (1, 5), true); + + test.AssertEqual (polygon.IsDiagonal (2, 0), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 2), false); + test.AssertEqual (polygon.IsDiagonal (2, 3), false); + test.AssertEqual (polygon.IsDiagonal (2, 4), true); + test.AssertEqual (polygon.IsDiagonal (2, 5), false); + + test.AssertEqual (polygon.IsDiagonal (3, 0), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (3, 2), false); + test.AssertEqual (polygon.IsDiagonal (3, 3), false); + test.AssertEqual (polygon.IsDiagonal (3, 4), false); + test.AssertEqual (polygon.IsDiagonal (3, 5), false); + + test.AssertEqual (polygon.IsDiagonal (4, 0), true); + test.AssertEqual (polygon.IsDiagonal (4, 1), true); + test.AssertEqual (polygon.IsDiagonal (4, 2), true); + test.AssertEqual (polygon.IsDiagonal (4, 3), false); + test.AssertEqual (polygon.IsDiagonal (4, 4), false); + test.AssertEqual (polygon.IsDiagonal (4, 5), false); + + test.AssertEqual (polygon.IsDiagonal (5, 0), false); + test.AssertEqual (polygon.IsDiagonal (5, 1), true); + test.AssertEqual (polygon.IsDiagonal (5, 2), false); + test.AssertEqual (polygon.IsDiagonal (5, 3), false); + test.AssertEqual (polygon.IsDiagonal (5, 4), false); + test.AssertEqual (polygon.IsDiagonal (5, 5), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest08', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.2, 0.2); + test.AssertEqual (polygon.IsDiagonal (0, 2), false); +}); + +diagonalSuite.AddTest ('IsDiagonalTest07', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (0.0, 1.0); + + test.AssertEqual (polygon.IsDiagonal (1, 0), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 2), false); + test.AssertEqual (polygon.IsDiagonal (1, 3), true); + test.AssertEqual (polygon.IsDiagonal (1, 4), false); + test.AssertEqual (polygon.IsDiagonal (1, 5), false); + test.AssertEqual (polygon.IsDiagonal (1, 6), true); + + test.AssertEqual (polygon.IsDiagonal (0, 1), false); + test.AssertEqual (polygon.IsDiagonal (1, 1), false); + test.AssertEqual (polygon.IsDiagonal (2, 1), false); + test.AssertEqual (polygon.IsDiagonal (3, 1), true); + test.AssertEqual (polygon.IsDiagonal (4, 1), false); + test.AssertEqual (polygon.IsDiagonal (5, 1), false); + test.AssertEqual (polygon.IsDiagonal (6, 1), true); +}); + +var polygonSectorTest = unitTest.AddTestSuite ('PolygonSectorPositionTest'); + +polygonSectorTest.AddTest ('PolygonSectorPositionTest01', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (3, 0), -1, -1), JSM.SectorPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (2, 1), -1, -1), JSM.SectorPosition.NoIntersection); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (2, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (2, 2), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 2), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (2, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0.5), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (-1.0, 0.5), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (-1.0, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); +}); + +polygonSectorTest.AddTest ('PolygonSectorPositionTest02', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0.5), 0, -1), JSM.SectorPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (0, 0), 0, -1), JSM.SectorPosition.NoIntersection); + + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, 1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, 1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, 2), JSM.SectorPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, 2), JSM.SectorPosition.NoIntersection); +}); + +var polygonSuite = unitTest.AddTestSuite ('ContourPolygonTest'); + +polygonSuite.AddTest ('AddVertexTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 3.0); + polygon.AddVertex (0.0, 3.0); + test.AssertEqual (polygon.ContourCount (), 1); + test.AssertEqual (polygon.VertexCount (), 4); + test.AssertEqual (polygon.GetVertex (0).x, 0.0); + test.AssertEqual (polygon.GetVertex (0).y, 0.0); + test.AssertEqual (polygon.GetVertex (1).x, 5.0); + test.AssertEqual (polygon.GetVertex (1).y, 0.0); + test.AssertEqual (polygon.GetVertex (2).x, 5.0); + test.AssertEqual (polygon.GetVertex (2).y, 3.0); + test.AssertEqual (polygon.GetVertex (3).x, 0.0); + test.AssertEqual (polygon.GetVertex (3).y, 3.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + test.AssertEqual (polygon.ContourCount (), 2); + test.AssertEqual (polygon.VertexCount (), 8); + test.AssertEqual (polygon.GetVertex (0).x, 0.0); + test.AssertEqual (polygon.GetVertex (0).y, 0.0); + test.AssertEqual (polygon.GetVertex (1).x, 5.0); + test.AssertEqual (polygon.GetVertex (1).y, 0.0); + test.AssertEqual (polygon.GetVertex (2).x, 5.0); + test.AssertEqual (polygon.GetVertex (2).y, 3.0); + test.AssertEqual (polygon.GetVertex (3).x, 0.0); + test.AssertEqual (polygon.GetVertex (3).y, 3.0); + test.AssertEqual (polygon.GetVertex (4).x, 1.0); + test.AssertEqual (polygon.GetVertex (4).y, 1.0); + test.AssertEqual (polygon.GetVertex (5).x, 1.0); + test.AssertEqual (polygon.GetVertex (5).y, 2.0); + test.AssertEqual (polygon.GetVertex (6).x, 2.0); + test.AssertEqual (polygon.GetVertex (6).y, 2.0); + test.AssertEqual (polygon.GetVertex (7).x, 2.0); + test.AssertEqual (polygon.GetVertex (7).y, 1.0); + + polygon.AddContour (); + polygon.AddVertexCoord (new JSM.Coord2D (3.0, 1.0)); + polygon.AddVertexCoord (new JSM.Coord2D (3.0, 2.0)); + polygon.AddVertexCoord (new JSM.Coord2D (4.0, 2.0)); + polygon.AddVertexCoord (new JSM.Coord2D (4.0, 1.0)); + + test.AssertEqual (polygon.ContourCount (), 3); + test.AssertEqual (polygon.VertexCount (), 12); + + test.AssertEqual (polygon.GetVertex (0).x, 0.0); + test.AssertEqual (polygon.GetVertex (0).y, 0.0); + test.AssertEqual (polygon.GetVertex (1).x, 5.0); + test.AssertEqual (polygon.GetVertex (1).y, 0.0); + test.AssertEqual (polygon.GetVertex (2).x, 5.0); + test.AssertEqual (polygon.GetVertex (2).y, 3.0); + test.AssertEqual (polygon.GetVertex (3).x, 0.0); + test.AssertEqual (polygon.GetVertex (3).y, 3.0); + test.AssertEqual (polygon.GetVertex (4).x, 1.0); + test.AssertEqual (polygon.GetVertex (4).y, 1.0); + test.AssertEqual (polygon.GetVertex (5).x, 1.0); + test.AssertEqual (polygon.GetVertex (5).y, 2.0); + test.AssertEqual (polygon.GetVertex (6).x, 2.0); + test.AssertEqual (polygon.GetVertex (6).y, 2.0); + test.AssertEqual (polygon.GetVertex (7).x, 2.0); + test.AssertEqual (polygon.GetVertex (7).y, 1.0); + test.AssertEqual (polygon.GetVertex (8).x, 3.0); + test.AssertEqual (polygon.GetVertex (8).y, 1.0); + test.AssertEqual (polygon.GetVertex (9).x, 3.0); + test.AssertEqual (polygon.GetVertex (9).y, 2.0); + test.AssertEqual (polygon.GetVertex (10).x, 4.0); + test.AssertEqual (polygon.GetVertex (10).y, 2.0); + test.AssertEqual (polygon.GetVertex (11).x, 4.0); + test.AssertEqual (polygon.GetVertex (11).y, 1.0); + + test.AssertEqual (polygon.GetVertex (0).IsEqual (polygon.GetContourVertex (0, 0)), true); + test.AssertEqual (polygon.GetVertex (1).IsEqual (polygon.GetContourVertex (0, 1)), true); + test.AssertEqual (polygon.GetVertex (2).IsEqual (polygon.GetContourVertex (0, 2)), true); + test.AssertEqual (polygon.GetVertex (3).IsEqual (polygon.GetContourVertex (0, 3)), true); + test.AssertEqual (polygon.GetVertex (4).IsEqual (polygon.GetContourVertex (1, 0)), true); + test.AssertEqual (polygon.GetVertex (5).IsEqual (polygon.GetContourVertex (1, 1)), true); + test.AssertEqual (polygon.GetVertex (6).IsEqual (polygon.GetContourVertex (1, 2)), true); + test.AssertEqual (polygon.GetVertex (7).IsEqual (polygon.GetContourVertex (1, 3)), true); + test.AssertEqual (polygon.GetVertex (8).IsEqual (polygon.GetContourVertex (2, 0)), true); + test.AssertEqual (polygon.GetVertex (9).IsEqual (polygon.GetContourVertex (2, 1)), true); + test.AssertEqual (polygon.GetVertex (10).IsEqual (polygon.GetContourVertex (2, 2)), true); + test.AssertEqual (polygon.GetVertex (11).IsEqual (polygon.GetContourVertex (2, 3)), true); +}); + +polygonSuite.AddTest ('CloneTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 3.0); + polygon.AddVertex (0.0, 3.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + var cloned = polygon.Clone (); + test.AssertEqual (polygon.VertexCount (), cloned.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), cloned.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), cloned.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), cloned.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), cloned.GetComplexity ()); +}); + +polygonSuite.AddTest ('InvalidPolygonTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddContour (); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (0.0, 0.0); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (5.0, 0.0); + test.AssertEqual (polygon.GetSignedArea (), 0.0); + test.AssertEqual (polygon.GetArea (), 0.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (5.0, 3.0); + test.AssertEqual (polygon.GetSignedArea (), 7.5); + test.AssertEqual (polygon.GetArea (), 7.5); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + polygon.AddVertex (0.0, 3.0); + test.AssertEqual (polygon.GetSignedArea (), 15.0); + test.AssertEqual (polygon.GetArea (), 15.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + polygon.AddContour (); + test.AssertEqual (polygon.GetSignedArea (), 15.0); + test.AssertEqual (polygon.GetArea (), 15.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (1.0, 1.0); + test.AssertEqual (polygon.GetSignedArea (), 15.0); + test.AssertEqual (polygon.GetArea (), 15.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (2.0, 1.0); + test.AssertEqual (polygon.GetSignedArea (), 15.0); + test.AssertEqual (polygon.GetArea (), 15.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Invalid); + + polygon.AddVertex (2.0, 2.0); + test.AssertEqual (polygon.GetSignedArea (), 15.5); + test.AssertEqual (polygon.GetArea (), 15.5); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + + polygon.AddVertex (1.0, 2.0); + test.AssertEqual (polygon.GetSignedArea (), 16.0); + test.AssertEqual (polygon.GetArea (), 16.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + + var polygon2 = new JSM.ContourPolygon2D (); + polygon2.AddContour (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (0.0, 3.0); + polygon2.AddVertex (5.0, 3.0); + polygon2.AddVertex (5.0, 0.0); + test.AssertEqual (polygon2.GetSignedArea (), -15.0); + test.AssertEqual (polygon2.GetArea (), 15.0); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + + polygon2.AddContour (); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 2.0); + polygon2.AddVertex (2.0, 2.0); + polygon2.AddVertex (2.0, 1.0); + test.AssertEqual (polygon2.GetSignedArea (), -16.0); + test.AssertEqual (polygon2.GetArea (), 16.0); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Invalid); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Complex); +}); + +polygonSuite.AddTest ('ValidTriangleTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + + var polygon2 = new JSM.ContourPolygon2D (); + polygon2.AddContour (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + + test.AssertEqualNum (polygon.GetSignedArea (), 0.5, JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), 0.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + test.AssertEqualNum (polygon2.GetSignedArea (), -0.5, JSM.Eps); + test.AssertEqualNum (polygon2.GetArea (), 0.5, JSM.Eps); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.Clockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); +}); + +polygonSuite.AddTest ('ComplexityTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + test.AssertEqual (polygon.GetSignedArea (), 20.0); + test.AssertEqual (polygon.GetArea (), 20.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + test.AssertEqual (polygon.GetSignedArea (), 19.0); + test.AssertEqual (polygon.GetArea (), 19.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + + test.AssertEqual (polygon.GetSignedArea (), 18.0); + test.AssertEqual (polygon.GetArea (), 18.0); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + + var polygon2 = new JSM.ContourPolygon2D (); + polygon2.AddContour (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (5.0, 0.0); + polygon2.AddVertex (5.0, 4.0); + polygon2.AddVertex (0.0, 4.0); + + test.AssertEqual (polygon2.GetSignedArea (), 20.0); + test.AssertEqual (polygon2.GetArea (), 20.0); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + + polygon2.AddContour (); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 2.0); + polygon2.AddVertex (2.0, 2.0); + polygon2.AddVertex (2.0, 1.0); + + test.AssertEqual (polygon2.GetSignedArea (), 19.0); + test.AssertEqual (polygon2.GetArea (), 19.0); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Complex); + + polygon2.AddContour (); + polygon2.AddVertex (3.0, 1.0); + polygon2.AddVertex (3.0, 2.0); + polygon2.AddVertex (4.0, 2.0); + polygon2.AddVertex (4.0, 1.0); + + test.AssertEqual (polygon2.GetSignedArea (), 18.0); + test.AssertEqual (polygon2.GetArea (), 18.0); + test.AssertEqual (polygon2.GetOrientation (), JSM.Orientation.CounterClockwise); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Complex); +}); + +} diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js new file mode 100644 index 00000000..da9fc524 --- /dev/null +++ b/test/unittest/tests/triangulation.js @@ -0,0 +1,1758 @@ +module.exports = function (unitTest) +{ + +function CheckCalculatedTriangulation_Exists (polygon, triangles) +{ + if (polygon === null || triangles === null) { + return false; + } + return true; +} + +function CheckCalculatedTriangulation_TriangleCount (polygon, triangles) +{ + if (triangles.length != polygon.VertexCount () - 2) { + return false; + } + return true; +} + +function CheckCalculatedTriangulation_Area (polygon, triangles) +{ + var originalArea = polygon.GetArea (); + var resultArea = 0.0; + + var i, triangle, trianglePoly; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + trianglePoly = new JSM.Polygon2D (); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[0])); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[1])); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[2])); + resultArea += trianglePoly.GetArea (); + } + if (!JSM.IsEqual (originalArea, resultArea)) { + return false; + } + return true; +} + +function CheckCalculatedTriangulation_Orientation (polygon, triangles) +{ + var originalOrientation = polygon.GetOrientation (); + var i, triangle, trianglePoly; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + trianglePoly = new JSM.Polygon2D (); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[0])); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[1])); + trianglePoly.AddVertexCoord (polygon.GetVertex (triangle[2])); + if (trianglePoly.GetOrientation () != originalOrientation) { + return false; + } + } + return true; +} + +function CheckCalculatedTriangulation (polygon, triangles) +{ + if (!CheckCalculatedTriangulation_Exists (polygon, triangles)) { + return false; + } + if (!CheckCalculatedTriangulation_TriangleCount (polygon, triangles)) { + return false; + } + if (!CheckCalculatedTriangulation_Area (polygon, triangles)) { + return false; + } + if (!CheckCalculatedTriangulation_Orientation (polygon, triangles)) { + return false; + } + return true; +} + +function CheckSimpleTriangulation (polygon, triangles) +{ + var triangles = JSM.TriangulateSimplePolygon (polygon); + return CheckCalculatedTriangulation (polygon, triangles); +} + +var simplePolygonSuite = unitTest.AddTestSuite ('SimplePolygonTriangulationTest'); + +simplePolygonSuite.AddTest ('InvalidPolygonTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + var triangles = JSM.TriangulateSimplePolygon (polygon); + test.AssertEqual (triangles, null); + + polygon.AddVertex (0.0, 0.0); + triangles = JSM.TriangulateSimplePolygon (polygon); + test.AssertEqual (triangles, null); + + polygon.AddVertex (1.0, 0.0); + triangles = JSM.TriangulateSimplePolygon (polygon); + test.AssertEqual (triangles, null); +}); + +simplePolygonSuite.AddTest ('TriangleTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + test.Assert (CheckSimpleTriangulation (polygon2)); +}); + +simplePolygonSuite.AddTest ('ConvexTriangulationTest', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (0.0, 1.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 0.0); + test.Assert (CheckSimpleTriangulation (polygon2)); +}); + +simplePolygonSuite.AddTest ('ConcaveTriangulationTest01', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.2, 0.2); + polygon.AddVertex (0.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (0.0, 1.0); + polygon.AddVertex (0.2, 0.2); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 0.0); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (0.5, 0.2); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.5, 0.8); + polygon.AddVertex (0.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (0.0, 1.0); + polygon.AddVertex (0.5, 0.8); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (0.5, 0.2); + test.Assert (CheckSimpleTriangulation (polygon)); + + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (2.0, 0.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 0.1); + polygon.AddVertex (0.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +simplePolygonSuite.AddTest ('ConcaveTriangulationTest02', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 5.0); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (3.0, 1.0); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +var convertToSimplePolygonSuite = unitTest.AddTestSuite ('ConvertPolygonToSimplePolygonTest'); + +convertToSimplePolygonSuite.AddTest ('SimplePolygonTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount (), simple.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Convex); + + var polygon2 = new JSM.ContourPolygon2D (); + polygon2.AddContour (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (0.0, 4.0); + polygon2.AddVertex (5.0, 4.0); + polygon2.AddVertex (5.0, 0.0); + + var simple2 = JSM.ConvertPolygonToSimplePolygon (polygon2); + test.AssertEqual (polygon2.VertexCount (), simple2.VertexCount ()); + test.AssertEqual (polygon2.GetSignedArea (), simple2.GetSignedArea ()); + test.AssertEqual (polygon2.GetArea (), simple2.GetArea ()); + test.AssertEqual (polygon2.GetOrientation (), simple2.GetOrientation ()); + test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); + test.AssertEqual (simple2.GetComplexity (), JSM.Complexity.Convex); +}); + +convertToSimplePolygonSuite.AddTest ('OneHoleTest01', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); + test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); +}); + +convertToSimplePolygonSuite.AddTest ('OneHoleTest02', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); + test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); +}); + +convertToSimplePolygonSuite.AddTest ('OneHoleTest03', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (4.0, 0.0); + polygon.AddVertex (4.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 3.0); + polygon.AddVertex (2.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); + test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); +}); + +convertToSimplePolygonSuite.AddTest ('TwoHolesTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); + test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); + test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); +}); + +var polygonSuite = unitTest.AddTestSuite ('PolygonTriangulationTest'); + +polygonSuite.AddTest ('OneHoleTriangulationTest', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon2 = new JSM.ContourPolygon2D (); + polygon2.AddContour (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (5.0, 0.0); + polygon2.AddVertex (0.0, 5.0); + polygon2.AddContour (); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 2.0); + polygon2.AddVertex (2.0, 2.0); + polygon2.AddVertex (2.0, 1.0); + + var simple2 = JSM.ConvertPolygonToSimplePolygon (polygon2); + test.Assert (CheckSimpleTriangulation (simple2)); + + var polygon3 = new JSM.ContourPolygon2D (); + polygon3.AddContour (); + polygon3.AddVertex (0, 0); + polygon3.AddVertex (100, 0); + polygon3.AddVertex (100, 100); + polygon3.AddVertex (0, 100); + polygon3.AddContour (); + polygon3.AddVertex (10, 10); + polygon3.AddVertex (10, 90); + polygon3.AddVertex (90, 90); + polygon3.AddVertex (90, 10); + + var simple3 = JSM.ConvertPolygonToSimplePolygon (polygon3); + test.Assert (CheckSimpleTriangulation (simple3)); +}); + +polygonSuite.AddTest ('TwoHolesTriangulationTest01', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + + test.Assert (CheckSimpleTriangulation (simple)); +}); + +polygonSuite.AddTest ('TwoHolesTriangulationTest02', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + + test.Assert (CheckSimpleTriangulation (simple)); +}); + +polygonSuite.AddTest ('TwoHolesTriangulationTest03', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + + test.Assert (CheckSimpleTriangulation (simple)); +}); + +polygonSuite.AddTest ('TwoHolesTriangulationTest04', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var triangles = JSM.TriangulateSimplePolygon (simple); + test.Assert (CheckCalculatedTriangulation_Exists (simple, triangles)); + test.Assert (CheckCalculatedTriangulation_TriangleCount (simple, triangles)); + test.Assert (CheckCalculatedTriangulation_Area (simple, triangles)); + test.Assert (CheckCalculatedTriangulation_Orientation (simple, triangles)); +}); + +var generatedSuite = unitTest.AddTestSuite ('GeneratedTriangulationTest'); + +generatedSuite.AddTest ('Test01', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (238, 542); + polygon.AddVertex (117, 162); + polygon.AddVertex (431, 88); + polygon.AddVertex (642, 232); + polygon.AddVertex (434, 469); + test.AssertEqualNum (polygon.GetArea (), 141564, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test02', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (242, 69); + polygon.AddVertex (123, 386); + polygon.AddVertex (331, 533); + polygon.AddVertex (539, 523); + polygon.AddVertex (609, 373); + polygon.AddVertex (602, 182); + polygon.AddVertex (393, 87); + test.AssertEqualNum (polygon.GetArea (), 167856.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test03', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (216, 132); + polygon.AddVertex (157, 435); + polygon.AddVertex (204, 246); + polygon.AddVertex (215, 479); + polygon.AddVertex (780, 397); + polygon.AddVertex (233, 461); + polygon.AddVertex (266, 372); + polygon.AddVertex (718, 371); + polygon.AddVertex (527, 406); + polygon.AddVertex (755, 383); + polygon.AddVertex (763, 302); + polygon.AddVertex (362, 361); + polygon.AddVertex (383, 145); + polygon.AddVertex (390, 341); + polygon.AddVertex (435, 335); + polygon.AddVertex (422, 221); + polygon.AddVertex (490, 322); + polygon.AddVertex (474, 202); + polygon.AddVertex (538, 311); + polygon.AddVertex (498, 144); + polygon.AddVertex (589, 312); + polygon.AddVertex (559, 155); + polygon.AddVertex (624, 272); + polygon.AddVertex (642, 182); + polygon.AddVertex (671, 259); + polygon.AddVertex (706, 140); + polygon.AddVertex (776, 211); + polygon.AddVertex (712, 58); + polygon.AddVertex (669, 190); + polygon.AddVertex (579, 52); + polygon.AddVertex (608, 182); + polygon.AddVertex (475, 46); + polygon.AddVertex (440, 178); + polygon.AddVertex (403, 55); + polygon.AddVertex (316, 56); + polygon.AddVertex (335, 336); + polygon.AddVertex (276, 338); + polygon.AddVertex (274, 178); + test.AssertEqualNum (polygon.GetArea (), 105526.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test04', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (58, 69); + polygon.AddVertex (175, 223); + polygon.AddVertex (90, 333); + polygon.AddVertex (242, 546); + polygon.AddVertex (154, 308); + polygon.AddVertex (317, 301); + polygon.AddVertex (219, 389); + polygon.AddVertex (320, 524); + polygon.AddVertex (746, 372); + polygon.AddVertex (390, 424); + polygon.AddVertex (474, 215); + polygon.AddVertex (313, 374); + polygon.AddVertex (453, 100); + polygon.AddVertex (284, 212); + polygon.AddVertex (302, 79); + polygon.AddVertex (195, 129); + test.AssertEqualNum (polygon.GetArea (), 97937.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test05', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (104, 71); + polygon.AddVertex (107, 213); + polygon.AddVertex (141, 59); + polygon.AddVertex (176, 228); + polygon.AddVertex (224, 49); + polygon.AddVertex (287, 272); + polygon.AddVertex (340, 104); + polygon.AddVertex (382, 318); + polygon.AddVertex (408, 55); + polygon.AddVertex (452, 435); + polygon.AddVertex (545, 51); + polygon.AddVertex (540, 532); + polygon.AddVertex (600, 182); + polygon.AddVertex (604, 485); + polygon.AddVertex (680, 219); + polygon.AddVertex (696, 470); + polygon.AddVertex (732, 21); + polygon.AddVertex (760, 579); + polygon.AddVertex (417, 587); + polygon.AddVertex (410, 382); + polygon.AddVertex (48, 381); + test.AssertEqualNum (polygon.GetArea (), 174123, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test06', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (136, 128); + polygon.AddVertex (722, 110); + polygon.AddVertex (142, 315); + polygon.AddVertex (482, 158); + polygon.AddVertex (79, 182); + polygon.AddVertex (56, 478); + polygon.AddVertex (717, 261); + polygon.AddVertex (765, 531); + polygon.AddVertex (21, 551); + polygon.AddVertex (54, 21); + polygon.AddVertex (394, 21); + polygon.AddVertex (393, 67); + test.AssertEqualNum (polygon.GetArea (), 196986, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test07', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (269, 176); + polygon.AddVertex (429, 98); + polygon.AddVertex (285, 326); + polygon.AddVertex (502, 320); + polygon.AddVertex (479, 59); + polygon.AddVertex (648, 57); + polygon.AddVertex (599, 499); + polygon.AddVertex (209, 540); + polygon.AddVertex (208, 501); + polygon.AddVertex (568, 473); + polygon.AddVertex (609, 82); + polygon.AddVertex (505, 89); + polygon.AddVertex (529, 363); + polygon.AddVertex (262, 359); + polygon.AddVertex (259, 390); + polygon.AddVertex (553, 393); + polygon.AddVertex (543, 454); + polygon.AddVertex (208, 465); + polygon.AddVertex (93, 128); + polygon.AddVertex (266, 288); + polygon.AddVertex (335, 172); + test.AssertEqualNum (polygon.GetArea (), 100896, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test08', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (248, 295); + polygon.AddVertex (229, 125); + polygon.AddVertex (374, 320); + polygon.AddVertex (404, 168); + polygon.AddVertex (418, 483); + polygon.AddVertex (278, 242); + test.AssertEqualNum (polygon.GetArea (), 18655.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test09', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (197, 332); + polygon.AddVertex (271, 136); + polygon.AddVertex (319, 394); + polygon.AddVertex (259, 261); + test.AssertEqualNum (polygon.GetArea (), 7997, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test10', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (249, 323); + polygon.AddVertex (304, 253); + polygon.AddVertex (257, 231); + polygon.AddVertex (239, 126); + polygon.AddVertex (152, 138); + polygon.AddVertex (177, 237); + polygon.AddVertex (213, 198); + polygon.AddVertex (234, 225); + polygon.AddVertex (202, 261); + polygon.AddVertex (231, 269); + polygon.AddVertex (223, 308); + polygon.AddVertex (131, 321); + polygon.AddVertex (139, 411); + polygon.AddVertex (242, 431); + polygon.AddVertex (209, 356); + polygon.AddVertex (344, 392); + polygon.AddVertex (343, 302); + polygon.AddVertex (422, 312); + polygon.AddVertex (414, 221); + polygon.AddVertex (343, 274); + polygon.AddVertex (350, 228); + test.AssertEqualNum (polygon.GetArea (), 37323.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test11', function (test) { + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (128, 294); + polygon.AddVertex (128, 306); + polygon.AddVertex (139, 315); + polygon.AddVertex (152, 317); + polygon.AddVertex (161, 314); + polygon.AddVertex (176, 307); + polygon.AddVertex (177, 291); + polygon.AddVertex (168, 277); + polygon.AddVertex (153, 275); + polygon.AddVertex (154, 104); + polygon.AddVertex (166, 95); + polygon.AddVertex (179, 99); + polygon.AddVertex (186, 112); + polygon.AddVertex (175, 123); + polygon.AddVertex (172, 141); + polygon.AddVertex (178, 147); + polygon.AddVertex (191, 150); + polygon.AddVertex (204, 142); + polygon.AddVertex (205, 125); + polygon.AddVertex (205, 115); + polygon.AddVertex (219, 107); + polygon.AddVertex (232, 116); + polygon.AddVertex (232, 132); + polygon.AddVertex (228, 144); + polygon.AddVertex (220, 156); + polygon.AddVertex (198, 162); + polygon.AddVertex (184, 162); + polygon.AddVertex (174, 167); + polygon.AddVertex (178, 183); + polygon.AddVertex (199, 193); + polygon.AddVertex (223, 182); + polygon.AddVertex (241, 172); + polygon.AddVertex (254, 159); + polygon.AddVertex (275, 157); + polygon.AddVertex (275, 172); + polygon.AddVertex (275, 179); + polygon.AddVertex (274, 186); + polygon.AddVertex (267, 192); + polygon.AddVertex (246, 195); + polygon.AddVertex (253, 184); + polygon.AddVertex (251, 177); + polygon.AddVertex (239, 183); + polygon.AddVertex (234, 197); + polygon.AddVertex (234, 207); + polygon.AddVertex (250, 208); + polygon.AddVertex (261, 208); + polygon.AddVertex (268, 220); + polygon.AddVertex (266, 232); + polygon.AddVertex (247, 239); + polygon.AddVertex (232, 240); + polygon.AddVertex (228, 227); + polygon.AddVertex (228, 217); + polygon.AddVertex (222, 210); + polygon.AddVertex (214, 211); + polygon.AddVertex (206, 222); + polygon.AddVertex (215, 238); + polygon.AddVertex (229, 259); + polygon.AddVertex (217, 271); + polygon.AddVertex (221, 284); + polygon.AddVertex (234, 285); + polygon.AddVertex (249, 282); + polygon.AddVertex (256, 303); + polygon.AddVertex (233, 315); + polygon.AddVertex (205, 328); + polygon.AddVertex (208, 340); + polygon.AddVertex (235, 349); + polygon.AddVertex (255, 337); + polygon.AddVertex (279, 339); + polygon.AddVertex (270, 363); + polygon.AddVertex (252, 369); + polygon.AddVertex (217, 376); + polygon.AddVertex (209, 360); + polygon.AddVertex (191, 360); + polygon.AddVertex (191, 390); + polygon.AddVertex (223, 399); + polygon.AddVertex (303, 407); + polygon.AddVertex (312, 366); + polygon.AddVertex (323, 338); + polygon.AddVertex (312, 318); + polygon.AddVertex (310, 304); + polygon.AddVertex (321, 298); + polygon.AddVertex (321, 278); + polygon.AddVertex (295, 270); + polygon.AddVertex (298, 263); + polygon.AddVertex (303, 255); + polygon.AddVertex (307, 237); + polygon.AddVertex (302, 230); + polygon.AddVertex (316, 204); + polygon.AddVertex (313, 180); + polygon.AddVertex (318, 171); + polygon.AddVertex (329, 165); + polygon.AddVertex (348, 170); + polygon.AddVertex (357, 188); + polygon.AddVertex (365, 188); + polygon.AddVertex (374, 178); + polygon.AddVertex (379, 162); + polygon.AddVertex (364, 140); + polygon.AddVertex (343, 132); + polygon.AddVertex (302, 132); + polygon.AddVertex (293, 122); + polygon.AddVertex (295, 105); + polygon.AddVertex (293, 87); + polygon.AddVertex (278, 80); + polygon.AddVertex (259, 75); + polygon.AddVertex (257, 69); + polygon.AddVertex (246, 60); + polygon.AddVertex (230, 63); + polygon.AddVertex (224, 81); + polygon.AddVertex (224, 87); + polygon.AddVertex (209, 91); + polygon.AddVertex (201, 88); + polygon.AddVertex (204, 64); + polygon.AddVertex (200, 45); + polygon.AddVertex (168, 43); + polygon.AddVertex (121, 44); + polygon.AddVertex (109, 69); + polygon.AddVertex (134, 86); + polygon.AddVertex (114, 97); + polygon.AddVertex (132, 119); + polygon.AddVertex (120, 129); + polygon.AddVertex (142, 148); + polygon.AddVertex (100, 179); + polygon.AddVertex (136, 190); + polygon.AddVertex (93, 220); + polygon.AddVertex (131, 221); + polygon.AddVertex (104, 246); + polygon.AddVertex (136, 248); + polygon.AddVertex (98, 280); + test.AssertEqualNum (polygon.GetArea (), 42850.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + test.Assert (CheckSimpleTriangulation (polygon)); +}); + +generatedSuite.AddTest ('Test12', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (375, 474); + polygon.AddVertex (228, 240); + polygon.AddVertex (497, 212); + polygon.AddContour (); + polygon.AddVertex (403, 269); + polygon.AddVertex (311, 275); + polygon.AddVertex (373, 387); + test.AssertEqualNum (polygon.GetArea (), 28193, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test13', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (146, 387); + polygon.AddVertex (167, 453); + polygon.AddVertex (304, 491); + polygon.AddVertex (249, 551); + polygon.AddVertex (385, 561); + polygon.AddVertex (362, 429); + polygon.AddVertex (273, 441); + polygon.AddVertex (277, 367); + polygon.AddVertex (443, 367); + polygon.AddVertex (413, 473); + polygon.AddVertex (476, 517); + polygon.AddVertex (654, 544); + polygon.AddVertex (499, 479); + polygon.AddVertex (522, 441); + polygon.AddVertex (604, 473); + polygon.AddVertex (601, 508); + polygon.AddVertex (631, 508); + polygon.AddVertex (637, 460); + polygon.AddVertex (712, 465); + polygon.AddVertex (696, 370); + polygon.AddVertex (571, 406); + polygon.AddVertex (583, 431); + polygon.AddVertex (625, 419); + polygon.AddVertex (637, 445); + polygon.AddVertex (574, 444); + polygon.AddVertex (511, 377); + polygon.AddVertex (492, 437); + polygon.AddVertex (473, 426); + polygon.AddVertex (511, 355); + polygon.AddVertex (406, 317); + polygon.AddVertex (419, 293); + polygon.AddVertex (573, 293); + polygon.AddVertex (565, 349); + polygon.AddVertex (673, 349); + polygon.AddVertex (695, 282); + polygon.AddVertex (582, 237); + polygon.AddVertex (602, 181); + polygon.AddVertex (658, 195); + polygon.AddVertex (664, 243); + polygon.AddVertex (696, 243); + polygon.AddVertex (706, 202); + polygon.AddVertex (735, 205); + polygon.AddVertex (737, 181); + polygon.AddVertex (657, 146); + polygon.AddVertex (658, 99); + polygon.AddVertex (602, 77); + polygon.AddVertex (590, 128); + polygon.AddVertex (535, 102); + polygon.AddVertex (517, 44); + polygon.AddVertex (405, 64); + polygon.AddVertex (488, 117); + polygon.AddVertex (483, 178); + polygon.AddVertex (439, 177); + polygon.AddVertex (400, 103); + polygon.AddVertex (302, 103); + polygon.AddVertex (322, 139); + polygon.AddVertex (363, 157); + polygon.AddVertex (369, 215); + polygon.AddVertex (339, 220); + polygon.AddVertex (283, 178); + polygon.AddVertex (153, 178); + polygon.AddVertex (64, 178); + polygon.AddVertex (54, 268); + polygon.AddVertex (128, 263); + polygon.AddVertex (116, 224); + polygon.AddVertex (199, 223); + polygon.AddVertex (192, 279); + polygon.AddVertex (234, 289); + polygon.AddVertex (258, 244); + polygon.AddVertex (366, 263); + polygon.AddVertex (340, 324); + polygon.AddVertex (192, 328); + test.AssertEqualNum (polygon.GetArea (), 151033, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test14', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (131, 357); + polygon.AddVertex (214, 511); + polygon.AddVertex (290, 445); + polygon.AddVertex (311, 507); + polygon.AddVertex (354, 508); + polygon.AddVertex (324, 438); + polygon.AddVertex (405, 461); + polygon.AddVertex (370, 508); + polygon.AddVertex (427, 524); + polygon.AddVertex (441, 477); + polygon.AddVertex (453, 539); + polygon.AddVertex (499, 524); + polygon.AddVertex (486, 564); + polygon.AddVertex (545, 556); + polygon.AddVertex (518, 575); + polygon.AddVertex (543, 574); + polygon.AddVertex (608, 550); + polygon.AddVertex (616, 580); + polygon.AddVertex (677, 558); + polygon.AddVertex (624, 490); + polygon.AddVertex (681, 492); + polygon.AddVertex (660, 394); + polygon.AddVertex (718, 413); + polygon.AddVertex (726, 315); + polygon.AddVertex (718, 302); + polygon.AddVertex (694, 283); + polygon.AddVertex (652, 275); + polygon.AddVertex (594, 281); + polygon.AddVertex (576, 298); + polygon.AddVertex (564, 319); + polygon.AddVertex (557, 351); + polygon.AddVertex (570, 387); + polygon.AddVertex (589, 403); + polygon.AddVertex (609, 423); + polygon.AddVertex (596, 442); + polygon.AddVertex (495, 420); + polygon.AddVertex (486, 385); + polygon.AddVertex (496, 344); + polygon.AddVertex (511, 311); + polygon.AddVertex (530, 291); + polygon.AddVertex (558, 269); + polygon.AddVertex (595, 261); + polygon.AddVertex (639, 254); + polygon.AddVertex (683, 259); + polygon.AddVertex (707, 271); + polygon.AddVertex (724, 279); + polygon.AddVertex (739, 276); + polygon.AddVertex (754, 262); + polygon.AddVertex (760, 242); + polygon.AddVertex (756, 226); + polygon.AddVertex (734, 208); + polygon.AddVertex (682, 199); + polygon.AddVertex (661, 149); + polygon.AddVertex (630, 96); + polygon.AddVertex (476, 69); + polygon.AddVertex (513, 134); + polygon.AddVertex (543, 181); + polygon.AddVertex (507, 221); + polygon.AddVertex (491, 210); + polygon.AddVertex (475, 199); + polygon.AddVertex (449, 190); + polygon.AddVertex (410, 190); + polygon.AddVertex (394, 195); + polygon.AddVertex (379, 202); + polygon.AddVertex (357, 224); + polygon.AddVertex (355, 243); + polygon.AddVertex (359, 261); + polygon.AddVertex (375, 276); + polygon.AddVertex (388, 284); + polygon.AddVertex (405, 282); + polygon.AddVertex (420, 278); + polygon.AddVertex (427, 268); + polygon.AddVertex (429, 260); + polygon.AddVertex (429, 252); + polygon.AddVertex (426, 238); + polygon.AddVertex (439, 230); + polygon.AddVertex (451, 230); + polygon.AddVertex (469, 246); + polygon.AddVertex (470, 261); + polygon.AddVertex (470, 284); + polygon.AddVertex (453, 305); + polygon.AddVertex (403, 313); + polygon.AddVertex (350, 301); + polygon.AddVertex (323, 266); + polygon.AddVertex (317, 198); + polygon.AddVertex (322, 143); + polygon.AddVertex (241, 114); + polygon.AddVertex (236, 238); + polygon.AddVertex (159, 213); + polygon.AddVertex (312, 356); + polygon.AddVertex (179, 303); + test.AssertEqualNum (polygon.GetArea (), 163611, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test15', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (110, 319); + polygon.AddVertex (113, 477); + polygon.AddVertex (202, 496); + polygon.AddVertex (172, 532); + polygon.AddVertex (236, 545); + polygon.AddVertex (254, 461); + polygon.AddVertex (144, 448); + polygon.AddVertex (184, 381); + polygon.AddVertex (365, 388); + polygon.AddVertex (325, 498); + polygon.AddVertex (375, 516); + polygon.AddVertex (355, 551); + polygon.AddVertex (404, 555); + polygon.AddVertex (409, 500); + polygon.AddVertex (472, 531); + polygon.AddVertex (515, 493); + polygon.AddVertex (457, 439); + polygon.AddVertex (557, 409); + polygon.AddVertex (552, 346); + polygon.AddVertex (582, 359); + polygon.AddVertex (587, 432); + polygon.AddVertex (627, 437); + polygon.AddVertex (625, 413); + polygon.AddVertex (658, 415); + polygon.AddVertex (661, 385); + polygon.AddVertex (681, 392); + polygon.AddVertex (696, 362); + polygon.AddVertex (602, 326); + polygon.AddVertex (635, 279); + polygon.AddVertex (686, 302); + polygon.AddVertex (692, 241); + polygon.AddVertex (631, 180); + polygon.AddVertex (566, 284); + polygon.AddVertex (575, 314); + polygon.AddVertex (472, 311); + polygon.AddVertex (492, 362); + polygon.AddVertex (422, 388); + polygon.AddVertex (387, 338); + polygon.AddVertex (284, 363); + polygon.AddVertex (251, 315); + polygon.AddVertex (279, 258); + polygon.AddVertex (373, 291); + polygon.AddVertex (377, 237); + polygon.AddVertex (423, 250); + polygon.AddVertex (412, 285); + polygon.AddVertex (433, 286); + polygon.AddVertex (444, 254); + polygon.AddVertex (473, 262); + polygon.AddVertex (469, 282); + polygon.AddVertex (486, 283); + polygon.AddVertex (487, 268); + polygon.AddVertex (501, 270); + polygon.AddVertex (502, 282); + polygon.AddVertex (523, 282); + polygon.AddVertex (528, 260); + polygon.AddVertex (559, 229); + polygon.AddVertex (518, 187); + polygon.AddVertex (534, 135); + polygon.AddVertex (586, 135); + polygon.AddVertex (610, 84); + polygon.AddVertex (658, 83); + polygon.AddVertex (662, 47); + polygon.AddVertex (552, 53); + polygon.AddVertex (548, 92); + polygon.AddVertex (484, 80); + polygon.AddVertex (423, 54); + polygon.AddVertex (441, 129); + polygon.AddVertex (469, 153); + polygon.AddVertex (461, 190); + polygon.AddVertex (383, 188); + polygon.AddVertex (386, 146); + polygon.AddVertex (278, 142); + polygon.AddVertex (341, 197); + polygon.AddVertex (311, 218); + polygon.AddVertex (237, 183); + polygon.AddVertex (235, 111); + polygon.AddVertex (139, 93); + polygon.AddVertex (157, 181); + polygon.AddVertex (221, 233); + polygon.AddVertex (211, 283); + polygon.AddVertex (153, 255); + test.AssertEqualNum (polygon.GetArea (), 132181.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test16', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (208, 387); + polygon.AddVertex (240, 204); + polygon.AddVertex (442, 224); + polygon.AddVertex (423, 406); + polygon.AddContour (); + polygon.AddVertex (262, 340); + polygon.AddVertex (324, 345); + polygon.AddVertex (340, 285); + polygon.AddVertex (284, 270); + polygon.AddContour (); + polygon.AddVertex (362, 339); + polygon.AddVertex (395, 348); + polygon.AddVertex (397, 314); + polygon.AddContour (); + polygon.AddVertex (328, 361); + polygon.AddVertex (352, 361); + polygon.AddVertex (347, 341); + polygon.AddContour (); + polygon.AddVertex (330, 244); + polygon.AddVertex (389, 259); + polygon.AddVertex (380, 235); + test.AssertEqualNum (polygon.GetArea (), 33073, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test17', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (180, 420); + polygon.AddVertex (572, 461); + polygon.AddVertex (601, 162); + polygon.AddVertex (150, 102); + polygon.AddContour (); + polygon.AddVertex (262, 352); + polygon.AddVertex (219, 196); + polygon.AddVertex (290, 197); + polygon.AddContour (); + polygon.AddVertex (376, 359); + polygon.AddVertex (304, 248); + polygon.AddVertex (430, 236); + polygon.AddVertex (458, 319); + polygon.AddContour (); + polygon.AddVertex (521, 397); + polygon.AddVertex (475, 245); + polygon.AddVertex (543, 242); + polygon.AddVertex (536, 337); + polygon.AddContour (); + polygon.AddVertex (345, 405); + polygon.AddVertex (309, 380); + polygon.AddVertex (324, 342); + polygon.AddVertex (340, 352); + polygon.AddContour (); + polygon.AddVertex (469, 396); + polygon.AddVertex (422, 361); + polygon.AddVertex (476, 349); + polygon.AddVertex (491, 375); + polygon.AddContour (); + polygon.AddVertex (483, 199); + polygon.AddVertex (313, 201); + polygon.AddVertex (452, 152); + polygon.AddVertex (519, 185); + polygon.AddContour (); + polygon.AddVertex (258, 173); + polygon.AddVertex (192, 165); + polygon.AddVertex (192, 132); + polygon.AddVertex (263, 140); + polygon.AddVertex (333, 149); + polygon.AddVertex (308, 174); + polygon.AddVertex (291, 163); + polygon.AddVertex (257, 151); + polygon.AddVertex (214, 151); + polygon.AddVertex (260, 160); + polygon.AddVertex (285, 176); + polygon.AddContour (); + polygon.AddVertex (564, 206); + polygon.AddVertex (510, 227); + polygon.AddVertex (507, 204); + polygon.AddVertex (533, 198); + polygon.AddContour (); + polygon.AddVertex (255, 398); + polygon.AddVertex (225, 381); + polygon.AddVertex (203, 273); + polygon.AddVertex (227, 285); + polygon.AddVertex (242, 363); + polygon.AddVertex (273, 384); + polygon.AddVertex (290, 332); + polygon.AddVertex (318, 342); + polygon.AddVertex (293, 398); + polygon.AddContour (); + polygon.AddVertex (451, 429); + polygon.AddVertex (383, 416); + polygon.AddVertex (393, 371); + polygon.AddContour (); + polygon.AddVertex (560, 424); + polygon.AddVertex (491, 445); + polygon.AddVertex (492, 415); + polygon.AddVertex (525, 411); + test.AssertEqualNum (polygon.GetArea (), 87509, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test18', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (180, 420); + polygon.AddVertex (572, 461); + polygon.AddVertex (601, 162); + polygon.AddVertex (150, 102); + polygon.AddContour (); + polygon.AddVertex (262, 352); + polygon.AddVertex (219, 196); + polygon.AddVertex (290, 197); + polygon.AddContour (); + polygon.AddVertex (376, 359); + polygon.AddVertex (304, 248); + polygon.AddVertex (430, 236); + polygon.AddVertex (458, 319); + polygon.AddContour (); + polygon.AddVertex (521, 397); + polygon.AddVertex (475, 245); + polygon.AddVertex (543, 242); + polygon.AddVertex (536, 337); + polygon.AddContour (); + polygon.AddVertex (345, 405); + polygon.AddVertex (309, 380); + polygon.AddVertex (324, 342); + polygon.AddVertex (340, 352); + polygon.AddContour (); + polygon.AddVertex (469, 396); + polygon.AddVertex (422, 361); + polygon.AddVertex (476, 349); + polygon.AddVertex (491, 375); + polygon.AddContour (); + polygon.AddVertex (483, 199); + polygon.AddVertex (313, 201); + polygon.AddVertex (452, 152); + polygon.AddVertex (519, 185); + polygon.AddContour (); + polygon.AddVertex (258, 173); + polygon.AddVertex (192, 165); + polygon.AddVertex (192, 132); + polygon.AddVertex (263, 140); + polygon.AddVertex (333, 149); + polygon.AddVertex (308, 174); + polygon.AddVertex (291, 163); + polygon.AddVertex (257, 151); + polygon.AddVertex (214, 151); + polygon.AddVertex (260, 160); + polygon.AddVertex (285, 176); + polygon.AddContour (); + polygon.AddVertex (564, 206); + polygon.AddVertex (510, 227); + polygon.AddVertex (507, 204); + polygon.AddVertex (533, 198); + polygon.AddContour (); + polygon.AddVertex (255, 398); + polygon.AddVertex (225, 381); + polygon.AddVertex (203, 273); + polygon.AddVertex (227, 285); + polygon.AddVertex (242, 363); + polygon.AddVertex (273, 384); + polygon.AddVertex (290, 332); + polygon.AddVertex (318, 342); + polygon.AddVertex (293, 398); + polygon.AddContour (); + polygon.AddVertex (451, 429); + polygon.AddVertex (383, 416); + polygon.AddVertex (393, 371); + polygon.AddContour (); + polygon.AddVertex (560, 424); + polygon.AddVertex (491, 445); + polygon.AddVertex (492, 415); + polygon.AddVertex (525, 411); + polygon.AddContour (); + polygon.AddVertex (569, 314); + polygon.AddVertex (567, 396); + polygon.AddVertex (536, 397); + polygon.AddVertex (557, 255); + polygon.AddVertex (581, 257); + test.AssertEqualNum (polygon.GetArea (), 84071.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test19', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (94, 553); + polygon.AddVertex (709, 549); + polygon.AddVertex (713, 43); + polygon.AddVertex (85, 44); + polygon.AddContour (); + polygon.AddVertex (217, 401); + polygon.AddVertex (223, 202); + polygon.AddVertex (538, 207); + polygon.AddVertex (543, 392); + polygon.AddContour (); + polygon.AddVertex (176, 128); + polygon.AddVertex (629, 136); + polygon.AddVertex (637, 368); + polygon.AddVertex (594, 364); + polygon.AddVertex (597, 175); + polygon.AddVertex (181, 177); + polygon.AddVertex (186, 447); + polygon.AddVertex (592, 437); + polygon.AddVertex (593, 377); + polygon.AddVertex (639, 381); + polygon.AddVertex (627, 477); + polygon.AddVertex (142, 492); + polygon.AddVertex (136, 167); + test.AssertEqualNum (polygon.GetArea (), 190194.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test20', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (64, 547); + polygon.AddVertex (691, 539); + polygon.AddVertex (696, 31); + polygon.AddContour (); + polygon.AddVertex (676, 127); + polygon.AddVertex (615, 124); + polygon.AddVertex (654, 85); + polygon.AddVertex (680, 55); + polygon.AddVertex (684, 92); + polygon.AddContour (); + polygon.AddVertex (675, 186); + polygon.AddVertex (538, 185); + polygon.AddVertex (604, 142); + polygon.AddVertex (665, 146); + polygon.AddContour (); + polygon.AddVertex (669, 268); + polygon.AddVertex (437, 272); + polygon.AddVertex (521, 201); + polygon.AddVertex (660, 206); + polygon.AddContour (); + polygon.AddVertex (667, 308); + polygon.AddVertex (385, 309); + polygon.AddVertex (415, 291); + polygon.AddVertex (653, 285); + polygon.AddContour (); + polygon.AddVertex (676, 364); + polygon.AddVertex (312, 365); + polygon.AddVertex (371, 327); + polygon.AddVertex (663, 325); + polygon.AddContour (); + polygon.AddVertex (678, 432); + polygon.AddVertex (232, 437); + polygon.AddVertex (288, 387); + polygon.AddVertex (668, 387); + polygon.AddContour (); + polygon.AddVertex (669, 485); + polygon.AddVertex (175, 488); + polygon.AddVertex (208, 457); + polygon.AddVertex (673, 453); + polygon.AddContour (); + polygon.AddVertex (674, 529); + polygon.AddVertex (108, 531); + polygon.AddVertex (138, 511); + polygon.AddVertex (647, 505); + test.AssertEqualNum (polygon.GetArea (), 76049, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test21', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (66, 559); + polygon.AddVertex (743, 588); + polygon.AddVertex (750, 59); + polygon.AddVertex (705, 58); + polygon.AddVertex (691, 535); + polygon.AddVertex (604, 530); + polygon.AddVertex (646, 126); + polygon.AddVertex (603, 126); + polygon.AddVertex (557, 531); + polygon.AddVertex (463, 530); + polygon.AddVertex (517, 184); + polygon.AddVertex (459, 181); + polygon.AddVertex (407, 523); + polygon.AddVertex (340, 524); + polygon.AddVertex (393, 264); + polygon.AddVertex (325, 263); + polygon.AddVertex (293, 513); + polygon.AddVertex (250, 514); + polygon.AddVertex (250, 325); + polygon.AddVertex (201, 318); + polygon.AddVertex (190, 511); + polygon.AddVertex (129, 511); + polygon.AddVertex (137, 322); + polygon.AddVertex (82, 328); + polygon.AddContour (); + polygon.AddVertex (714, 123); + polygon.AddVertex (716, 84); + polygon.AddVertex (736, 86); + polygon.AddVertex (734, 115); + polygon.AddContour (); + polygon.AddVertex (606, 183); + polygon.AddVertex (612, 143); + polygon.AddVertex (637, 144); + polygon.AddVertex (628, 179); + polygon.AddContour (); + polygon.AddVertex (463, 259); + polygon.AddVertex (461, 209); + polygon.AddVertex (493, 211); + polygon.AddVertex (495, 265); + polygon.AddContour (); + polygon.AddVertex (312, 469); + polygon.AddVertex (336, 299); + polygon.AddVertex (361, 298); + polygon.AddVertex (333, 483); + polygon.AddContour (); + polygon.AddVertex (217, 490); + polygon.AddVertex (209, 379); + polygon.AddVertex (228, 373); + polygon.AddVertex (234, 430); + polygon.AddContour (); + polygon.AddVertex (90, 488); + polygon.AddVertex (98, 371); + polygon.AddVertex (115, 371); + polygon.AddVertex (119, 468); + polygon.AddContour (); + polygon.AddVertex (96, 553); + polygon.AddVertex (108, 536); + polygon.AddVertex (697, 556); + polygon.AddVertex (703, 571); + polygon.AddVertex (357, 564); + test.AssertEqualNum (polygon.GetArea (), 109202, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test22', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (84, 449); + polygon.AddVertex (139, 503); + polygon.AddVertex (165, 413); + polygon.AddVertex (181, 510); + polygon.AddVertex (194, 449); + polygon.AddVertex (207, 492); + polygon.AddVertex (231, 446); + polygon.AddVertex (231, 496); + polygon.AddVertex (250, 466); + polygon.AddVertex (256, 488); + polygon.AddVertex (271, 446); + polygon.AddVertex (292, 477); + polygon.AddVertex (306, 419); + polygon.AddVertex (332, 522); + polygon.AddVertex (352, 422); + polygon.AddVertex (373, 525); + polygon.AddVertex (394, 412); + polygon.AddVertex (411, 505); + polygon.AddVertex (447, 410); + polygon.AddVertex (476, 469); + polygon.AddVertex (481, 426); + polygon.AddVertex (499, 487); + polygon.AddVertex (511, 439); + polygon.AddVertex (536, 500); + polygon.AddVertex (548, 437); + polygon.AddVertex (586, 519); + polygon.AddVertex (598, 428); + polygon.AddVertex (667, 537); + polygon.AddVertex (667, 449); + polygon.AddVertex (711, 500); + polygon.AddVertex (696, 434); + polygon.AddVertex (272, 271); + polygon.AddContour (); + polygon.AddVertex (266, 397); + polygon.AddVertex (217, 364); + polygon.AddVertex (405, 354); + polygon.AddContour (); + polygon.AddVertex (526, 407); + polygon.AddVertex (442, 381); + polygon.AddVertex (468, 375); + polygon.AddVertex (510, 378); + polygon.AddVertex (554, 394); + polygon.AddVertex (581, 411); + polygon.AddContour (); + polygon.AddVertex (374, 398); + polygon.AddVertex (385, 373); + polygon.AddVertex (402, 390); + polygon.AddVertex (411, 375); + polygon.AddVertex (420, 397); + polygon.AddVertex (429, 380); + polygon.AddVertex (441, 403); + polygon.AddVertex (416, 470); + polygon.AddVertex (406, 401); + polygon.AddContour (); + polygon.AddVertex (126, 465); + polygon.AddVertex (107, 447); + polygon.AddVertex (184, 368); + polygon.AddVertex (255, 406); + polygon.AddVertex (250, 418); + polygon.AddVertex (178, 389); + polygon.AddVertex (144, 420); + polygon.AddVertex (151, 432); + polygon.AddVertex (142, 455); + polygon.AddContour (); + polygon.AddVertex (238, 339); + polygon.AddVertex (264, 304); + polygon.AddVertex (276, 342); + polygon.AddVertex (298, 317); + polygon.AddVertex (312, 327); + polygon.AddVertex (323, 318); + polygon.AddVertex (352, 345); + polygon.AddVertex (369, 326); + polygon.AddVertex (373, 349); + polygon.AddVertex (314, 353); + polygon.AddVertex (312, 339); + polygon.AddVertex (275, 355); + test.AssertEqualNum (polygon.GetArea (), 56177.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test23', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (84, 534); + polygon.AddVertex (98, 167); + polygon.AddVertex (663, 156); + polygon.AddVertex (145, 215); + polygon.AddContour (); + polygon.AddVertex (99, 413); + polygon.AddVertex (130, 203); + polygon.AddVertex (458, 173); + polygon.AddVertex (109, 179); + test.AssertEqualNum (polygon.GetArea (), 15951, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test24', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (73, 538); + polygon.AddVertex (724, 555); + polygon.AddVertex (732, 74); + polygon.AddVertex (56, 58); + polygon.AddContour (); + polygon.AddVertex (93, 520); + polygon.AddVertex (97, 443); + polygon.AddVertex (150, 452); + polygon.AddVertex (148, 518); + polygon.AddContour (); + polygon.AddVertex (208, 512); + polygon.AddVertex (188, 462); + polygon.AddVertex (251, 451); + polygon.AddVertex (262, 497); + polygon.AddContour (); + polygon.AddVertex (312, 515); + polygon.AddVertex (284, 450); + polygon.AddVertex (441, 456); + polygon.AddVertex (406, 515); + polygon.AddContour (); + polygon.AddVertex (535, 530); + polygon.AddVertex (495, 448); + polygon.AddVertex (624, 446); + polygon.AddVertex (625, 502); + polygon.AddContour (); + polygon.AddVertex (676, 422); + polygon.AddVertex (597, 375); + polygon.AddVertex (646, 307); + polygon.AddVertex (708, 342); + polygon.AddContour (); + polygon.AddVertex (463, 413); + polygon.AddVertex (515, 323); + polygon.AddVertex (573, 341); + polygon.AddVertex (590, 428); + polygon.AddContour (); + polygon.AddVertex (386, 403); + polygon.AddVertex (291, 353); + polygon.AddVertex (354, 305); + polygon.AddVertex (451, 345); + polygon.AddContour (); + polygon.AddVertex (243, 406); + polygon.AddVertex (174, 373); + polygon.AddVertex (243, 300); + polygon.AddVertex (290, 378); + polygon.AddContour (); + polygon.AddVertex (178, 421); + polygon.AddVertex (110, 422); + polygon.AddVertex (102, 296); + polygon.AddVertex (160, 295); + polygon.AddVertex (129, 364); + polygon.AddContour (); + polygon.AddVertex (106, 270); + polygon.AddVertex (93, 206); + polygon.AddVertex (198, 208); + polygon.AddVertex (195, 262); + polygon.AddContour (); + polygon.AddVertex (219, 287); + polygon.AddVertex (252, 200); + polygon.AddVertex (335, 224); + polygon.AddVertex (317, 271); + polygon.AddContour (); + polygon.AddVertex (387, 288); + polygon.AddVertex (356, 261); + polygon.AddVertex (394, 194); + polygon.AddVertex (456, 198); + polygon.AddContour (); + polygon.AddVertex (464, 301); + polygon.AddVertex (497, 223); + polygon.AddVertex (565, 229); + polygon.AddVertex (562, 285); + polygon.AddContour (); + polygon.AddVertex (629, 279); + polygon.AddVertex (601, 265); + polygon.AddVertex (596, 202); + polygon.AddVertex (683, 192); + polygon.AddContour (); + polygon.AddVertex (545, 204); + polygon.AddVertex (482, 194); + polygon.AddVertex (491, 119); + polygon.AddVertex (576, 108); + polygon.AddContour (); + polygon.AddVertex (700, 143); + polygon.AddVertex (640, 167); + polygon.AddVertex (616, 109); + polygon.AddVertex (675, 102); + polygon.AddContour (); + polygon.AddVertex (440, 112); + polygon.AddVertex (372, 153); + polygon.AddVertex (305, 129); + polygon.AddVertex (311, 97); + polygon.AddVertex (426, 87); + polygon.AddContour (); + polygon.AddVertex (321, 178); + polygon.AddVertex (285, 195); + polygon.AddVertex (157, 161); + polygon.AddVertex (175, 126); + polygon.AddVertex (265, 96); + polygon.AddContour (); + polygon.AddVertex (95, 172); + polygon.AddVertex (68, 84); + polygon.AddVertex (194, 71); + polygon.AddVertex (106, 107); + test.AssertEqualNum (polygon.GetArea (), 207382.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +generatedSuite.AddTest ('Test25', function (test) { + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (81, 542); + polygon.AddVertex (225, 542); + polygon.AddVertex (544, 542); + polygon.AddVertex (741, 386); + polygon.AddVertex (689, 133); + polygon.AddVertex (385, 33); + polygon.AddVertex (86, 47); + polygon.AddVertex (32, 244); + polygon.AddVertex (116, 95); + polygon.AddVertex (335, 73); + polygon.AddVertex (488, 106); + polygon.AddVertex (656, 152); + polygon.AddVertex (684, 358); + polygon.AddVertex (536, 491); + polygon.AddVertex (591, 180); + polygon.AddVertex (125, 137); + polygon.AddVertex (32, 378); + polygon.AddContour (); + polygon.AddVertex (107, 500); + polygon.AddVertex (66, 376); + polygon.AddVertex (144, 160); + polygon.AddVertex (568, 198); + polygon.AddVertex (505, 512); + test.AssertEqualNum (polygon.GetArea (), 94397.5, JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); + var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +} diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index 43cf81b5..024fa997 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 8eab81c1..1e6ba3f6 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index 2f23c80c..8baab746 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index 59c073ed..591c1330 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index 0997393c..14286652 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 66e62917..adff42fd 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index d7464344..50c41909 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -30,8 +30,10 @@ - - + + + + diff --git a/tools/files.txt b/tools/files.txt index 128a1cd9..95691ef6 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -18,8 +18,10 @@ ../src/geometry/plane.js ../src/geometry/projection.js ../src/geometry/convexhull.js -../src/geometry/polygon.js -../src/geometry/polygonutils.js +../src/geometry/polygon2d.js +../src/geometry/triangulation.js +../src/geometry/oldpolygon.js +../src/geometry/oldpolygonutils.js ../src/geometry/octree.js ../src/geometry/bsptree.js ../src/geometry/utilities.js From d9a6f99eeec9631c95429bd7b121f01a83100fd1 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 18 Jul 2015 09:07:51 +0200 Subject: [PATCH 11/27] Make unit tests use the new polygon class. --- build/jsmodeler.js | 29 +- documentation/jsmdoc/include/jsmdoc.json | 10 - documentation/olddemo/include/tridemo.js | 6 +- src/geometry/oldpolygonutils.js | 39 - src/geometry/polygon2d.js | 16 +- src/geometry/triangulation.js | 20 +- test/unittest/tests/geometry.js | 902 ----------------------- test/unittest/tests/polygon.js | 52 +- test/unittest/tests/triangulation.js | 752 ++++++++++++++++++- 9 files changed, 777 insertions(+), 1049 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 3bf7dd13..3da13bf2 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -78,18 +78,18 @@ JSM.ConvexHull3D=function(a){function b(){this.position=null}function c(){this.t a.tri1!=b&&a.tri2!=b&&(-1==a.tri1?a.tri1=b:-1==a.tri2&&(a.tri2=b));return f}function h(a,b,c,e){var g=a.triangles.length,h=f(a,g,b,c),k=f(a,g,c,e),g=f(a,g,e,b),l=new d;l.vertices=[b,c,e];l.edges=[h,k,g];l.valid=!0;a.triangles.push(l);return a.triangles.length-1}function g(a,b,c){a=a.edges[c];a.tri1==b?a.tri1=-1:a.tri2==b&&(a.tri2=-1)}function l(a,b,c,d,e){c=a.vertices[c].position;d=a.vertices[d].position;e=a.vertices[e].position;a=JSM.CoordSub(a.vertices[b].position,e);b=JSM.CoordSub(c,e);c=JSM.CoordSub(d, e);return JSM.VectorDot(a,JSM.VectorCross(b,c))/6}function k(a,b){var c=[],d,e;for(d=0;dn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qf)return e;var h,g,l,k,m;for(h=0;ha)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;cg))if(3==g)f.push(h.map);else{g=c(h.polygon);if(null===g)return null;void 0!==b&&null!==b&&b(h.polygon,g);h=d(h,g);e.push(h.resultData1);e.push(h.resultData2)}return f};JSM.TriangulateSimpleConcavePolygon=function(a){return JSM.TriangulateSimpleConcavePolygonDiagonal(a)}; -JSM.TriangulateSimplePolygon=function(a){if(null===a)return null;var b=a.VertexCount();return 3>b?null:3==b?[[0,1,2]]:a.GetComplexity()==JSM.Complexity.Convex?JSM.TriangulateSimpleConvexPolygon(a):JSM.TriangulateSimpleConcavePolygon(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; +a.AddVertexCoord(d)})(b,a,d);return!0}var c=a.ContourCount(),d=a.GetContour(0).Clone();if(1==c)return d;var e=[],f;for(f=1;ff))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; +JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();return 3>b?null:3==b?[[0,1,2]]:a.GetComplexity()==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; JSM.OldPolygon2D.prototype.SetVertex=function(a,b,c){this.vertices[a].Set(b,c)};JSM.OldPolygon2D.prototype.VertexCount=function(){return this.vertices.length};JSM.OldPolygon2D.prototype.Clear=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.Clone=function(){var a=new JSM.OldPolygon2D,b;for(b=0;b=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& (g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var h=[],g,l,k;for(g=0;gb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;af;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else D("Skip chunk ("+c.toString(16)+", "+d+")",4), a.Skip(d-6)})}function ca(a,b,c){D("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?D("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?D("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):D("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){D("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==B?ca(a,b,c):(D("Skip chunk ("+ b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; diff --git a/documentation/jsmdoc/include/jsmdoc.json b/documentation/jsmdoc/include/jsmdoc.json index e4ce5141..923274db 100644 --- a/documentation/jsmdoc/include/jsmdoc.json +++ b/documentation/jsmdoc/include/jsmdoc.json @@ -1021,16 +1021,6 @@ ["integer[3][*]", "the result"] ] }, - "CheckTriangulation2D" : { - "description" : "Checks a triangulation created with PolygonTriangulate2D. It checks if the area of triangles equal to the area of the original polygon.", - "parameters" : [ - ["polygon", "OldPolygon2D", "the polygon"], - ["triangles", "integer[3][*]", "the triangulation"] - ], - "returns" : [ - ["boolean", "the result"] - ] - }, "CreatePolygonWithHole" : { "description" : "Creates a simple polygon from multiple contours by creating in-out edges between contours. The input array should contain null values at contour ends.", "parameters" : [ diff --git a/documentation/olddemo/include/tridemo.js b/documentation/olddemo/include/tridemo.js index fbb65b49..59670db7 100644 --- a/documentation/olddemo/include/tridemo.js +++ b/documentation/olddemo/include/tridemo.js @@ -42,7 +42,7 @@ JSMTriangulationDemo.prototype = DrawTriangulation : function (result) { - if (result.length < 1) { + if (result === null || result.length < 1) { return false; } @@ -74,7 +74,7 @@ JSMTriangulationDemo.prototype = return false; } - var polygon = new JSM.OldPolygon2D (); + var polygon = new JSM.Polygon2D (); var i, current; for (i = 0; i < coords.length; i++) { @@ -82,7 +82,7 @@ JSMTriangulationDemo.prototype = polygon.AddVertex (current[0], current[1]); } - var result = JSM.PolygonTriangulate2D (polygon); + var result = JSM.TriangulatePolygon2D (polygon); this.editor.Enable (false); this.DrawTriangulation (result); return true; diff --git a/src/geometry/oldpolygonutils.js b/src/geometry/oldpolygonutils.js index 8b8ca469..dfc3e587 100644 --- a/src/geometry/oldpolygonutils.js +++ b/src/geometry/oldpolygonutils.js @@ -682,45 +682,6 @@ JSM.PolygonTriangulate2D = function (polygon) return GetResult (resultPolygons, orientation); }; -/** -* Function: CheckTriangulation2D -* Description: -* Checks a triangulation created with PolygonTriangulate2D. It checks if -* the area of triangles equal to the area of the original polygon. -* Parameters: -* polygon {OldPolygon2D} the polygon -* triangles {integer[3][*]} the triangulation -* Returns: -* {boolean} the result -*/ -JSM.CheckTriangulation2D = function (polygon, triangles) -{ - var polygonArea = JSM.PolygonSignedArea2D (polygon); - var trianglesArea = 0.0; - - var i, j, triangle, currentTriangle, vertex; - for (i = 0; i < triangles.length; i++) { - triangle = triangles[i]; - if (triangle.length !== 3) { - return false; - } - - currentTriangle = new JSM.OldPolygon2D (); - for (j = 0; j < triangle.length; j++) { - vertex = polygon.GetVertex (triangle[j]); - currentTriangle.AddVertex (vertex.x, vertex.y); - } - - trianglesArea += JSM.PolygonSignedArea2D (currentTriangle); - } - - if (!JSM.IsEqual (polygonArea, trianglesArea)) { - return false; - } - - return true; -}; - /** * Function: CreatePolygonWithHole * Description: diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js index 126eeb07..96793cdb 100644 --- a/src/geometry/polygon2d.js +++ b/src/geometry/polygon2d.js @@ -5,7 +5,7 @@ JSM.Complexity = { Complex : 3 }; -JSM.PointPosition = { +JSM.CoordPosition = { OnVertex : 0, OnEdge : 1, Inside : 2, @@ -162,7 +162,7 @@ JSM.Polygon2D.prototype.IsConcaveVertex = function (index) return vertexOrientation != orientation; }; -JSM.Polygon2D.prototype.PointPosition = function (coord) +JSM.Polygon2D.prototype.CoordPosition = function (coord) { function IntersectionCount (coord, beg, end) { @@ -218,17 +218,17 @@ JSM.Polygon2D.prototype.PointPosition = function (coord) sector = new JSM.Sector2D (edgeFrom, edgeTo); position = sector.CoordPosition (coord); if (position == JSM.CoordSectorPosition2D.CoordInsideOfSector) { - return JSM.PointPosition.OnEdge; + return JSM.CoordPosition.OnEdge; } else if (position == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - return JSM.PointPosition.OnVertex; + return JSM.CoordPosition.OnVertex; } intersections += IntersectionCount (coord, edgeFrom, edgeTo); } if (intersections % 2 !== 0) { - return JSM.PointPosition.Inside; + return JSM.CoordPosition.Inside; } - return JSM.PointPosition.Outside; + return JSM.CoordPosition.Outside; }; JSM.Polygon2D.prototype.SectorPosition = function (beg, end, begIndex, endIndex) @@ -285,8 +285,8 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) (fromVertex.x + toVertex.x) / 2.0, (fromVertex.y + toVertex.y) / 2.0 ); - var position = polygon.PointPosition (midCoord); - return position == JSM.PointPosition.Inside; + var position = polygon.CoordPosition (midCoord); + return position == JSM.CoordPosition.Inside; } if (from == to) { diff --git a/src/geometry/triangulation.js b/src/geometry/triangulation.js index 898f3494..a88e886c 100644 --- a/src/geometry/triangulation.js +++ b/src/geometry/triangulation.js @@ -1,4 +1,4 @@ -JSM.ConvertPolygonToSimplePolygon = function (inputPolygon) +JSM.ConvertContourPolygonToPolygon2D = function (inputPolygon) { function AddContour (inputPolygon, resultPolygon, holeIndex, conversionData) { @@ -119,7 +119,7 @@ JSM.ConvertPolygonToSimplePolygon = function (inputPolygon) return resultPolygon; }; -JSM.TriangulateSimpleConvexPolygon = function (polygon) +JSM.TriangulateConvexPolygon = function (polygon) { var result = []; var i; @@ -129,7 +129,7 @@ JSM.TriangulateSimpleConvexPolygon = function (polygon) return result; }; -JSM.TriangulateSimpleConcavePolygonDiagonal = function (inputPolygon, onProcess) +JSM.TriangulateConcavePolygon2D = function (inputPolygon) { function GetInitialVertexMap (count) { @@ -209,9 +209,6 @@ JSM.TriangulateSimpleConcavePolygonDiagonal = function (inputPolygon, onProcess) if (diagonal === null) { return null; } - if (onProcess !== undefined && onProcess !== null) { - onProcess (polygonData.polygon, diagonal); - } resultData = SplitPolygon (polygonData, diagonal); polygonStack.push (resultData.resultData1); polygonStack.push (resultData.resultData2); @@ -219,12 +216,7 @@ JSM.TriangulateSimpleConcavePolygonDiagonal = function (inputPolygon, onProcess) return result; }; -JSM.TriangulateSimpleConcavePolygon = function (polygon) -{ - return JSM.TriangulateSimpleConcavePolygonDiagonal (polygon); -}; - -JSM.TriangulateSimplePolygon = function (polygon) +JSM.TriangulatePolygon2D = function (polygon) { if (polygon === null) { return null; @@ -241,8 +233,8 @@ JSM.TriangulateSimplePolygon = function (polygon) var complexity = polygon.GetComplexity (); if (complexity == JSM.Complexity.Convex) { - return JSM.TriangulateSimpleConvexPolygon (polygon); + return JSM.TriangulateConvexPolygon (polygon); } - return JSM.TriangulateSimpleConcavePolygon (polygon); + return JSM.TriangulateConcavePolygon2D (polygon); }; diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index 7942f2ac..4ac2f53d 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -1546,96 +1546,6 @@ generalSuite.AddTest ('TriangleOctreeTest', function (test) var polygonSuite = unitTest.AddTestSuite ('GeometryPolygon'); -polygonSuite.AddTest ('PolygonTest', function (test) -{ - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0.0, 0.0); - polygon.AddVertex (1.0, 0.0); - polygon.AddVertex (0.0, 1.0); - test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon), 0.5)); - test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.CounterClockwise); - test.Assert (JSM.PolygonComplexity2D (polygon) == JSM.Complexity.Convex); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.2, 0.2), polygon) == 'CoordInsideOfPolygon'); - - JSM.ChangePolygonOrientation2D (polygon); - test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon), -0.5)); - test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.Clockwise); - test.Assert (JSM.PolygonComplexity2D (polygon) == JSM.Complexity.Convex); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.2, 0.2), polygon) == 'CoordInsideOfPolygon'); - - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0.0, 0.0); - polygon.AddVertex (1.0, 0.0); - - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (triangles.length == 0); - - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0.0, 0.0); - polygon.AddVertex (1.0, 0.0); - polygon.AddVertex (1.0, 1.0); - - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (triangles.length == 1); - test.Assert (triangles[0].toString () == '0,1,2'); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles) == true); - - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0.0, 0.0); - polygon.AddVertex (1.0, 0.0); - polygon.AddVertex (1.0, 1.0); - polygon.AddVertex (0.0, 1.0); - test.Assert (JSM.IsPolygonVertexVisible2D (polygon, 0, 2) == true); - - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (triangles.length == 2); - test.Assert (triangles[0].toString () == '0,1,2'); - test.Assert (triangles[1].toString () == '0,2,3'); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles) == true); - - var polygon = new JSM.Polygon (); - polygon.AddVertex (0.0, 0.0, 0.0); - polygon.AddVertex (1.0, 0.0, 0.0); - polygon.AddVertex (1.0, 1.0, 0.0); - polygon.AddVertex (0.0, 1.0, 0.0); - var triangles = JSM.PolygonTriangulate (polygon); - test.Assert (triangles.length == 2); - test.Assert (triangles[0].toString () == '0,1,2'); - test.Assert (triangles[1].toString () == '0,2,3'); - - var vertices = [ - new JSM.Coord2D (-0.5, -0.5), - new JSM.Coord2D (0.5, -0.5), - new JSM.Coord2D (0.5, 0.5), - new JSM.Coord2D (0.0, 0.5), - new JSM.Coord2D (0.0, 0.0), - new JSM.Coord2D (-0.5, 0.0) - ] - - var polygon = JSM.CreatePolygonFromVertices (vertices); - test.Assert (polygon.VertexCount () == 6); - - vertices[0].x = 1.0; - vertices[0].y = 1.0; - - test.Assert (polygon.GetVertex (0).x == -0.5 && polygon.GetVertex (0).y == -0.5); - - var vertices = [ - new JSM.Coord2D (-0.5, 0.0), - new JSM.Coord2D (0.0, 0.0), - new JSM.Coord2D (0.0, 0.5), - new JSM.Coord2D (0.5, 0.5), - new JSM.Coord2D (0.5, -0.5), - new JSM.Coord2D (-0.5, -0.5), - ]; - - var polygon = JSM.CreatePolygonFromVertices (vertices); - test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.Clockwise); - - var polygon = JSM.CreateCCWPolygonFromVertices (vertices); - test.Assert (JSM.PolygonOrientation2D (polygon) == JSM.Orientation.CounterClockwise); -}); - polygonSuite.AddTest ('ContourPolygon2DTest', function (test) { var polygon = new JSM.OldContourPolygon2D (); @@ -1842,141 +1752,6 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (JSM.SectorIntersectsPolygon2D (polygon4, GetSector (0, 0, 1, 1), 0, -1) == false); }); -polygonSuite.AddTest ('PolygonTriangulation2DTest', function (test) -{ - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0.0, 0.0); - polygon.AddVertex (3.0, 0.0); - polygon.AddVertex (3.0, 2.0); - polygon.AddVertex (1.5, 3.0); - polygon.AddVertex (0.0, 2.0); - - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 3); - test.Assert (triangles[0].toString () == [0, 1, 2].toString ()); - test.Assert (triangles[1].toString () == [0, 2, 3].toString ()); - test.Assert (triangles[2].toString () == [0, 3, 4].toString ()); - - var polygon2 = new JSM.OldPolygon2D (); - polygon2.AddVertex (0.0, 0.0); - polygon2.AddVertex (3.0, 0.0); - polygon2.AddVertex (3.0, 2.0); - polygon2.AddVertex (2.0, 2.0); - polygon2.AddVertex (2.0, 1.0); - polygon2.AddVertex (1.0, 1.0); - polygon2.AddVertex (1.0, 2.0); - polygon2.AddVertex (0.0, 2.0); - - var triangles = JSM.PolygonTriangulate2D (polygon2); - test.Assert (JSM.CheckTriangulation2D (polygon2, triangles)); - test.Assert (triangles.length == 6); - test.Assert (triangles[0].toString () == [1, 4, 0].toString ()); - test.Assert (triangles[1].toString () == [5, 0, 4].toString ()); - test.Assert (triangles[2].toString () == [2, 4, 1].toString ()); - test.Assert (triangles[3].toString () == [4, 2, 3].toString ()); - test.Assert (triangles[4].toString () == [6, 0, 5].toString ()); - test.Assert (triangles[5].toString () == [0, 6, 7].toString ()); - - var polygon2cw = new JSM.OldPolygon2D (); - polygon2cw.AddVertex (0.0, 0.0); - polygon2cw.AddVertex (0.0, 2.0); - polygon2cw.AddVertex (1.0, 2.0); - polygon2cw.AddVertex (1.0, 1.0); - polygon2cw.AddVertex (2.0, 1.0); - polygon2cw.AddVertex (2.0, 2.0); - polygon2cw.AddVertex (3.0, 2.0); - polygon2cw.AddVertex (3.0, 0.0); - - var triangles = JSM.PolygonTriangulate2D (polygon2cw); - test.Assert (JSM.CheckTriangulation2D (polygon2cw, triangles)); - test.Assert (triangles.length == 6); - test.Assert (triangles[0].toString () == [6, 7, 5].toString ()); - test.Assert (triangles[1].toString () == [5, 7, 4].toString ()); - test.Assert (triangles[2].toString () == [4, 7, 3].toString ()); - test.Assert (triangles[3].toString () == [2, 3, 1].toString ()); - test.Assert (triangles[4].toString () == [1, 3, 0].toString ()); - test.Assert (triangles[5].toString () == [7, 0, 3].toString ()); - - var polygon3 = new JSM.OldPolygon2D (); - polygon3.AddVertex (0.0, 0.0); - polygon3.AddVertex (5.0, 0.0); - polygon3.AddVertex (5.0, 1.0); - polygon3.AddVertex (1.0, 1.0); - polygon3.AddVertex (1.0, 5.0); - polygon3.AddVertex (4.0, 5.0); - polygon3.AddVertex (4.0, 3.0); - polygon3.AddVertex (3.0, 3.0); - polygon3.AddVertex (3.0, 4.0); - polygon3.AddVertex (2.0, 4.0); - polygon3.AddVertex (2.0, 2.0); - polygon3.AddVertex (5.0, 2.0); - polygon3.AddVertex (5.0, 6.0); - polygon3.AddVertex (0.0, 6.0); - - var triangles = JSM.PolygonTriangulate2D (polygon3); - test.Assert (JSM.CheckTriangulation2D (polygon3, triangles)); - test.Assert (triangles.length == 12); - test.Assert (triangles[0].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[1].toString () == [3, 0, 2].toString ()); - test.Assert (triangles[2].toString () == [4, 0, 3].toString ()); - test.Assert (triangles[3].toString () == [5, 12, 4].toString ()); - test.Assert (triangles[4].toString () == [13, 4, 12].toString ()); - test.Assert (triangles[5].toString () == [4, 13, 0].toString ()); - test.Assert (triangles[6].toString () == [6, 12, 5].toString ()); - test.Assert (triangles[7].toString () == [7, 10, 6].toString ()); - test.Assert (triangles[8].toString () == [11, 6, 10].toString ()); - test.Assert (triangles[9].toString () == [6, 11, 12].toString ()); - test.Assert (triangles[10].toString () == [8, 10, 7].toString ()); - test.Assert (triangles[11].toString () == [10, 8, 9].toString ()); - - var polygon4 = new JSM.OldPolygon2D (); - polygon4.AddVertex (52, 221); - polygon4.AddVertex (101, 89); - polygon4.AddVertex (244, 89); - polygon4.AddVertex (188, 222); - polygon4.AddVertex (104, 219); - polygon4.AddVertex (135, 139); - polygon4.AddVertex (167, 140); - polygon4.AddVertex (152, 189); - polygon4.AddVertex (170, 189); - polygon4.AddVertex (192, 118); - polygon4.AddVertex (118, 121); - polygon4.AddVertex (77, 223); - - var triangles = JSM.PolygonTriangulate2D (polygon4); - test.Assert (JSM.CheckTriangulation2D (polygon4, triangles)); - test.Assert (triangles.length == 10); - - var polygon5 = new JSM.OldPolygon2D (); - polygon5.AddVertex (1, 0); - polygon5.AddVertex (2, 0); - polygon5.AddVertex (2, 1); - polygon5.AddVertex (3, 1); - polygon5.AddVertex (3, 2); - polygon5.AddVertex (2, 2); - polygon5.AddVertex (2, 3); - polygon5.AddVertex (1, 3); - polygon5.AddVertex (1, 2); - polygon5.AddVertex (0, 2); - polygon5.AddVertex (0, 1); - polygon5.AddVertex (1, 1); - - var triangles = JSM.PolygonTriangulate2D (polygon5); - test.Assert (JSM.CheckTriangulation2D (polygon5, triangles)); - test.Assert (triangles.length == 10); - test.Assert (triangles[0].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[1].toString () == [2, 5, 0].toString ()); - test.Assert (triangles[2].toString () == [6, 0, 5].toString ()); - test.Assert (triangles[3].toString () == [3, 5, 2].toString ()); - test.Assert (triangles[4].toString () == [5, 3, 4].toString ()); - test.Assert (triangles[5].toString () == [8, 6, 7].toString ()); - test.Assert (triangles[6].toString () == [6, 11, 0].toString ()); - test.Assert (triangles[7].toString () == [8, 11, 6].toString ()); - test.Assert (triangles[8].toString () == [9, 11, 8].toString ()); - test.Assert (triangles[9].toString () == [11, 9, 10].toString ()); -}); - polygonSuite.AddTest ('PolygonTriangulationTest', function (test) { var polygon = new JSM.Polygon (); @@ -2022,282 +1797,6 @@ polygonSuite.AddTest ('PolygonOffsetTest', function (test) test.Assert (offseted.vertices[4].IsEqual (new JSM.Coord (0.8, 1.1527864045000422, 0.0))); }); -polygonSuite.AddTest ('PolygonWithHole2DTest', function (test) -{ - var polygon = new JSM.OldPolygon2D (); - polygon.AddVertex (0, 0); - polygon.AddVertex (3, 0); - polygon.AddVertex (3, 3); - polygon.AddVertex (0, 3); - polygon.AddVertex (0, 0); - polygon.AddVertex (1, 1); - polygon.AddVertex (1, 2); - polygon.AddVertex (2, 2); - polygon.AddVertex (2, 1); - polygon.AddVertex (1, 1); - - test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon), 8.0)); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 0.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.0, 1.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (2.0, 2.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (3.0, 3.0), polygon) == 'CoordOnPolygonEdge'); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (-1.0, -1.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (4.0, 4.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (-1.0, 1.5), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (4.0, 1.5), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 1.5), polygon) == 'CoordOutsideOfPolygon'); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 0.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (2.5, 1.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 2.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.5, 1.5), polygon) == 'CoordInsideOfPolygon'); - - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 8); - test.Assert (triangles[0].toString () == [2, 7, 1].toString ()); - test.Assert (triangles[1].toString () == [8, 1, 7].toString ()); - test.Assert (triangles[2].toString () == [3, 7, 2].toString ()); - test.Assert (triangles[3].toString () == [9, 1, 8].toString ()); - test.Assert (triangles[4].toString () == [1, 9, 0].toString ()); - test.Assert (triangles[5].toString () == [5, 3, 4].toString ()); - test.Assert (triangles[6].toString () == [6, 3, 5].toString ()); - test.Assert (triangles[7].toString () == [3, 6, 7].toString ()); - - var polygon2 = new JSM.OldPolygon2D (); - polygon2.AddVertex (0, 0); - polygon2.AddVertex (6, 0); - polygon2.AddVertex (6, 3); - polygon2.AddVertex (5, 2); - polygon2.AddVertex (5, 1); - polygon2.AddVertex (4, 1); - polygon2.AddVertex (4, 2); - polygon2.AddVertex (5, 2); - polygon2.AddVertex (6, 3); - polygon2.AddVertex (0, 3); - polygon2.AddVertex (1, 2); - polygon2.AddVertex (2, 2); - polygon2.AddVertex (2, 1); - polygon2.AddVertex (1, 1); - polygon2.AddVertex (1, 2); - polygon2.AddVertex (0, 3); - - test.Assert (JSM.IsEqual (JSM.PolygonSignedArea2D (polygon2), 16.0)); - - var triangles = JSM.PolygonTriangulate2D (polygon2); - test.Assert (JSM.CheckTriangulation2D (polygon2, triangles)); - test.Assert (triangles.length == 14); - test.Assert (triangles[0].toString () == [1, 4, 0].toString ()); - test.Assert (triangles[1].toString () == [5, 0, 4].toString ()); - test.Assert (triangles[2].toString () == [2, 4, 1].toString ()); - test.Assert (triangles[3].toString () == [4, 2, 3].toString ()); - test.Assert (triangles[4].toString () == [5, 12, 0].toString ()); - test.Assert (triangles[5].toString () == [13, 0, 12].toString ()); - test.Assert (triangles[6].toString () == [6, 12, 5].toString ()); - test.Assert (triangles[7].toString () == [14, 0, 13].toString ()); - test.Assert (triangles[8].toString () == [0, 14, 15].toString ()); - test.Assert (triangles[9].toString () == [8, 6, 7].toString ()); - test.Assert (triangles[10].toString () == [9, 6, 8].toString ()); - test.Assert (triangles[11].toString () == [6, 11, 12].toString ()); - test.Assert (triangles[12].toString () == [9, 11, 6].toString ()); - test.Assert (triangles[13].toString () == [11, 9, 10].toString ()); - - var polygon3 = new JSM.OldPolygon2D (); - polygon3.AddVertex (0, 0); - polygon3.AddVertex (5, 0); - polygon3.AddVertex (2.5, 5); - polygon3.AddVertex (2, 2); - polygon3.AddVertex (3, 2); - polygon3.AddVertex (3, 1); - polygon3.AddVertex (2, 1); - polygon3.AddVertex (2, 2); - polygon3.AddVertex (2.5, 5); - - var triangles = JSM.PolygonTriangulate2D (polygon3); - test.Assert (JSM.CheckTriangulation2D (polygon3, triangles)); - test.Assert (triangles.length == 7); - test.Assert (triangles[0].toString () == [1, 5, 0].toString ()); - test.Assert (triangles[1].toString () == [6, 0, 5].toString ()); - test.Assert (triangles[2].toString () == [1, 4, 5].toString ()); - test.Assert (triangles[3].toString () == [7, 0, 6].toString ()); - test.Assert (triangles[4].toString () == [0, 7, 8].toString ()); - test.Assert (triangles[5].toString () == [2, 4, 1].toString ()); - test.Assert (triangles[6].toString () == [4, 2, 3].toString ()); -}); - -polygonSuite.AddTest ('CreatePolygonWithHole2DTest', function (test) -{ - function CreatePolygon2D (vertices, indices) - { - var result = new JSM.OldPolygon2D (); - - var i, vertex; - for (i = 0; i < indices.length; i++) { - vertex = vertices[indices[i]]; - result.AddVertex (vertex.x, vertex.y); - } - - return result; - } - - var vertices = [ - new JSM.Coord2D (0, 0), - new JSM.Coord2D (7, 0), - new JSM.Coord2D (7, 3), - new JSM.Coord2D (0, 3) - ]; - - var indices = JSM.CreatePolygonWithHole2D (vertices); - test.Assert (indices.toString () == [0, 1, 2, 3].toString ()); - - var polygon = CreatePolygon2D (vertices, indices); - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 2); - test.Assert (triangles[0].toString () == [0, 1, 2].toString ()); - test.Assert (triangles[1].toString () == [0, 2, 3].toString ()); - - var vertices = [ - new JSM.Coord2D (0, 0), - new JSM.Coord2D (7, 0), - new JSM.Coord2D (7, 3), - new JSM.Coord2D (0, 3), - null, - new JSM.Coord2D (1, 1), - new JSM.Coord2D (1, 2), - new JSM.Coord2D (2, 2), - new JSM.Coord2D (2, 1), - ]; - - var indices = JSM.CreatePolygonWithHole2D (vertices); - test.Assert (indices.toString () == [0, 5, 6, 7, 8, 5, 0, 1, 2, 3].toString ()); - - var polygon = CreatePolygon2D (vertices, indices); - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 8); - test.Assert (triangles[0].toString () == [3, 8, 2].toString ()); - test.Assert (triangles[1].toString () == [9, 2, 8].toString ()); - test.Assert (triangles[2].toString () == [4, 8, 3].toString ()); - test.Assert (triangles[3].toString () == [0, 2, 9].toString ()); - test.Assert (triangles[4].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[5].toString () == [8, 6, 7].toString ()); - test.Assert (triangles[6].toString () == [4, 6, 8].toString ()); - test.Assert (triangles[7].toString () == [6, 4, 5].toString ()); - - var vertices = [ - new JSM.Coord2D (0, 0), - new JSM.Coord2D (7, 0), - new JSM.Coord2D (7, 3), - new JSM.Coord2D (0, 3), - null, - new JSM.Coord2D (1, 1), - new JSM.Coord2D (1, 2), - new JSM.Coord2D (2, 2), - new JSM.Coord2D (2, 1), - null, - new JSM.Coord2D (3, 1), - new JSM.Coord2D (3, 2), - new JSM.Coord2D (4, 2), - new JSM.Coord2D (4, 1), - ]; - - var indices = JSM.CreatePolygonWithHole2D (vertices); - test.Assert (indices.toString () == [0, 5, 6, 7, 10, 11, 12, 13, 10, 7, 8, 5, 0, 1, 2, 3].toString ()); - - var polygon = CreatePolygon2D (vertices, indices); - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 14); - test.Assert (triangles[0].toString () == [15, 2, 14].toString ()); - test.Assert (triangles[1].toString () == [5, 3, 4].toString ()); - test.Assert (triangles[2].toString () == [6, 14, 5].toString ()); - test.Assert (triangles[3].toString () == [0, 2, 15].toString ()); - test.Assert (triangles[4].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[5].toString () == [14, 3, 5].toString ()); - test.Assert (triangles[6].toString () == [3, 14, 2].toString ()); - test.Assert (triangles[7].toString () == [7, 14, 6].toString ()); - test.Assert (triangles[8].toString () == [8, 12, 7].toString ()); - test.Assert (triangles[9].toString () == [13, 7, 12].toString ()); - test.Assert (triangles[10].toString () == [7, 13, 14].toString ()); - test.Assert (triangles[11].toString () == [12, 10, 11].toString ()); - test.Assert (triangles[12].toString () == [8, 10, 12].toString ()); - test.Assert (triangles[13].toString () == [10, 8, 9].toString ()); - - var vertices = [ - new JSM.Coord2D (0, 0), - new JSM.Coord2D (7, 0), - new JSM.Coord2D (7, 3), - new JSM.Coord2D (0, 3), - null, - new JSM.Coord2D (1, 1), - new JSM.Coord2D (1, 2), - new JSM.Coord2D (2, 2), - new JSM.Coord2D (2, 1), - null, - new JSM.Coord2D (3, 1), - new JSM.Coord2D (3, 2), - new JSM.Coord2D (4, 2), - new JSM.Coord2D (4, 1), - null, - new JSM.Coord2D (5, 1), - new JSM.Coord2D (5, 2), - new JSM.Coord2D (6, 2), - new JSM.Coord2D (6, 1) - ]; - - var indices = JSM.CreatePolygonWithHole2D (vertices); - test.Assert (indices.toString () == [0, 5, 6, 7, 10, 11, 12, 15, 16, 17, 18, 15, 12, 13, 10, 7, 8, 5, 0, 1, 2, 3].toString ()); - - var polygon = CreatePolygon2D (vertices, indices); - var triangles = JSM.PolygonTriangulate2D (polygon); - test.Assert (JSM.CheckTriangulation2D (polygon, triangles)); - test.Assert (triangles.length == 20); - test.Assert (triangles[0].toString () == [21, 2, 20].toString ()); - test.Assert (triangles[1].toString () == [5, 3, 4].toString ()); - test.Assert (triangles[2].toString () == [0, 2, 21].toString ()); - test.Assert (triangles[3].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[4].toString () == [20, 3, 5].toString ()); - test.Assert (triangles[5].toString () == [3, 20, 2].toString ()); - test.Assert (triangles[6].toString () == [8, 6, 7].toString ()); - test.Assert (triangles[7].toString () == [9, 20, 8].toString ()); - test.Assert (triangles[8].toString () == [20, 6, 8].toString ()); - test.Assert (triangles[9].toString () == [6, 20, 5].toString ()); - test.Assert (triangles[10].toString () == [10, 20, 9].toString ()); - test.Assert (triangles[11].toString () == [11, 18, 10].toString ()); - test.Assert (triangles[12].toString () == [19, 10, 18].toString ()); - test.Assert (triangles[13].toString () == [10, 19, 20].toString ()); - test.Assert (triangles[14].toString () == [11, 13, 18].toString ()); - test.Assert (triangles[15].toString () == [13, 11, 12].toString ()); - test.Assert (triangles[16].toString () == [14, 18, 13].toString ()); - test.Assert (triangles[17].toString () == [18, 16, 17].toString ()); - test.Assert (triangles[18].toString () == [14, 16, 18].toString ()); - test.Assert (triangles[19].toString () == [16, 14, 15].toString ()); - - var vertices = [ - new JSM.Coord2D (300.8485412597656, 319.4265441894531), - new JSM.Coord2D (338.24835205078125, 396.81103515625), - new JSM.Coord2D (421.9165954589844, 416.66839599609375), - new JSM.Coord2D (489.1433410644531, 362.9385986328125), - new JSM.Coord2D (489.543701171875, 276.95245361328125), - new JSM.Coord2D (422.18115234375, 223.48004150390625), - new JSM.Coord2D (337.93084716796875, 241.53892517089844), - null, - new JSM.Coord2D (400.6557922363281, 231.74929809570312), - new JSM.Coord2D (468.43548583984375, 264.9992980957031), - new JSM.Coord2D (484.7142639160156, 338.9593505859375), - new JSM.Coord2D (437.7185363769531, 398.06951904296875), - new JSM.Coord2D (362.0542297363281, 397.45257568359375), - new JSM.Coord2D (315.2279052734375, 338.1394348144531), - new JSM.Coord2D (332.49664306640625, 264.4938659667969) - ]; - - var indices = JSM.CreatePolygonWithHole2D (vertices); - test.Assert (indices.toString () == [0, 13, 14, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6].toString ()); -}); - polygonSuite.AddTest ('CreatePolygonWithHoleTest', function (test) { function CreatePolygon (vertices, indices) @@ -2383,407 +1882,6 @@ polygonSuite.AddTest ('CreatePolygonWithHoleTest', function (test) } }); -polygonSuite.AddTest ('TriangulationWithHole2DTest', function (test) { - function TestTriangulation (basePolygon, refIndices) - { - var polygonIndices = JSM.CreatePolygonWithHole2D (basePolygon); - if (polygonIndices.toString () != refIndices.toString ()) { - return false; - } - var polygon = new JSM.OldPolygon2D (); - var i, vertex; - for (i = 0; i < polygonIndices.length; i++) { - vertex = basePolygon[polygonIndices[i]]; - polygon.AddVertex (vertex.x, vertex.y); - } - var triangles = JSM.PolygonTriangulate2D (polygon); - if (!JSM.CheckTriangulation2D (polygon, triangles)) { - return false; - } - return true; - } - - var basePolygon = [ - new JSM.Coord2D (14.406249999999998, 0.004463199991732836), - new JSM.Coord2D (12.273693084716795, -0.13337911665439606), - new JSM.Coord2D (10.177939414978026, -0.5507046580314636), - new JSM.Coord2D (8.158322334289549, -1.2485805749893188), - new JSM.Coord2D (6.256920814514159, -2.2232589721679688), - new JSM.Coord2D (4.518617153167724, -3.4653913974761963), - new JSM.Coord2D (2.992141485214233, -4.959873676300049), - new JSM.Coord2D (1.7292572259902952, -6.682513236999512), - new JSM.Coord2D (0.7823054790496825, -8.596776962280273), - new JSM.Coord2D (0.19680410623550412, -10.650409698486328), - new JSM.Coord2D (2.7840769689646545e-9, -12.77676773071289), - new JSM.Coord2D (2.7840769689646545e-9, -58.87051773071289), - new JSM.Coord2D (0.19683623313903806, -60.99687194824219), - new JSM.Coord2D (0.782375395298004, -63.05048370361328), - new JSM.Coord2D (1.7292767763137815, -64.96475982666016), - new JSM.Coord2D (2.992123126983642, -66.68743133544922), - new JSM.Coord2D (4.5186753273010245, -68.18182373046875), - new JSM.Coord2D (6.256915569305419, -69.42404174804688), - new JSM.Coord2D (8.158330917358397, -70.398681640625), - new JSM.Coord2D (10.17793846130371, -71.0965805053711), - new JSM.Coord2D (12.273698806762694, -71.51383209228516), - new JSM.Coord2D (14.406246185302733, -71.65176391601562), - new JSM.Coord2D (385.18749999999994, -71.65176391601562), - new JSM.Coord2D (387.32006835937494, -71.513916015625), - new JSM.Coord2D (389.41580200195307, -71.0965805053711), - new JSM.Coord2D (391.43542480468744, -70.398681640625), - new JSM.Coord2D (393.33679199218744, -69.42398071289062), - new JSM.Coord2D (395.0751342773437, -68.18187713623047), - new JSM.Coord2D (396.6016235351562, -66.6874008178711), - new JSM.Coord2D (397.86450195312494, -64.96475982666016), - new JSM.Coord2D (398.8114624023437, -63.050498962402344), - new JSM.Coord2D (399.39697265624994, -60.99687576293945), - new JSM.Coord2D (399.59374999999994, -58.870513916015625), - new JSM.Coord2D (399.59374999999994, -12.776763916015625), - new JSM.Coord2D (399.39688110351557, -10.650407791137695), - new JSM.Coord2D (398.8113708496093, -8.596782684326172), - new JSM.Coord2D (397.8644714355468, -6.682509422302246), - new JSM.Coord2D (396.6016235351562, -4.95983362197876), - new JSM.Coord2D (395.07510375976557, -3.465416193008423), - new JSM.Coord2D (393.3368530273437, -2.223223924636841), - new JSM.Coord2D (391.43542480468744, -1.2485815286636353), - new JSM.Coord2D (389.41580200195307, -0.5506518483161926), - new JSM.Coord2D (387.3200378417968, -0.13342222571372986), - new JSM.Coord2D (385.18749999999994, 0.004486083984375), - null, - new JSM.Coord2D (357.99999999999994, -10.651786804199219), - new JSM.Coord2D (360.0240173339843, -10.729362487792969), - new JSM.Coord2D (362.0359497070312, -10.963029861450195), - new JSM.Coord2D (364.0234985351562, -11.353105545043945), - new JSM.Coord2D (365.97412109374994, -11.898651123046875), - new JSM.Coord2D (367.87536621093744, -12.597009658813477), - new JSM.Coord2D (369.7149047851562, -13.44465446472168), - new JSM.Coord2D (371.4808044433593, -14.436634063720703), - new JSM.Coord2D (373.1611938476562, -15.567431449890137), - new JSM.Coord2D (374.7445983886718, -16.83041000366211), - new JSM.Coord2D (376.2197875976562, -18.21826934814453), - new JSM.Coord2D (377.57568359374994, -19.722864151000977), - new JSM.Coord2D (378.80154418945307, -21.335163116455078), - new JSM.Coord2D (379.88711547851557, -23.0450382232666), - new JSM.Coord2D (380.82266235351557, -24.84136199951172), - new JSM.Coord2D (381.5994262695312, -26.711843490600586), - new JSM.Coord2D (382.2098999023437, -28.642974853515625), - new JSM.Coord2D (382.64871215820307, -30.620220184326172), - new JSM.Coord2D (382.91235351562494, -32.628326416015625), - new JSM.Coord2D (382.99999999999994, -34.65178680419922), - new JSM.Coord2D (382.91235351562494, -36.67523956298828), - new JSM.Coord2D (382.6486206054687, -38.68333053588867), - new JSM.Coord2D (382.2098083496093, -40.660552978515625), - new JSM.Coord2D (381.59924316406244, -42.591670989990234), - new JSM.Coord2D (380.8226013183593, -44.46219253540039), - new JSM.Coord2D (379.8871459960937, -46.258583068847656), - new JSM.Coord2D (378.8015747070312, -47.96845626831055), - new JSM.Coord2D (377.5756530761718, -49.58070755004883), - new JSM.Coord2D (376.2197875976562, -51.08530807495117), - new JSM.Coord2D (374.7445983886718, -52.47315979003906), - new JSM.Coord2D (373.16116333007807, -53.73616027832031), - new JSM.Coord2D (371.4807739257812, -54.86695861816406), - new JSM.Coord2D (369.7149353027343, -55.85900115966797), - new JSM.Coord2D (367.87536621093744, -56.70659255981445), - new JSM.Coord2D (365.97412109374994, -57.405006408691406), - new JSM.Coord2D (364.0234985351562, -57.95049285888672), - new JSM.Coord2D (362.0359497070312, -58.340576171875), - new JSM.Coord2D (360.0239868164062, -58.574188232421875), - new JSM.Coord2D (357.99999999999994, -58.65178680419922), - new JSM.Coord2D (355.97598266601557, -58.57420349121094), - new JSM.Coord2D (353.9640502929687, -58.340545654296875), - new JSM.Coord2D (351.9765014648437, -57.95048141479492), - new JSM.Coord2D (350.02587890624994, -57.40494155883789), - new JSM.Coord2D (348.12463378906244, -56.706573486328125), - new JSM.Coord2D (346.2850952148437, -55.85893249511719), - new JSM.Coord2D (344.51919555664057, -54.866943359375), - new JSM.Coord2D (342.8388061523437, -53.73613357543945), - new JSM.Coord2D (341.25537109374994, -52.47316360473633), - new JSM.Coord2D (339.78018188476557, -51.085304260253906), - new JSM.Coord2D (338.4242858886718, -49.58070755004883), - new JSM.Coord2D (337.1984252929687, -47.968421936035156), - new JSM.Coord2D (336.1128845214843, -46.25852584838867), - new JSM.Coord2D (335.1773071289062, -44.462196350097656), - new JSM.Coord2D (334.40054321289057, -42.591712951660156), - new JSM.Coord2D (333.79003906249994, -40.66058349609375), - new JSM.Coord2D (333.3512878417968, -38.68334197998047), - new JSM.Coord2D (333.08764648437494, -36.675235748291016), - new JSM.Coord2D (332.99999999999994, -34.65178680419922), - new JSM.Coord2D (333.08764648437494, -32.62833023071289), - new JSM.Coord2D (333.3513793945312, -30.620243072509766), - new JSM.Coord2D (333.79019165039057, -28.643016815185547), - new JSM.Coord2D (334.4007263183593, -26.711898803710938), - new JSM.Coord2D (335.17736816406244, -24.84137725830078), - new JSM.Coord2D (336.11282348632807, -23.044984817504883), - new JSM.Coord2D (337.1984252929687, -21.33512306213379), - new JSM.Coord2D (338.42434692382807, -19.722867965698242), - new JSM.Coord2D (339.7802429199218, -18.2182674407959), - new JSM.Coord2D (341.25540161132807, -16.830411911010742), - new JSM.Coord2D (342.8388061523437, -15.567415237426758), - new JSM.Coord2D (344.51919555664057, -14.436615943908691), - new JSM.Coord2D (346.28506469726557, -13.444568634033203), - new JSM.Coord2D (348.12466430664057, -12.596980094909668), - new JSM.Coord2D (350.02587890624994, -11.8985595703125), - new JSM.Coord2D (351.9765014648437, -11.353080749511719), - new JSM.Coord2D (353.9640502929687, -10.962987899780273), - new JSM.Coord2D (355.9760131835937, -10.729391098022461), - null, - new JSM.Coord2D (45.84374999999999, -10.683036804199219), - new JSM.Coord2D (47.88229370117187, -10.759542465209961), - new JSM.Coord2D (49.909187316894524, -10.990069389343262), - new JSM.Coord2D (51.91246795654296, -11.375129699707031), - new JSM.Coord2D (53.879959106445305, -11.913954734802246), - new JSM.Coord2D (55.799419403076165, -12.604604721069336), - new JSM.Coord2D (57.658760070800774, -13.443743705749512), - new JSM.Coord2D (59.44597625732422, -14.427173614501953), - new JSM.Coord2D (61.14910888671875, -15.54993724822998), - new JSM.Coord2D (62.75645065307617, -16.805988311767578), - new JSM.Coord2D (64.25637817382811, -18.188514709472656), - new JSM.Coord2D (65.63724517822264, -19.689943313598633), - new JSM.Coord2D (66.88774108886717, -21.301536560058594), - new JSM.Coord2D (67.99694824218749, -23.013425827026367), - new JSM.Coord2D (68.9541778564453, -24.814687728881836), - new JSM.Coord2D (69.74999237060545, -26.69283676147461), - new JSM.Coord2D (70.37625885009764, -28.63409423828125), - new JSM.Coord2D (70.82669067382811, -30.623504638671875), - new JSM.Coord2D (71.09741210937499, -32.64522933959961), - new JSM.Coord2D (71.18749999999999, -34.68303298950195), - new JSM.Coord2D (71.09748077392577, -36.72084426879883), - new JSM.Coord2D (70.82672882080077, -38.74257278442383), - new JSM.Coord2D (70.37628936767577, -40.731990814208984), - new JSM.Coord2D (69.7500534057617, -42.67326354980469), - new JSM.Coord2D (68.95420837402342, -44.55139923095703), - new JSM.Coord2D (67.99696350097655, -46.3526496887207), - new JSM.Coord2D (66.88782501220702, -48.06458282470703), - new JSM.Coord2D (65.63726806640624, -49.67613983154297), - new JSM.Coord2D (64.25634765624999, -51.17751693725586), - new JSM.Coord2D (62.75646209716797, -52.56009292602539), - new JSM.Coord2D (61.14913558959961, -53.816165924072266), - new JSM.Coord2D (59.44598388671875, -54.93890380859375), - new JSM.Coord2D (57.65877532958984, -55.9223518371582), - new JSM.Coord2D (55.799427032470696, -56.761478424072266), - new JSM.Coord2D (53.87994766235351, -57.45206832885742), - new JSM.Coord2D (51.912464141845696, -57.99094009399414), - new JSM.Coord2D (49.90919876098632, -58.37601852416992), - new JSM.Coord2D (47.882305145263665, -58.60653305053711), - new JSM.Coord2D (45.843757629394524, -58.68303298950195), - new JSM.Coord2D (43.80521011352538, -58.60653305053711), - new JSM.Coord2D (41.77831649780273, -58.37600326538086), - new JSM.Coord2D (39.77503585815429, -57.99094009399414), - new JSM.Coord2D (37.807544708251946, -57.45210647583008), - new JSM.Coord2D (35.88808059692382, -56.761451721191406), - new JSM.Coord2D (34.02873992919921, -55.92230987548828), - new JSM.Coord2D (32.241523742675774, -54.93888473510742), - new JSM.Coord2D (30.53838539123535, -53.81612777709961), - new JSM.Coord2D (28.931024551391598, -52.56009292602539), - new JSM.Coord2D (27.431098937988278, -51.17756652832031), - new JSM.Coord2D (26.05021476745605, -49.676151275634766), - new JSM.Coord2D (24.799709320068356, -48.06455612182617), - new JSM.Coord2D (23.690509796142575, -46.3526611328125), - new JSM.Coord2D (22.73331260681152, -44.55138397216797), - new JSM.Coord2D (21.937499999999996, -42.67323303222656), - new JSM.Coord2D (21.31124114990234, -40.731971740722656), - new JSM.Coord2D (20.860818862915036, -38.7425537109375), - new JSM.Coord2D (20.590082168579098, -36.720829010009766), - new JSM.Coord2D (20.500007629394528, -34.68303298950195), - new JSM.Coord2D (20.590051651000973, -32.645225524902344), - new JSM.Coord2D (20.860799789428707, -30.623497009277344), - new JSM.Coord2D (21.311223983764645, -28.634075164794922), - new JSM.Coord2D (21.93748092651367, -26.692811965942383), - new JSM.Coord2D (22.733314514160153, -24.814674377441406), - new JSM.Coord2D (23.69057464599609, -23.013431549072266), - new JSM.Coord2D (24.799715042114254, -21.301498413085938), - new JSM.Coord2D (26.050258636474606, -19.6899356842041), - new JSM.Coord2D (27.431152343749996, -18.188535690307617), - new JSM.Coord2D (28.931035995483395, -16.80597496032715), - new JSM.Coord2D (30.538366317749023, -15.549915313720703), - new JSM.Coord2D (32.24151229858398, -14.427176475524902), - new JSM.Coord2D (34.02872085571288, -13.443732261657715), - new JSM.Coord2D (35.888069152832024, -12.604608535766602), - new JSM.Coord2D (37.80755233764648, -11.914011001586914), - new JSM.Coord2D (39.77502822875976, -11.375136375427246), - new JSM.Coord2D (41.7782859802246, -10.990045547485352), - new JSM.Coord2D (43.80519485473632, -10.75953197479248), - null, - new JSM.Coord2D (107.71874999999999, -10.683036804199219), - new JSM.Coord2D (295.56249999999994, -10.683036804199219), - new JSM.Coord2D (297.7281188964843, -10.829914093017578), - new JSM.Coord2D (299.85278320312494, -11.273558616638184), - new JSM.Coord2D (301.8931274414062, -12.013519287109375), - new JSM.Coord2D (303.8041687011718, -13.04211139678955), - new JSM.Coord2D (305.53958129882807, -14.345172882080078), - new JSM.Coord2D (307.05151367187494, -15.901714324951172), - new JSM.Coord2D (308.2914733886718, -17.682279586791992), - new JSM.Coord2D (309.2132263183593, -19.646312713623047), - new JSM.Coord2D (309.77932739257807, -21.740589141845703), - new JSM.Coord2D (309.96874999999994, -23.90178680419922), - new JSM.Coord2D (309.96874999999994, -45.46428680419922), - new JSM.Coord2D (309.77932739257807, -47.625484466552734), - new JSM.Coord2D (309.21340942382807, -49.71982192993164), - new JSM.Coord2D (308.2914733886718, -51.683753967285156), - new JSM.Coord2D (307.0514831542968, -53.464298248291016), - new JSM.Coord2D (305.53958129882807, -55.02088928222656), - new JSM.Coord2D (303.80419921874994, -56.32395935058594), - new JSM.Coord2D (301.8931274414062, -57.3525505065918), - new JSM.Coord2D (299.85278320312494, -58.092491149902344), - new JSM.Coord2D (297.7281188964843, -58.53616714477539), - new JSM.Coord2D (295.56249999999994, -58.68303680419922), - new JSM.Coord2D (107.71874999999999, -58.68303680419922), - new JSM.Coord2D (105.55313873291014, -58.536163330078125), - new JSM.Coord2D (103.42848205566405, -58.09251022338867), - new JSM.Coord2D (101.3881378173828, -57.352508544921875), - new JSM.Coord2D (99.47705078124999, -56.32398223876953), - new JSM.Coord2D (97.74167633056639, -55.020896911621094), - new JSM.Coord2D (96.22973632812499, -53.46435546875), - new JSM.Coord2D (94.98975372314452, -51.68381118774414), - new JSM.Coord2D (94.06801605224608, -49.71977615356445), - new JSM.Coord2D (93.50196075439452, -47.625484466552734), - new JSM.Coord2D (93.31249999999999, -45.46428680419922), - new JSM.Coord2D (93.31249999999999, -23.90178680419922), - new JSM.Coord2D (93.50192260742186, -21.740585327148438), - new JSM.Coord2D (94.0679473876953, -19.646278381347656), - new JSM.Coord2D (94.98979187011717, -17.682294845581055), - new JSM.Coord2D (96.22973632812499, -15.901721954345703), - new JSM.Coord2D (97.7416534423828, -14.345148086547852), - new JSM.Coord2D (99.47707366943358, -13.04212474822998), - new JSM.Coord2D (101.38810729980467, -12.01349925994873), - new JSM.Coord2D (103.42847442626952, -11.27356243133545), - new JSM.Coord2D (105.55313873291014, -10.829910278320312) - ]; - test.Assert (TestTriangulation (basePolygon, [0, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 199, 200, - 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 45, 0, 1, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, - 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 122, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43])); - - var basePolygon = [ - new JSM.Coord2D (0.0, 0.0), - new JSM.Coord2D (300.0, 0.0), - new JSM.Coord2D (300.0, 300.0), - new JSM.Coord2D (0.0, 300.0), - null, - new JSM.Coord2D (100.0, 100.0), - new JSM.Coord2D (100.0, 200.0), - new JSM.Coord2D (200.0, 200.0), - new JSM.Coord2D (200.0, 100.0), - null, - new JSM.Coord2D (10.0, 10.0), - new JSM.Coord2D (10.0, 50.0), - new JSM.Coord2D (50.0, 50.0), - new JSM.Coord2D (50.0, 10.0) - ]; - test.Assert (TestTriangulation (basePolygon, [0, 10, 11, 12, 13, 10, 0, 1, 5, 6, 7, 8, 5, 1, 2, 3])); - - var basePolygon = [ - new JSM.Coord2D (0, 0), - new JSM.Coord2D (7, 0), - new JSM.Coord2D (7, 3), - new JSM.Coord2D (0, 3), - null, - new JSM.Coord2D (1, 1), - new JSM.Coord2D (1, 2), - new JSM.Coord2D (2, 2), - new JSM.Coord2D (2, 1), - null, - new JSM.Coord2D (3, 1), - new JSM.Coord2D (3, 2), - new JSM.Coord2D (4, 2), - new JSM.Coord2D (4, 1), - null, - new JSM.Coord2D (5, 1), - new JSM.Coord2D (5, 2), - new JSM.Coord2D (6, 2), - new JSM.Coord2D (6, 1) - ]; - test.Assert (TestTriangulation (basePolygon, [0, 5, 6, 7, 10, 11, 12, 15, 16, 17, 18, 15, 12, 13, 10, 7, 8, 5, 0, 1, 2, 3])); - - var basePolygon = [ - new JSM.Coord (0.0, 0.0, 0.0), - new JSM.Coord (10.0, 0.0, 0.0), - new JSM.Coord (10.0, 10.0, 0.0), - new JSM.Coord (0.0, 10.0, 0.0), - null, - new JSM.Coord (5.0, 5.0, 0.0), - new JSM.Coord (5.0, 6.0, 0.0), - new JSM.Coord (6.0, 6.0, 0.0), - new JSM.Coord (6.0, 5.0, 0.0), - null, - new JSM.Coord (1.0, 1.0, 0.0), - new JSM.Coord (1.0, 9.0, 0.0), - new JSM.Coord (2.0, 9.0, 0.0), - new JSM.Coord (2.0, 2.0, 0.0), - new JSM.Coord (8.0, 2.0, 0.0), - new JSM.Coord (8.0, 9.0, 0.0), - new JSM.Coord (9.0, 9.0, 0.0), - new JSM.Coord (9.0, 1.0, 0.0) - ]; - test.Assert (TestTriangulation (basePolygon, [0, 10, 11, 12, 5, 6, 7, 8, 5, 12, 13, 14, 15, 16, 17, 10, 0, 1, 2, 3])); - - var basePolygon = [ - new JSM.Coord (0.0, 0.0, 0.0), - new JSM.Coord (10.0, 0.0, 0.0), - new JSM.Coord (10.0, 10.0, 0.0), - new JSM.Coord (0.0, 10.0, 0.0), - null, - new JSM.Coord (5.0, 5.0, 0.0), - new JSM.Coord (5.0, 6.0, 0.0), - new JSM.Coord (6.0, 6.0, 0.0), - new JSM.Coord (6.0, 5.0, 0.0), - null, - new JSM.Coord (3.0, 3.0, 0.0), - new JSM.Coord (3.0, 4.0, 0.0), - new JSM.Coord (4.0, 4.0, 0.0), - new JSM.Coord (4.0, 3.0, 0.0), - null, - new JSM.Coord (5.0, 3.0, 0.0), - new JSM.Coord (5.0, 4.0, 0.0), - new JSM.Coord (6.0, 4.0, 0.0), - new JSM.Coord (6.0, 3.0, 0.0), - null, - new JSM.Coord (1.0, 1.0, 0.0), - new JSM.Coord (1.0, 9.0, 0.0), - new JSM.Coord (2.0, 9.0, 0.0), - new JSM.Coord (2.0, 2.0, 0.0), - new JSM.Coord (8.0, 2.0, 0.0), - new JSM.Coord (8.0, 9.0, 0.0), - new JSM.Coord (9.0, 9.0, 0.0), - new JSM.Coord (9.0, 1.0, 0.0) - ]; - test.Assert (TestTriangulation (basePolygon, [0, 20, 21, 22, 5, 6, 7, 8, 11, 12, 15, 16, 17, 18, 15, 12, 13, 10, 11, 8, 5, 22, 23, 24, 25, 26, 27, 20, 0, 1, 2, 3])); - - var basePolygon = [ - new JSM.Coord (0.0, 0.0, 0.0), - new JSM.Coord (10.0, 0.0, 0.0), - new JSM.Coord (10.0, 10.0, 0.0), - new JSM.Coord (0.0, 10.0, 0.0), - null, - new JSM.Coord (5.0, 5.0, 0.0), - new JSM.Coord (5.0, 6.0, 0.0), - new JSM.Coord (6.0, 6.0, 0.0), - new JSM.Coord (6.0, 5.0, 0.0), - null, - new JSM.Coord (5.0, 3.0, 0.0), - new JSM.Coord (5.0, 4.0, 0.0), - new JSM.Coord (6.0, 4.0, 0.0), - new JSM.Coord (6.0, 3.0, 0.0), - null, - new JSM.Coord (1.0, 1.0, 0.0), - new JSM.Coord (1.0, 9.0, 0.0), - new JSM.Coord (2.0, 9.0, 0.0), - new JSM.Coord (2.0, 2.0, 0.0), - new JSM.Coord (8.0, 2.0, 0.0), - new JSM.Coord (8.0, 9.0, 0.0), - new JSM.Coord (9.0, 9.0, 0.0), - new JSM.Coord (9.0, 1.0, 0.0), - null, - new JSM.Coord (3.0, 3.0, 0.0), - new JSM.Coord (3.0, 4.0, 0.0), - new JSM.Coord (4.0, 4.0, 0.0), - new JSM.Coord (4.0, 3.0, 0.0), - ]; - test.Assert (TestTriangulation (basePolygon, [0, 15, 16, 17, 24, 25, 5, 6, 7, 8, 11, 12, 13, 10, 11, 8, 5, 25, 26, 27, 24, 17, 18, 19, 20, 21, 22, 15, 0, 1, 2, 3])); -}); - polygonSuite.AddTest ('OldCutPolygonTest', function (test) { var polygon = new JSM.Polygon (); diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index f1c9f26f..a0c7cb43 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -386,26 +386,26 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (0.0, 2.0); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 0.0)), JSM.PointPosition.OnVertex); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 0.0)), JSM.PointPosition.OnVertex); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 2.0)), JSM.PointPosition.OnVertex); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 2.0)), JSM.PointPosition.OnVertex); - - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 0.0)), JSM.PointPosition.OnEdge); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (2.0, 1.0)), JSM.PointPosition.OnEdge); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 2.0)), JSM.PointPosition.OnEdge); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (0.0, 1.0)), JSM.PointPosition.OnEdge); - - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (1.0, 1.0)), JSM.PointPosition.Inside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 1.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)), JSM.CoordPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 0.0)), JSM.CoordPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)), JSM.CoordPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)), JSM.CoordPosition.OnVertex); + + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.0)), JSM.CoordPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 2.0)), JSM.CoordPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPosition.OnEdge); + + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)), JSM.CoordPosition.Inside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 1.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 0.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 2.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon.PointPosition (new JSM.Coord2D (3.0, 3.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)), JSM.CoordPosition.Outside); var polygon2 = new JSM.Polygon2D (); polygon2.AddVertex (0.0, 0.0); @@ -413,13 +413,13 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon2.AddVertex (0.0, 2.0); polygon2.AddVertex (-1.0, 1.0); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.0, 1.0)), JSM.PointPosition.Inside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (2.0, 1.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.5, 0.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.PointPosition.Outside); - test.AssertEqual (polygon2.PointPosition (new JSM.Coord2D (0.5, 2.0)), JSM.PointPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPosition.Inside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 0.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 2.0)), JSM.CoordPosition.Outside); }); var diagonalSuite = unitTest.AddTestSuite ('IsDiagonalSuite'); diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index da9fc524..3b86091d 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -73,7 +73,7 @@ function CheckCalculatedTriangulation (polygon, triangles) function CheckSimpleTriangulation (polygon, triangles) { - var triangles = JSM.TriangulateSimplePolygon (polygon); + var triangles = JSM.TriangulatePolygon2D (polygon); return CheckCalculatedTriangulation (polygon, triangles); } @@ -82,15 +82,15 @@ var simplePolygonSuite = unitTest.AddTestSuite ('SimplePolygonTriangulationTest' simplePolygonSuite.AddTest ('InvalidPolygonTest', function (test) { var polygon = new JSM.Polygon2D (); - var triangles = JSM.TriangulateSimplePolygon (polygon); + var triangles = JSM.TriangulatePolygon2D (polygon); test.AssertEqual (triangles, null); polygon.AddVertex (0.0, 0.0); - triangles = JSM.TriangulateSimplePolygon (polygon); + triangles = JSM.TriangulatePolygon2D (polygon); test.AssertEqual (triangles, null); polygon.AddVertex (1.0, 0.0); - triangles = JSM.TriangulateSimplePolygon (polygon); + triangles = JSM.TriangulatePolygon2D (polygon); test.AssertEqual (triangles, null); }); @@ -126,6 +126,694 @@ simplePolygonSuite.AddTest ('ConvexTriangulationTest', function (test) test.Assert (CheckSimpleTriangulation (polygon2)); }); +simplePolygonSuite.AddTest ('OldTriangulationTest01', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (3.0, 0.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (1.5, 3.0); + polygon.AddVertex (0.0, 2.0); + + var triangles = JSM.TriangulatePolygon2D (polygon); + test.Assert (CheckSimpleTriangulation (polygon, triangles)); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0.0, 0.0); + polygon2.AddVertex (3.0, 0.0); + polygon2.AddVertex (3.0, 2.0); + polygon2.AddVertex (2.0, 2.0); + polygon2.AddVertex (2.0, 1.0); + polygon2.AddVertex (1.0, 1.0); + polygon2.AddVertex (1.0, 2.0); + polygon2.AddVertex (0.0, 2.0); + + var triangles = JSM.TriangulatePolygon2D (polygon2); + test.Assert (CheckSimpleTriangulation (polygon2, triangles)); + + var polygon2cw = new JSM.Polygon2D (); + polygon2cw.AddVertex (0.0, 0.0); + polygon2cw.AddVertex (0.0, 2.0); + polygon2cw.AddVertex (1.0, 2.0); + polygon2cw.AddVertex (1.0, 1.0); + polygon2cw.AddVertex (2.0, 1.0); + polygon2cw.AddVertex (2.0, 2.0); + polygon2cw.AddVertex (3.0, 2.0); + polygon2cw.AddVertex (3.0, 0.0); + + var triangles = JSM.TriangulatePolygon2D (polygon2cw); + test.Assert (CheckSimpleTriangulation (polygon2cw, triangles)); + + var polygon3 = new JSM.Polygon2D (); + polygon3.AddVertex (0.0, 0.0); + polygon3.AddVertex (5.0, 0.0); + polygon3.AddVertex (5.0, 1.0); + polygon3.AddVertex (1.0, 1.0); + polygon3.AddVertex (1.0, 5.0); + polygon3.AddVertex (4.0, 5.0); + polygon3.AddVertex (4.0, 3.0); + polygon3.AddVertex (3.0, 3.0); + polygon3.AddVertex (3.0, 4.0); + polygon3.AddVertex (2.0, 4.0); + polygon3.AddVertex (2.0, 2.0); + polygon3.AddVertex (5.0, 2.0); + polygon3.AddVertex (5.0, 6.0); + polygon3.AddVertex (0.0, 6.0); + + var triangles = JSM.TriangulatePolygon2D (polygon3); + test.Assert (CheckSimpleTriangulation (polygon3, triangles)); + + var polygon4 = new JSM.Polygon2D (); + polygon4.AddVertex (52, 221); + polygon4.AddVertex (101, 89); + polygon4.AddVertex (244, 89); + polygon4.AddVertex (188, 222); + polygon4.AddVertex (104, 219); + polygon4.AddVertex (135, 139); + polygon4.AddVertex (167, 140); + polygon4.AddVertex (152, 189); + polygon4.AddVertex (170, 189); + polygon4.AddVertex (192, 118); + polygon4.AddVertex (118, 121); + polygon4.AddVertex (77, 223); + + var triangles = JSM.TriangulatePolygon2D (polygon4); + test.Assert (CheckSimpleTriangulation (polygon4, triangles)); + + var polygon5 = new JSM.Polygon2D (); + polygon5.AddVertex (1, 0); + polygon5.AddVertex (2, 0); + polygon5.AddVertex (2, 1); + polygon5.AddVertex (3, 1); + polygon5.AddVertex (3, 2); + polygon5.AddVertex (2, 2); + polygon5.AddVertex (2, 3); + polygon5.AddVertex (1, 3); + polygon5.AddVertex (1, 2); + polygon5.AddVertex (0, 2); + polygon5.AddVertex (0, 1); + polygon5.AddVertex (1, 1); + + var triangles = JSM.TriangulatePolygon2D (polygon5); + test.Assert (CheckSimpleTriangulation (polygon5, triangles)); +}); + +simplePolygonSuite.AddTest ('OldTriangulationTest02', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0, 0); + polygon.AddVertex (3, 0); + polygon.AddVertex (3, 3); + polygon.AddVertex (0, 3); + polygon.AddVertex (0, 0); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddVertex (2, 1); + polygon.AddVertex (1, 1); + + test.Assert (JSM.IsEqual (polygon.GetSignedArea (), 8.0)); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordPosition.OnVertex); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, -1.0)) == JSM.CoordPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 4.0)) == JSM.CoordPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.5)) == JSM.CoordPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 1.5)) == JSM.CoordPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPosition.Outside); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 2.5)) == JSM.CoordPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPosition.Inside); + + var triangles = JSM.TriangulatePolygon2D (polygon); + test.Assert (CheckCalculatedTriangulation (polygon, triangles)); + + var polygon2 = new JSM.Polygon2D (); + polygon2.AddVertex (0, 0); + polygon2.AddVertex (6, 0); + polygon2.AddVertex (6, 3); + polygon2.AddVertex (5, 2); + polygon2.AddVertex (5, 1); + polygon2.AddVertex (4, 1); + polygon2.AddVertex (4, 2); + polygon2.AddVertex (5, 2); + polygon2.AddVertex (6, 3); + polygon2.AddVertex (0, 3); + polygon2.AddVertex (1, 2); + polygon2.AddVertex (2, 2); + polygon2.AddVertex (2, 1); + polygon2.AddVertex (1, 1); + polygon2.AddVertex (1, 2); + polygon2.AddVertex (0, 3); + + test.Assert (JSM.IsEqual (polygon2.GetSignedArea (), 16.0)); + + var triangles = JSM.TriangulatePolygon2D (polygon2); + test.Assert (CheckCalculatedTriangulation (polygon2, triangles)); + + var polygon3 = new JSM.Polygon2D (); + polygon3.AddVertex (0, 0); + polygon3.AddVertex (5, 0); + polygon3.AddVertex (2.5, 5); + polygon3.AddVertex (2, 2); + polygon3.AddVertex (3, 2); + polygon3.AddVertex (3, 1); + polygon3.AddVertex (2, 1); + polygon3.AddVertex (2, 2); + polygon3.AddVertex (2.5, 5); + + var triangles = JSM.TriangulatePolygon2D (polygon3); + test.Assert (CheckCalculatedTriangulation (polygon3, triangles)); +}); + +simplePolygonSuite.AddTest ('OldTriangulationTest03', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0, 0); + polygon.AddVertex (7, 0); + polygon.AddVertex (7, 3); + polygon.AddVertex (0, 3); + polygon.AddContour (); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddVertex (2, 1); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0, 0); + polygon.AddVertex (7, 0); + polygon.AddVertex (7, 3); + polygon.AddVertex (0, 3); + polygon.AddContour (); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddVertex (2, 1); + polygon.AddContour (); + polygon.AddVertex (3, 1); + polygon.AddVertex (3, 2); + polygon.AddVertex (4, 2); + polygon.AddVertex (4, 1); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0, 0); + polygon.AddVertex (7, 0); + polygon.AddVertex (7, 3); + polygon.AddVertex (0, 3); + polygon.AddContour (); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddVertex (2, 1); + polygon.AddContour (); + polygon.AddVertex (3, 1); + polygon.AddVertex (3, 2); + polygon.AddVertex (4, 2); + polygon.AddVertex (4, 1); + polygon.AddContour (); + polygon.AddVertex (5, 1); + polygon.AddVertex (5, 2); + polygon.AddVertex (6, 2); + polygon.AddVertex (6, 1); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (300.8485412597656, 319.4265441894531); + polygon.AddVertex (338.24835205078125, 396.81103515625); + polygon.AddVertex (421.9165954589844, 416.66839599609375); + polygon.AddVertex (489.1433410644531, 362.9385986328125); + polygon.AddVertex (489.543701171875, 276.95245361328125); + polygon.AddVertex (422.18115234375, 223.48004150390625); + polygon.AddVertex (337.93084716796875, 241.53892517089844); + polygon.AddContour (); + polygon.AddVertex (400.6557922363281, 231.74929809570312); + polygon.AddVertex (468.43548583984375, 264.9992980957031); + polygon.AddVertex (484.7142639160156, 338.9593505859375); + polygon.AddVertex (437.7185363769531, 398.06951904296875); + polygon.AddVertex (362.0542297363281, 397.45257568359375); + polygon.AddVertex (315.2279052734375, 338.1394348144531); + polygon.AddVertex (332.49664306640625, 264.4938659667969); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); +}); + +simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (14.406249999999998, 0.004463199991732836); + polygon.AddVertex (12.273693084716795, -0.13337911665439606); + polygon.AddVertex (10.177939414978026, -0.5507046580314636); + polygon.AddVertex (8.158322334289549, -1.2485805749893188); + polygon.AddVertex (6.256920814514159, -2.2232589721679688); + polygon.AddVertex (4.518617153167724, -3.4653913974761963); + polygon.AddVertex (2.992141485214233, -4.959873676300049); + polygon.AddVertex (1.7292572259902952, -6.682513236999512); + polygon.AddVertex (0.7823054790496825, -8.596776962280273); + polygon.AddVertex (0.19680410623550412, -10.650409698486328); + polygon.AddVertex (2.7840769689646545e-9, -12.77676773071289); + polygon.AddVertex (2.7840769689646545e-9, -58.87051773071289); + polygon.AddVertex (0.19683623313903806, -60.99687194824219); + polygon.AddVertex (0.782375395298004, -63.05048370361328); + polygon.AddVertex (1.7292767763137815, -64.96475982666016); + polygon.AddVertex (2.992123126983642, -66.68743133544922); + polygon.AddVertex (4.5186753273010245, -68.18182373046875); + polygon.AddVertex (6.256915569305419, -69.42404174804688); + polygon.AddVertex (8.158330917358397, -70.398681640625); + polygon.AddVertex (10.17793846130371, -71.0965805053711); + polygon.AddVertex (12.273698806762694, -71.51383209228516); + polygon.AddVertex (14.406246185302733, -71.65176391601562); + polygon.AddVertex (385.18749999999994, -71.65176391601562); + polygon.AddVertex (387.32006835937494, -71.513916015625); + polygon.AddVertex (389.41580200195307, -71.0965805053711); + polygon.AddVertex (391.43542480468744, -70.398681640625); + polygon.AddVertex (393.33679199218744, -69.42398071289062); + polygon.AddVertex (395.0751342773437, -68.18187713623047); + polygon.AddVertex (396.6016235351562, -66.6874008178711); + polygon.AddVertex (397.86450195312494, -64.96475982666016); + polygon.AddVertex (398.8114624023437, -63.050498962402344); + polygon.AddVertex (399.39697265624994, -60.99687576293945); + polygon.AddVertex (399.59374999999994, -58.870513916015625); + polygon.AddVertex (399.59374999999994, -12.776763916015625); + polygon.AddVertex (399.39688110351557, -10.650407791137695); + polygon.AddVertex (398.8113708496093, -8.596782684326172); + polygon.AddVertex (397.8644714355468, -6.682509422302246); + polygon.AddVertex (396.6016235351562, -4.95983362197876); + polygon.AddVertex (395.07510375976557, -3.465416193008423); + polygon.AddVertex (393.3368530273437, -2.223223924636841); + polygon.AddVertex (391.43542480468744, -1.2485815286636353); + polygon.AddVertex (389.41580200195307, -0.5506518483161926); + polygon.AddVertex (387.3200378417968, -0.13342222571372986); + polygon.AddVertex (385.18749999999994, 0.004486083984375); + polygon.AddContour (); + polygon.AddVertex (357.99999999999994, -10.651786804199219); + polygon.AddVertex (360.0240173339843, -10.729362487792969); + polygon.AddVertex (362.0359497070312, -10.963029861450195); + polygon.AddVertex (364.0234985351562, -11.353105545043945); + polygon.AddVertex (365.97412109374994, -11.898651123046875); + polygon.AddVertex (367.87536621093744, -12.597009658813477); + polygon.AddVertex (369.7149047851562, -13.44465446472168); + polygon.AddVertex (371.4808044433593, -14.436634063720703); + polygon.AddVertex (373.1611938476562, -15.567431449890137); + polygon.AddVertex (374.7445983886718, -16.83041000366211); + polygon.AddVertex (376.2197875976562, -18.21826934814453); + polygon.AddVertex (377.57568359374994, -19.722864151000977); + polygon.AddVertex (378.80154418945307, -21.335163116455078); + polygon.AddVertex (379.88711547851557, -23.0450382232666); + polygon.AddVertex (380.82266235351557, -24.84136199951172); + polygon.AddVertex (381.5994262695312, -26.711843490600586); + polygon.AddVertex (382.2098999023437, -28.642974853515625); + polygon.AddVertex (382.64871215820307, -30.620220184326172); + polygon.AddVertex (382.91235351562494, -32.628326416015625); + polygon.AddVertex (382.99999999999994, -34.65178680419922); + polygon.AddVertex (382.91235351562494, -36.67523956298828); + polygon.AddVertex (382.6486206054687, -38.68333053588867); + polygon.AddVertex (382.2098083496093, -40.660552978515625); + polygon.AddVertex (381.59924316406244, -42.591670989990234); + polygon.AddVertex (380.8226013183593, -44.46219253540039); + polygon.AddVertex (379.8871459960937, -46.258583068847656); + polygon.AddVertex (378.8015747070312, -47.96845626831055); + polygon.AddVertex (377.5756530761718, -49.58070755004883); + polygon.AddVertex (376.2197875976562, -51.08530807495117); + polygon.AddVertex (374.7445983886718, -52.47315979003906); + polygon.AddVertex (373.16116333007807, -53.73616027832031); + polygon.AddVertex (371.4807739257812, -54.86695861816406); + polygon.AddVertex (369.7149353027343, -55.85900115966797); + polygon.AddVertex (367.87536621093744, -56.70659255981445); + polygon.AddVertex (365.97412109374994, -57.405006408691406); + polygon.AddVertex (364.0234985351562, -57.95049285888672); + polygon.AddVertex (362.0359497070312, -58.340576171875); + polygon.AddVertex (360.0239868164062, -58.574188232421875); + polygon.AddVertex (357.99999999999994, -58.65178680419922); + polygon.AddVertex (355.97598266601557, -58.57420349121094); + polygon.AddVertex (353.9640502929687, -58.340545654296875); + polygon.AddVertex (351.9765014648437, -57.95048141479492); + polygon.AddVertex (350.02587890624994, -57.40494155883789); + polygon.AddVertex (348.12463378906244, -56.706573486328125); + polygon.AddVertex (346.2850952148437, -55.85893249511719); + polygon.AddVertex (344.51919555664057, -54.866943359375); + polygon.AddVertex (342.8388061523437, -53.73613357543945); + polygon.AddVertex (341.25537109374994, -52.47316360473633); + polygon.AddVertex (339.78018188476557, -51.085304260253906); + polygon.AddVertex (338.4242858886718, -49.58070755004883); + polygon.AddVertex (337.1984252929687, -47.968421936035156); + polygon.AddVertex (336.1128845214843, -46.25852584838867); + polygon.AddVertex (335.1773071289062, -44.462196350097656); + polygon.AddVertex (334.40054321289057, -42.591712951660156); + polygon.AddVertex (333.79003906249994, -40.66058349609375); + polygon.AddVertex (333.3512878417968, -38.68334197998047); + polygon.AddVertex (333.08764648437494, -36.675235748291016); + polygon.AddVertex (332.99999999999994, -34.65178680419922); + polygon.AddVertex (333.08764648437494, -32.62833023071289); + polygon.AddVertex (333.3513793945312, -30.620243072509766); + polygon.AddVertex (333.79019165039057, -28.643016815185547); + polygon.AddVertex (334.4007263183593, -26.711898803710938); + polygon.AddVertex (335.17736816406244, -24.84137725830078); + polygon.AddVertex (336.11282348632807, -23.044984817504883); + polygon.AddVertex (337.1984252929687, -21.33512306213379); + polygon.AddVertex (338.42434692382807, -19.722867965698242); + polygon.AddVertex (339.7802429199218, -18.2182674407959); + polygon.AddVertex (341.25540161132807, -16.830411911010742); + polygon.AddVertex (342.8388061523437, -15.567415237426758); + polygon.AddVertex (344.51919555664057, -14.436615943908691); + polygon.AddVertex (346.28506469726557, -13.444568634033203); + polygon.AddVertex (348.12466430664057, -12.596980094909668); + polygon.AddVertex (350.02587890624994, -11.8985595703125); + polygon.AddVertex (351.9765014648437, -11.353080749511719); + polygon.AddVertex (353.9640502929687, -10.962987899780273); + polygon.AddVertex (355.9760131835937, -10.729391098022461); + polygon.AddContour (); + polygon.AddVertex (45.84374999999999, -10.683036804199219); + polygon.AddVertex (47.88229370117187, -10.759542465209961); + polygon.AddVertex (49.909187316894524, -10.990069389343262); + polygon.AddVertex (51.91246795654296, -11.375129699707031); + polygon.AddVertex (53.879959106445305, -11.913954734802246); + polygon.AddVertex (55.799419403076165, -12.604604721069336); + polygon.AddVertex (57.658760070800774, -13.443743705749512); + polygon.AddVertex (59.44597625732422, -14.427173614501953); + polygon.AddVertex (61.14910888671875, -15.54993724822998); + polygon.AddVertex (62.75645065307617, -16.805988311767578); + polygon.AddVertex (64.25637817382811, -18.188514709472656); + polygon.AddVertex (65.63724517822264, -19.689943313598633); + polygon.AddVertex (66.88774108886717, -21.301536560058594); + polygon.AddVertex (67.99694824218749, -23.013425827026367); + polygon.AddVertex (68.9541778564453, -24.814687728881836); + polygon.AddVertex (69.74999237060545, -26.69283676147461); + polygon.AddVertex (70.37625885009764, -28.63409423828125); + polygon.AddVertex (70.82669067382811, -30.623504638671875); + polygon.AddVertex (71.09741210937499, -32.64522933959961); + polygon.AddVertex (71.18749999999999, -34.68303298950195); + polygon.AddVertex (71.09748077392577, -36.72084426879883); + polygon.AddVertex (70.82672882080077, -38.74257278442383); + polygon.AddVertex (70.37628936767577, -40.731990814208984); + polygon.AddVertex (69.7500534057617, -42.67326354980469); + polygon.AddVertex (68.95420837402342, -44.55139923095703); + polygon.AddVertex (67.99696350097655, -46.3526496887207); + polygon.AddVertex (66.88782501220702, -48.06458282470703); + polygon.AddVertex (65.63726806640624, -49.67613983154297); + polygon.AddVertex (64.25634765624999, -51.17751693725586); + polygon.AddVertex (62.75646209716797, -52.56009292602539); + polygon.AddVertex (61.14913558959961, -53.816165924072266); + polygon.AddVertex (59.44598388671875, -54.93890380859375); + polygon.AddVertex (57.65877532958984, -55.9223518371582); + polygon.AddVertex (55.799427032470696, -56.761478424072266); + polygon.AddVertex (53.87994766235351, -57.45206832885742); + polygon.AddVertex (51.912464141845696, -57.99094009399414); + polygon.AddVertex (49.90919876098632, -58.37601852416992); + polygon.AddVertex (47.882305145263665, -58.60653305053711); + polygon.AddVertex (45.843757629394524, -58.68303298950195); + polygon.AddVertex (43.80521011352538, -58.60653305053711); + polygon.AddVertex (41.77831649780273, -58.37600326538086); + polygon.AddVertex (39.77503585815429, -57.99094009399414); + polygon.AddVertex (37.807544708251946, -57.45210647583008); + polygon.AddVertex (35.88808059692382, -56.761451721191406); + polygon.AddVertex (34.02873992919921, -55.92230987548828); + polygon.AddVertex (32.241523742675774, -54.93888473510742); + polygon.AddVertex (30.53838539123535, -53.81612777709961); + polygon.AddVertex (28.931024551391598, -52.56009292602539); + polygon.AddVertex (27.431098937988278, -51.17756652832031); + polygon.AddVertex (26.05021476745605, -49.676151275634766); + polygon.AddVertex (24.799709320068356, -48.06455612182617); + polygon.AddVertex (23.690509796142575, -46.3526611328125); + polygon.AddVertex (22.73331260681152, -44.55138397216797); + polygon.AddVertex (21.937499999999996, -42.67323303222656); + polygon.AddVertex (21.31124114990234, -40.731971740722656); + polygon.AddVertex (20.860818862915036, -38.7425537109375); + polygon.AddVertex (20.590082168579098, -36.720829010009766); + polygon.AddVertex (20.500007629394528, -34.68303298950195); + polygon.AddVertex (20.590051651000973, -32.645225524902344); + polygon.AddVertex (20.860799789428707, -30.623497009277344); + polygon.AddVertex (21.311223983764645, -28.634075164794922); + polygon.AddVertex (21.93748092651367, -26.692811965942383); + polygon.AddVertex (22.733314514160153, -24.814674377441406); + polygon.AddVertex (23.69057464599609, -23.013431549072266); + polygon.AddVertex (24.799715042114254, -21.301498413085938); + polygon.AddVertex (26.050258636474606, -19.6899356842041); + polygon.AddVertex (27.431152343749996, -18.188535690307617); + polygon.AddVertex (28.931035995483395, -16.80597496032715); + polygon.AddVertex (30.538366317749023, -15.549915313720703); + polygon.AddVertex (32.24151229858398, -14.427176475524902); + polygon.AddVertex (34.02872085571288, -13.443732261657715); + polygon.AddVertex (35.888069152832024, -12.604608535766602); + polygon.AddVertex (37.80755233764648, -11.914011001586914); + polygon.AddVertex (39.77502822875976, -11.375136375427246); + polygon.AddVertex (41.7782859802246, -10.990045547485352); + polygon.AddVertex (43.80519485473632, -10.75953197479248); + polygon.AddContour (); + polygon.AddVertex (107.71874999999999, -10.683036804199219); + polygon.AddVertex (295.56249999999994, -10.683036804199219); + polygon.AddVertex (297.7281188964843, -10.829914093017578); + polygon.AddVertex (299.85278320312494, -11.273558616638184); + polygon.AddVertex (301.8931274414062, -12.013519287109375); + polygon.AddVertex (303.8041687011718, -13.04211139678955); + polygon.AddVertex (305.53958129882807, -14.345172882080078); + polygon.AddVertex (307.05151367187494, -15.901714324951172); + polygon.AddVertex (308.2914733886718, -17.682279586791992); + polygon.AddVertex (309.2132263183593, -19.646312713623047); + polygon.AddVertex (309.77932739257807, -21.740589141845703); + polygon.AddVertex (309.96874999999994, -23.90178680419922); + polygon.AddVertex (309.96874999999994, -45.46428680419922); + polygon.AddVertex (309.77932739257807, -47.625484466552734); + polygon.AddVertex (309.21340942382807, -49.71982192993164); + polygon.AddVertex (308.2914733886718, -51.683753967285156); + polygon.AddVertex (307.0514831542968, -53.464298248291016); + polygon.AddVertex (305.53958129882807, -55.02088928222656); + polygon.AddVertex (303.80419921874994, -56.32395935058594); + polygon.AddVertex (301.8931274414062, -57.3525505065918); + polygon.AddVertex (299.85278320312494, -58.092491149902344); + polygon.AddVertex (297.7281188964843, -58.53616714477539); + polygon.AddVertex (295.56249999999994, -58.68303680419922); + polygon.AddVertex (107.71874999999999, -58.68303680419922); + polygon.AddVertex (105.55313873291014, -58.536163330078125); + polygon.AddVertex (103.42848205566405, -58.09251022338867); + polygon.AddVertex (101.3881378173828, -57.352508544921875); + polygon.AddVertex (99.47705078124999, -56.32398223876953); + polygon.AddVertex (97.74167633056639, -55.020896911621094); + polygon.AddVertex (96.22973632812499, -53.46435546875); + polygon.AddVertex (94.98975372314452, -51.68381118774414); + polygon.AddVertex (94.06801605224608, -49.71977615356445); + polygon.AddVertex (93.50196075439452, -47.625484466552734); + polygon.AddVertex (93.31249999999999, -45.46428680419922); + polygon.AddVertex (93.31249999999999, -23.90178680419922); + polygon.AddVertex (93.50192260742186, -21.740585327148438); + polygon.AddVertex (94.0679473876953, -19.646278381347656); + polygon.AddVertex (94.98979187011717, -17.682294845581055); + polygon.AddVertex (96.22973632812499, -15.901721954345703); + polygon.AddVertex (97.7416534423828, -14.345148086547852); + polygon.AddVertex (99.47707366943358, -13.04212474822998); + polygon.AddVertex (101.38810729980467, -12.01349925994873); + polygon.AddVertex (103.42847442626952, -11.27356243133545); + polygon.AddVertex (105.55313873291014, -10.829910278320312); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), 0.0001); + test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), 0.0001); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (300.0, 0.0); + polygon.AddVertex (300.0, 300.0); + polygon.AddVertex (0.0, 300.0); + polygon.AddContour (); + polygon.AddVertex (100.0, 100.0); + polygon.AddVertex (100.0, 200.0); + polygon.AddVertex (200.0, 200.0); + polygon.AddVertex (200.0, 100.0); + polygon.AddContour (); + polygon.AddVertex (10.0, 10.0); + polygon.AddVertex (10.0, 50.0); + polygon.AddVertex (50.0, 50.0); + polygon.AddVertex (50.0, 10.0); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0, 0); + polygon.AddVertex (7, 0); + polygon.AddVertex (7, 3); + polygon.AddVertex (0, 3); + polygon.AddContour (); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddVertex (2, 1); + polygon.AddContour (); + polygon.AddVertex (3, 1); + polygon.AddVertex (3, 2); + polygon.AddVertex (4, 2); + polygon.AddVertex (4, 1); + polygon.AddContour (); + polygon.AddVertex (5, 1); + polygon.AddVertex (5, 2); + polygon.AddVertex (6, 2); + polygon.AddVertex (6, 1); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (10.0, 0.0); + polygon.AddVertex (10.0, 10.0); + polygon.AddVertex (0.0, 10.0); + polygon.AddContour (); + polygon.AddVertex (5.0, 5.0); + polygon.AddVertex (5.0, 6.0); + polygon.AddVertex (6.0, 6.0); + polygon.AddVertex (6.0, 5.0); + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 9.0); + polygon.AddVertex (2.0, 9.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (8.0, 2.0); + polygon.AddVertex (8.0, 9.0); + polygon.AddVertex (9.0, 9.0); + polygon.AddVertex (9.0, 1.0); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (10.0, 0.0); + polygon.AddVertex (10.0, 10.0); + polygon.AddVertex (0.0, 10.0); + polygon.AddContour (); + polygon.AddVertex (5.0, 5.0); + polygon.AddVertex (5.0, 6.0); + polygon.AddVertex (6.0, 6.0); + polygon.AddVertex (6.0, 5.0); + polygon.AddContour (); + polygon.AddVertex (3.0, 3.0); + polygon.AddVertex (3.0, 4.0); + polygon.AddVertex (4.0, 4.0); + polygon.AddVertex (4.0, 3.0); + polygon.AddContour (); + polygon.AddVertex (5.0, 3.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (6.0, 4.0); + polygon.AddVertex (6.0, 3.0); + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 9.0); + polygon.AddVertex (2.0, 9.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (8.0, 2.0); + polygon.AddVertex (8.0, 9.0); + polygon.AddVertex (9.0, 9.0); + polygon.AddVertex (9.0, 1.0); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (10.0, 0.0); + polygon.AddVertex (10.0, 10.0); + polygon.AddVertex (0.0, 10.0); + polygon.AddContour (); + polygon.AddVertex (5.0, 5.0); + polygon.AddVertex (5.0, 6.0); + polygon.AddVertex (6.0, 6.0); + polygon.AddVertex (6.0, 5.0); + polygon.AddContour (); + polygon.AddVertex (5.0, 3.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (6.0, 4.0); + polygon.AddVertex (6.0, 3.0); + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 9.0); + polygon.AddVertex (2.0, 9.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (8.0, 2.0); + polygon.AddVertex (8.0, 9.0); + polygon.AddVertex (9.0, 9.0); + polygon.AddVertex (9.0, 1.0); + polygon.AddContour (); + polygon.AddVertex (3.0, 3.0); + polygon.AddVertex (3.0, 4.0); + polygon.AddVertex (4.0, 4.0); + polygon.AddVertex (4.0, 3.0); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckSimpleTriangulation (simple)); +}); + simplePolygonSuite.AddTest ('ConcaveTriangulationTest01', function (test) { var polygon = new JSM.Polygon2D (); @@ -197,7 +885,7 @@ convertToSimplePolygonSuite.AddTest ('SimplePolygonTest', function (test) polygon.AddVertex (5.0, 4.0); polygon.AddVertex (0.0, 4.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount (), simple.VertexCount ()); test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); test.AssertEqual (polygon.GetArea (), simple.GetArea ()); @@ -212,7 +900,7 @@ convertToSimplePolygonSuite.AddTest ('SimplePolygonTest', function (test) polygon2.AddVertex (5.0, 4.0); polygon2.AddVertex (5.0, 0.0); - var simple2 = JSM.ConvertPolygonToSimplePolygon (polygon2); + var simple2 = JSM.ConvertContourPolygonToPolygon2D (polygon2); test.AssertEqual (polygon2.VertexCount (), simple2.VertexCount ()); test.AssertEqual (polygon2.GetSignedArea (), simple2.GetSignedArea ()); test.AssertEqual (polygon2.GetArea (), simple2.GetArea ()); @@ -236,7 +924,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest01', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (2.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); @@ -260,7 +948,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest02', function (test) polygon.AddVertex (1.0, 1.0); polygon.AddVertex (1.0, 2.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); @@ -284,7 +972,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest03', function (test) polygon.AddVertex (2.0, 3.0); polygon.AddVertex (2.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 2, simple.VertexCount ()); test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); @@ -314,7 +1002,7 @@ convertToSimplePolygonSuite.AddTest ('TwoHolesTest', function (test) polygon.AddVertex (4.0, 2.0); polygon.AddVertex (4.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); test.AssertEqualNum (polygon.GetSignedArea (), simple.GetSignedArea (), JSM.Eps); test.AssertEqualNum (polygon.GetArea (), simple.GetArea (), JSM.Eps); @@ -339,7 +1027,7 @@ polygonSuite.AddTest ('OneHoleTriangulationTest', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (2.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); var polygon2 = new JSM.ContourPolygon2D (); @@ -353,7 +1041,7 @@ polygonSuite.AddTest ('OneHoleTriangulationTest', function (test) polygon2.AddVertex (2.0, 2.0); polygon2.AddVertex (2.0, 1.0); - var simple2 = JSM.ConvertPolygonToSimplePolygon (polygon2); + var simple2 = JSM.ConvertContourPolygonToPolygon2D (polygon2); test.Assert (CheckSimpleTriangulation (simple2)); var polygon3 = new JSM.ContourPolygon2D (); @@ -368,7 +1056,7 @@ polygonSuite.AddTest ('OneHoleTriangulationTest', function (test) polygon3.AddVertex (90, 90); polygon3.AddVertex (90, 10); - var simple3 = JSM.ConvertPolygonToSimplePolygon (polygon3); + var simple3 = JSM.ConvertContourPolygonToPolygon2D (polygon3); test.Assert (CheckSimpleTriangulation (simple3)); }); @@ -393,7 +1081,7 @@ polygonSuite.AddTest ('TwoHolesTriangulationTest01', function (test) polygon.AddVertex (4.0, 2.0); polygon.AddVertex (4.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); test.AssertEqual (polygon.GetArea (), simple.GetArea ()); @@ -425,7 +1113,7 @@ polygonSuite.AddTest ('TwoHolesTriangulationTest02', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (2.0, 1.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); test.AssertEqual (polygon.GetArea (), simple.GetArea ()); @@ -455,7 +1143,7 @@ polygonSuite.AddTest ('TwoHolesTriangulationTest03', function (test) polygon.AddVertex (1.0, 2.0); polygon.AddVertex (2.0, 2.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.AssertEqual (polygon.VertexCount () + 4, simple.VertexCount ()); test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); test.AssertEqual (polygon.GetArea (), simple.GetArea ()); @@ -485,8 +1173,8 @@ polygonSuite.AddTest ('TwoHolesTriangulationTest04', function (test) polygon.AddVertex (3.0, 2.0); polygon.AddVertex (4.0, 2.0); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); - var triangles = JSM.TriangulateSimplePolygon (simple); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + var triangles = JSM.TriangulatePolygon2D (simple); test.Assert (CheckCalculatedTriangulation_Exists (simple, triangles)); test.Assert (CheckCalculatedTriangulation_TriangleCount (simple, triangles)); test.Assert (CheckCalculatedTriangulation_Area (simple, triangles)); @@ -875,7 +1563,7 @@ generatedSuite.AddTest ('Test12', function (test) { test.AssertEqualNum (polygon.GetArea (), 28193, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -957,7 +1645,7 @@ generatedSuite.AddTest ('Test13', function (test) { test.AssertEqualNum (polygon.GetArea (), 151033, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1058,7 +1746,7 @@ generatedSuite.AddTest ('Test14', function (test) { test.AssertEqualNum (polygon.GetArea (), 163611, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1149,7 +1837,7 @@ generatedSuite.AddTest ('Test15', function (test) { test.AssertEqualNum (polygon.GetArea (), 132181.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Concave, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1180,7 +1868,7 @@ generatedSuite.AddTest ('Test16', function (test) { test.AssertEqualNum (polygon.GetArea (), 33073, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1259,7 +1947,7 @@ generatedSuite.AddTest ('Test17', function (test) { test.AssertEqualNum (polygon.GetArea (), 87509, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1344,7 +2032,7 @@ generatedSuite.AddTest ('Test18', function (test) { test.AssertEqualNum (polygon.GetArea (), 84071.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1377,7 +2065,7 @@ generatedSuite.AddTest ('Test19', function (test) { test.AssertEqualNum (polygon.GetArea (), 190194.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1431,7 +2119,7 @@ generatedSuite.AddTest ('Test20', function (test) { test.AssertEqualNum (polygon.GetArea (), 76049, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1501,7 +2189,7 @@ generatedSuite.AddTest ('Test21', function (test) { test.AssertEqualNum (polygon.GetArea (), 109202, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1587,7 +2275,7 @@ generatedSuite.AddTest ('Test22', function (test) { test.AssertEqualNum (polygon.GetArea (), 56177.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1606,7 +2294,7 @@ generatedSuite.AddTest ('Test23', function (test) { test.AssertEqualNum (polygon.GetArea (), 15951, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.CounterClockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1718,7 +2406,7 @@ generatedSuite.AddTest ('Test24', function (test) { test.AssertEqualNum (polygon.GetArea (), 207382.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); @@ -1751,7 +2439,7 @@ generatedSuite.AddTest ('Test25', function (test) { test.AssertEqualNum (polygon.GetArea (), 94397.5, JSM.Eps); test.AssertEqual (polygon.GetOrientation (), JSM.Orientation.Clockwise, JSM.Eps); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex, JSM.Eps); - var simple = JSM.ConvertPolygonToSimplePolygon (polygon); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); test.Assert (CheckSimpleTriangulation (simple)); }); From b4fd341719e59d894c09f9153d5723672db6372c Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 18 Jul 2015 09:48:45 +0200 Subject: [PATCH 12/27] Make unit tests use the new polygon class 2. --- build/jsmodeler.js | 6 +- sandbox/triangulatewithhole.html | 148 ------------------------------- src/geometry/triangulation.js | 4 + src/modeler/explode.js | 39 ++++---- test/unittest/tests/geometry.js | 85 ------------------ 5 files changed, 27 insertions(+), 255 deletions(-) delete mode 100644 sandbox/triangulatewithhole.html diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 3da13bf2..bd268cde 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -103,7 +103,7 @@ c=a.GetContour(c);var g,h,k,l;for(g=0;gf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; -JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();return 3>b?null:3==b?[[0,1,2]]:a.GetComplexity()==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; +JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; JSM.OldPolygon2D.prototype.SetVertex=function(a,b,c){this.vertices[a].Set(b,c)};JSM.OldPolygon2D.prototype.VertexCount=function(){return this.vertices.length};JSM.OldPolygon2D.prototype.Clear=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.Clone=function(){var a=new JSM.OldPolygon2D,b;for(b=0;b=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& (g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var h=[],g,l,k;for(g=0;gb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, diff --git a/sandbox/triangulatewithhole.html b/sandbox/triangulatewithhole.html deleted file mode 100644 index a1a41aa8..00000000 --- a/sandbox/triangulatewithhole.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example - - - - - - - - - diff --git a/src/geometry/triangulation.js b/src/geometry/triangulation.js index a88e886c..adc42eea 100644 --- a/src/geometry/triangulation.js +++ b/src/geometry/triangulation.js @@ -232,6 +232,10 @@ JSM.TriangulatePolygon2D = function (polygon) } var complexity = polygon.GetComplexity (); + if (complexity === JSM.Complexity.Invalid) { + return null; + } + if (complexity == JSM.Complexity.Convex) { return JSM.TriangulateConvexPolygon (polygon); } diff --git a/src/modeler/explode.js b/src/modeler/explode.js index 2b95a25c..3ca494de 100644 --- a/src/modeler/explode.js +++ b/src/modeler/explode.js @@ -66,26 +66,27 @@ JSM.ExplodeBodyToTriangles = function (body, materials, explodeData) var normal = JSM.CalculateBodyPolygonNormal (body, index); var triangles = JSM.PolygonTriangulate (polygon3D, normal); - - var triangle; - for (i = 0; i < triangles.length; i++) { - triangle = triangles[i]; - vertex1 = body.GetVertex (polygon.GetVertexIndex (triangle[0])).position; - vertex2 = body.GetVertex (polygon.GetVertexIndex (triangle[1])).position; - vertex3 = body.GetVertex (polygon.GetVertexIndex (triangle[2])).position; - normal1 = vertexNormals[index][triangle[0]]; - normal2 = vertexNormals[index][triangle[1]]; - normal3 = vertexNormals[index][triangle[2]]; - uv1 = null; - uv2 = null; - uv3 = null; - if (hasTextureCoords) { - uv1 = textureCoords[index][triangle[0]]; - uv2 = textureCoords[index][triangle[1]]; - uv3 = textureCoords[index][triangle[2]]; + if (triangles !== null) { + var triangle; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + vertex1 = body.GetVertex (polygon.GetVertexIndex (triangle[0])).position; + vertex2 = body.GetVertex (polygon.GetVertexIndex (triangle[1])).position; + vertex3 = body.GetVertex (polygon.GetVertexIndex (triangle[2])).position; + normal1 = vertexNormals[index][triangle[0]]; + normal2 = vertexNormals[index][triangle[1]]; + normal3 = vertexNormals[index][triangle[2]]; + uv1 = null; + uv2 = null; + uv3 = null; + if (hasTextureCoords) { + uv1 = textureCoords[index][triangle[0]]; + uv2 = textureCoords[index][triangle[1]]; + uv3 = textureCoords[index][triangle[2]]; + } + + CreateTriangle (vertex1, vertex2, vertex3, normal1, normal2, normal3, uv1, uv2, uv3); } - - CreateTriangle (vertex1, vertex2, vertex3, normal1, normal2, normal3, uv1, uv2, uv3); } } } diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index 4ac2f53d..fef723d4 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -1797,91 +1797,6 @@ polygonSuite.AddTest ('PolygonOffsetTest', function (test) test.Assert (offseted.vertices[4].IsEqual (new JSM.Coord (0.8, 1.1527864045000422, 0.0))); }); -polygonSuite.AddTest ('CreatePolygonWithHoleTest', function (test) -{ - function CreatePolygon (vertices, indices) - { - var result = new JSM.Polygon (); - - var i, vertex; - for (i = 0; i < indices.length; i++) { - vertex = vertices[indices[i]]; - result.AddVertex (vertex.x, vertex.y, vertex.z); - } - - return result; - } - - var i, j; - for (i = 0; i <= 3; i++) { - var vertices = [ - new JSM.Coord (0, 0, 0), - new JSM.Coord (7, 0, 0), - new JSM.Coord (7, 3, 0), - new JSM.Coord (0, 3, 0), - null, - new JSM.Coord (1, 1, 0), - new JSM.Coord (1, 2, 0), - new JSM.Coord (2, 2, 0), - new JSM.Coord (2, 1, 0), - null, - new JSM.Coord (3, 1, 0), - new JSM.Coord (3, 2, 0), - new JSM.Coord (4, 2, 0), - new JSM.Coord (4, 1, 0), - null, - new JSM.Coord (5, 1, 0), - new JSM.Coord (5, 2, 0), - new JSM.Coord (6, 2, 0), - new JSM.Coord (6, 1, 0) - ]; - - if (i > 0) { - var transformation; - if (i == 1) { - transformation = new JSM.RotationXTransformation (90.0 * JSM.DegRad); - } else if (i == 2) { - transformation = new JSM.RotationYTransformation (90.0 * JSM.DegRad); - } else if (i == 3) { - transformation = new JSM.RotationZTransformation (90.0 * JSM.DegRad); - } - var j; - for (j = 0; j < vertices.length; j++) { - if (vertices[j] !== null) { - vertices[j] = transformation.Apply (vertices[j]); - } - } - } - - var indices = JSM.CreatePolygonWithHole (vertices); - test.Assert (indices.toString () == [0, 5, 6, 7, 10, 11, 12, 15, 16, 17, 18, 15, 12, 13, 10, 7, 8, 5, 0, 1, 2, 3].toString ()); - - var polygon = CreatePolygon (vertices, indices); - var triangles = JSM.PolygonTriangulate (polygon); - test.Assert (triangles.length == 20); - test.Assert (triangles[0].toString () == [21, 2, 20].toString ()); - test.Assert (triangles[1].toString () == [5, 3, 4].toString ()); - test.Assert (triangles[2].toString () == [0, 2, 21].toString ()); - test.Assert (triangles[3].toString () == [2, 0, 1].toString ()); - test.Assert (triangles[4].toString () == [20, 3, 5].toString ()); - test.Assert (triangles[5].toString () == [3, 20, 2].toString ()); - test.Assert (triangles[6].toString () == [8, 6, 7].toString ()); - test.Assert (triangles[7].toString () == [9, 20, 8].toString ()); - test.Assert (triangles[8].toString () == [20, 6, 8].toString ()); - test.Assert (triangles[9].toString () == [6, 20, 5].toString ()); - test.Assert (triangles[10].toString () == [10, 20, 9].toString ()); - test.Assert (triangles[11].toString () == [11, 18, 10].toString ()); - test.Assert (triangles[12].toString () == [19, 10, 18].toString ()); - test.Assert (triangles[13].toString () == [10, 19, 20].toString ()); - test.Assert (triangles[14].toString () == [11, 13, 18].toString ()); - test.Assert (triangles[15].toString () == [13, 11, 12].toString ()); - test.Assert (triangles[16].toString () == [14, 18, 13].toString ()); - test.Assert (triangles[17].toString () == [18, 16, 17].toString ()); - test.Assert (triangles[18].toString () == [14, 16, 18].toString ()); - test.Assert (triangles[19].toString () == [16, 14, 15].toString ()); - } -}); - polygonSuite.AddTest ('OldCutPolygonTest', function (test) { var polygon = new JSM.Polygon (); From 3b841e8e9721ba9495932bd9e64228adf9742a10 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 18 Jul 2015 11:02:53 +0200 Subject: [PATCH 13/27] Add triangulation speed test. --- sandbox/svgtomodel2.html | 136 ++++++++++++++++++++++++++++++++ sandbox/triangulationspeed.html | 130 ++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 sandbox/svgtomodel2.html create mode 100644 sandbox/triangulationspeed.html diff --git a/sandbox/svgtomodel2.html b/sandbox/svgtomodel2.html new file mode 100644 index 00000000..decaaf26 --- /dev/null +++ b/sandbox/svgtomodel2.html @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Example + + + + + + + + + + + +
+ + + + + diff --git a/sandbox/triangulationspeed.html b/sandbox/triangulationspeed.html new file mode 100644 index 00000000..62c1e163 --- /dev/null +++ b/sandbox/triangulationspeed.html @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Example + + + + + + +
+ + + From 68d17966ab46ea10e434d25a3ae8bd3fdb3fe48b Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 20 Jul 2015 17:38:17 +0200 Subject: [PATCH 14/27] Remove OldPolygon2D. --- build/jsmodeler.js | 425 ++++++------ documentation/jsmdoc/include/jsmdoc.json | 214 ++---- sandbox/3dsdump.html | 1 + sandbox/bezier.html | 1 + sandbox/beziercurve.html | 1 + sandbox/bspline.html | 1 + sandbox/charts.html | 1 + sandbox/convexhull.html | 1 + sandbox/coplanar.html | 1 + sandbox/csg.html | 1 + sandbox/csg2.html | 1 + sandbox/curvedprism.html | 1 + sandbox/docimages.html | 1 + sandbox/doublesided.html | 1 + sandbox/githublogo.html | 1 + sandbox/heightmap.html | 1 + sandbox/hiddenline.html | 1 + sandbox/importer.html | 1 + sandbox/jsonimport.html | 1 + sandbox/jsonimporttexture.html | 1 + sandbox/minimal.html | 1 + sandbox/minimal2.html | 1 + sandbox/octree.html | 1 + sandbox/pointcloud.html | 1 + sandbox/pointcloudjson.html | 1 + sandbox/print.html | 1 + sandbox/prismwithhole.html | 1 + sandbox/randommat.html | 1 + sandbox/renderer.html | 1 + sandbox/revolved.html | 1 + sandbox/smartbuilder.html | 1 + sandbox/smartbuilder2.html | 1 + sandbox/solids.html | 1 + sandbox/specular.html | 1 + sandbox/svgonthefly.html | 1 + sandbox/svgtomodel.html | 1 + sandbox/svgtomodel2.html | 1 + sandbox/svgtomodeltexture.html | 1 + sandbox/tasks.html | 1 + sandbox/texture.html | 1 + sandbox/tictactoecanvas.html | 1 + sandbox/triangulate.html | 1 + sandbox/triangulationspeed.html | 130 ---- sandbox/tube.html | 1 + sandbox/undermouse.html | 1 + sandbox/viewer.html | 1 + src/extras/drawing.js | 10 +- src/extras/svgtomodel.js | 6 +- src/geometry/bsptree.js | 6 +- src/geometry/coord.js | 22 +- src/geometry/oldpolygon.js | 174 +---- src/geometry/oldpolygonutils.js | 814 +---------------------- src/geometry/polygon.js | 458 +++++++++++++ src/geometry/polygon2d.js | 36 +- src/geometry/triangulation.js | 48 +- src/modeler/bodyutils.js | 22 +- src/modeler/converter.js | 16 +- src/modeler/explode.js | 2 +- src/modeler/exporter.js | 19 +- src/modeler/generator.js | 25 +- test/unittest/jsmodelertest.js | 1 + test/unittest/tests/geometry.js | 165 ++--- test/unittest/tests/polygon.js | 122 ++-- test/unittest/tests/triangulation.js | 30 +- test/viewertest/cameratest.html | 1 + test/viewertest/csgtest.html | 1 + test/viewertest/importtest.html | 1 + test/viewertest/svgtomodeltest.html | 1 + test/viewertest/texturetest.html | 1 + test/viewertest/viewertest.html | 1 + test/viewertest/viewertypes.html | 1 + tools/files.txt | 1 + 72 files changed, 1044 insertions(+), 1752 deletions(-) delete mode 100644 sandbox/triangulationspeed.html create mode 100644 src/geometry/polygon.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index bd268cde..31d7aefc 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,9 +1,9 @@ /* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=37};JSM.RandomNumber=function(a,b){return Math.random()*(b-a)+a};JSM.RandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1)+a)};JSM.SeededRandomInt=function(a,b,c){return Math.floor((9301*c+49297)%233280/233280*(b-a+1)+a)};JSM.ValueOrDefault=function(a,b){return void 0===a||null===a?b:a}; JSM.CopyObjectProperties=function(a,b,c){if(!(void 0===a||null===a||void 0===b||null===b))for(var d in a)if(a.hasOwnProperty(d)&&(c||void 0===b[d]||null===b[d]))b[d]=a[d]};JSM.Assert=function(a,b){if(!a){var c="Assertion failed.";void 0!==b&&null!==b&&(c+=" "+b);alert(c)}};JSM.Timer=function(){this.stop=this.start=0};JSM.Timer.prototype.Start=function(){this.start=(new Date).getTime()};JSM.Timer.prototype.Stop=function(){this.end=(new Date).getTime()}; JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter=function(){this.current=this.frames=this.start=null};JSM.FPSCounter.prototype.Get=function(a){var b=(new Date).getTime();null===this.start&&(this.start=b,this.current=this.frames=0);if(null===a||void 0===a)a=1E3;this.frames+=1;var c=b-this.start;c>=a&&(this.current=1E3*(this.frames/c),this.start=b,this.frames=0);return parseInt(this.current,10)}; -JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;ca.length||void 0===b||null===b)){var c,d;for(c=0;cJSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.BarycentricInterpolation=function(a,b,c,d,e,f,g){function h(a,b,c){var d=(a+b+c)/2;a=d*(d-a)*(d-b)*(d-c);return 0>a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(g);b=b.DistanceTo(g);g=c.DistanceTo(g);c=h(l,k,m);if(JSM.IsZero(c))return d;l=h(l,a,b);k=h(k,b,g);m=h(m,a,g);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],s=a[11],t=a[13],v=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*t;r[2]=c*g+d*m+e*q+f*v;r[3]=c*l+d*n+e*s+f*u;return r}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],s=a[12],t=a[13],v=a[14],u=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*r+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=s*r+t*x+v*L+u*N;F[13]=s*w+t*A+v*H+u*O;F[14]=s*y+t*B+v*C+u*J;F[15]=s*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];return(b*h-c*f)*(n*a-p*t)-(b*g-d*f)*(m*a-p*s)+(b*l-e*f)*(m*t-n*s)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*t-n*q)+(d*l-e*g)*(k*s-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];var v=b*h-c*f,u=b*g-d*f,r=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*s-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*s,L=m*a-p*s,H=n*a-p*t,C=v*H-u*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(s*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*r-q*z-a*u)/C;E[7]=(k*z-n*r+p* -u)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-s*r+a*v)/C;E[11]=(m*r-k*y-p*v)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(s*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- -b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=a[1],h=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],s=a[11],t=a[13],v=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*g+d*k+e*p+f*t;r[2]=c*h+d*m+e*q+f*v;r[3]=c*l+d*n+e*s+f*u;return r}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],s=a[12],t=a[13],v=a[14],u=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=g*r+h*x+l*L+k*N;F[5]=g*w+h*A+l*H+k*O;F[6]=g*y+h*B+l*C+k*J;F[7]=g*z+h*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ +p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=s*r+t*x+v*L+u*N;F[13]=s*w+t*A+v*H+u*O;F[14]=s*y+t*B+v*C+u*J;F[15]=s*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];return(b*g-c*f)*(n*a-p*t)-(b*h-d*f)*(m*a-p*s)+(b*l-e*f)*(m*t-n*s)+(c*h-d*g)*(k*a-p*q)-(c*l-e*g)*(k*t-n*q)+(d*l-e*h)*(k*s-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];var v=b*g-c*f,u=b*h-d*f,r=b*l-e*f,w=c*h-d*g,y=c*l-e*g,z=d*l-e*h,x=k*s-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*s,L=m*a-p*s,H=n*a-p*t,C=v*H-u*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(g*H-h*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(s*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(h*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*r-q*z-a*u)/C;E[7]=(k*z-n*r+p* +u)/C;E[8]=(f*L-g*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-s*r+a*v)/C;E[11]=(m*r-k*y-p*v)/C;E[12]=(g*A-f*K-h*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(s*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,g=e*e,h=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(g+h)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=g+(f+h)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=h+(f+g)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(g+h)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=g+(f+h)*b;k[6]=e*d*(1- +b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=h+(f+g)*b;k[11]=0;k[12]=(m*(g+h)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+h)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+g)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,g=c+c,h=d+d;a=b*f;var l=b*g,b=b*h,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h,h=[];h[0]=1-(k+d);h[1]=l+e;h[2]=b-g;h[3]=0;h[4]=l-e;h[5]=1-(a+d);h[6]=c+f;h[7]=0;h[8]=b+g;h[9]=c-f;h[10]=1-(a+k);h[11]=0;h[12]=0;h[13]=0;h[14]=0;h[15]=1;return h};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.ToDirectionVectors=function(){this.e1=JSM.CoordSub(this.e1,this.origo);this.e2=JSM.CoordSub(this.e2,this.origo);this.e3=JSM.CoordSub(this.e3,this.origo);return this};JSM.CoordSystem.prototype.ToAbsoluteCoords=function(){this.e1=JSM.CoordAdd(this.e1,this.origo);this.e2=JSM.CoordAdd(this.e2,this.origo);this.e3=JSM.CoordAdd(this.e3,this.origo);return this}; JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.OldSectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3}; JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: +JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,g=this.end.y,h=this.GetLength();if(JSM.IsZero(h))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(g-e))/(h*h);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(g-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; -JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| +JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,g=a.beg.x,h=a.beg.y,l=a.end.x,k=a.end.y,m=(l-g)*(d-h)-(k-h)*(c-g),n=(e-c)*(d-h)-(f-d)*(c-g);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? -(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=h;n/= -h;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, -q=f.y,s=h.x,t=h.y,v=g.x,u=g.y,r=(v-s)*(n-t)-(u-t)*(m-s),w=(p-m)*(n-t)-(q-n)*(m-s),s=(u-t)*(p-m)-(v-s)*(q-n);if(JSM.IsZero(s)){if(JSM.IsZero(r)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=r/s;w/=s;if(JSM.IsLower(h, -0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; +(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;g=(k-h)*(e-c)-(l-g)*(f-d);if(JSM.IsZero(g))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=g;n/= +g;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,g=a.beg,h=a.end,l=e.IsEqual(g)||e.IsEqual(h),k=f.IsEqual(g)||f.IsEqual(h);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, +q=f.y,s=g.x,t=g.y,v=h.x,u=h.y,r=(v-s)*(n-t)-(u-t)*(m-s),w=(p-m)*(n-t)-(q-n)*(m-s),s=(u-t)*(p-m)-(v-s)*(q-n);if(JSM.IsZero(s)){if(JSM.IsZero(r)&&JSM.IsZero(w)){if(c(e,f,g)||c(e,f,h)||c(g,h,e)||c(g,h,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}g=r/s;w/=s;if(JSM.IsLower(g, +0)||JSM.IsGreater(g,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+g*(p-m),b.y=n+g*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,g=d.x,h=d.y,l=(g-e)*(g-e)+(h-f)*(h-f);if(JSM.IsZero(l))return a.Clone();b=((g-e)*(b-e)+(h-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: -JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,h,g;for(h=0;h<=b;h++)g=a.beg.Clone().Offset(d,f),c.push(g),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; +JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),g=e.x,h=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-g)*(k-g)+(m-h)*(m-h)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-g)*(b-g)+(m-h)*(c-h)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: +JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,g,h;for(g=0;g<=b;g++)h=a.beg.Clone().Offset(d,f),c.push(h),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; JSM.CoordLinePosition={CoordOnLine:0,CoordOutsideOfLine:1};JSM.LineLinePosition={LinesDontIntersect:0,LinesIntersectsOnePoint:1,LinesIntersectsCoincident:2};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; JSM.Line2D.prototype.CoordPosition=function(a){var b=this.start,c=this.direction;a=c.x*(a.y-b.y)-c.y*(a.x-b.x);return JSM.IsPositive(a)?JSM.CoordLinePosition2D.CoordAtLineLeft:JSM.IsNegative(a)?JSM.CoordLinePosition2D.CoordAtLineRight:JSM.CoordLinePosition2D.CoordOnLine};JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b}; -JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: -JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-h)*(k-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; -JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,g),k=[f,h,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),h=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= -JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(g.MultiplyScalar(h),b=JSM.CoordAdd(a,g),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; +JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,g=this.direction,h=f.x,l=f.y,k=f.z,m=f.x+g.x,n=f.y+g.y,p=f.z+g.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=g.Clone().MultiplyScalar(((m-h)*(c-h)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: +JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,g=a.y,h=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-g)*(k-g)+(m-h)*(m-h);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-g)*(c-g)+(m-h)*(d-h))/n);return JSM.CoordAdd(a,b)}; +JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,g=JSM.CoordAdd(f,e),h=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,h),k=[f,g,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),g=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(g*l-n*k)/m;g=(g+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= +JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(h.MultiplyScalar(g),b=JSM.CoordAdd(a,h),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b}; JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)};JSM.Box.prototype.IsCoordInside=function(a){return JSM.IsLower(a.x,this.min.x)||JSM.IsLower(a.y,this.min.y)||JSM.IsLower(a.z,this.min.z)||JSM.IsGreater(a.x,this.max.x)||JSM.IsGreater(a.y,this.max.y)||JSM.IsGreater(a.z,this.max.z)?!1:!0};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())}; JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)};JSM.Sphere=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.Set=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.GetCenter=function(){return this.center};JSM.Sphere.prototype.GetRadius=function(){return this.radius}; @@ -67,29 +67,29 @@ JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0=== JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.CoordPlanePosition={CoordOnPlane:0,CoordInFrontOfPlane:1,CoordAtBackOfPlane:2};JSM.LinePlanePosition={LineParallelToPlane:0,LineIntersectsPlane:1};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d}; JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)};JSM.Plane.prototype.CoordSignedDistance=function(a){var b=this.a,c=this.b,d=this.c;return(b*a.x+c*a.y+d*a.z+this.d)/Math.sqrt(b*b+c*c+d*d)};JSM.Plane.prototype.CoordDistance=function(a){a=this.CoordSignedDistance(a);return Math.abs(a)}; -JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; -JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,l=this.c,k=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; -JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+h*d+g*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; +JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,g=this.c,h=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+g*d+h,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; +JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,g=this.a,h=this.b,l=this.c,k=this.d,m=g*(d-(a.start.x+c.x))+h*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((g*d+h*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; +JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,g=this.b,h=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+g*(d-(a.start.y+b.y))+h*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+g*d+h*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; -JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((h*b+g*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; -JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; +JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,g=c.a,h=c.b,l=c.c;c=c.d;var k=g*(b-(a.x+d.x))+h*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((g*b+h*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(g*b+h*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; +JSM.Project=function(a,b,c,d,e,f,g,h,l){b=JSM.MatrixView(b,c,d);g=JSM.MatrixPerspective(e,f,g,h);e=new JSM.Coord(0,0,0);h=[];f=[];h[0]=a.x;h[1]=a.y;h[2]=a.z;h[3]=1;f=JSM.MatrixVectorMultiply(g,JSM.MatrixVectorMultiply(b,h));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qf)return e;var h,g,l,k,m;for(h=0;he)return d;var f,g,h,l,k;for(f=0;fa)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;c=c+this.c JSM.ContourPolygon2D.prototype.GetContourVertex=function(a,b){return this.contours[a].GetVertex(b)};JSM.ContourPolygon2D.prototype.GetContour=function(a){return this.contours[a]};JSM.ContourPolygon2D.prototype.ContourCount=function(){return this.contours.length};JSM.ContourPolygon2D.prototype.GetSignedArea=function(){var a=0,b;for(b=0;bf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; -JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.OldPolygon2D=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.AddVertex=function(a,b){this.vertices.push(new JSM.Coord2D(a,b))};JSM.OldPolygon2D.prototype.GetVertex=function(a){return this.vertices[a]}; -JSM.OldPolygon2D.prototype.SetVertex=function(a,b,c){this.vertices[a].Set(b,c)};JSM.OldPolygon2D.prototype.VertexCount=function(){return this.vertices.length};JSM.OldPolygon2D.prototype.Clear=function(){this.vertices=[]};JSM.OldPolygon2D.prototype.Clone=function(){var a=new JSM.OldPolygon2D,b;for(b=0;b=e)return!0;var f,g,h,k;for(f=0;2>f;f++){h=g=-1;0===f?(g=b,h=c):1===f&& -(g=c,h=b);k=[];for(k.push(a[h]);g!==h;g=gf)return[];a=[];var h=[],g,l,k;for(g=0;gb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; +JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)};JSM.OldContourPolygon2D=function(){this.polygons=[]}; +JSM.OldContourPolygon2D.prototype.AddVertex=function(a,b,c){void 0===this.polygons[a]&&(this.polygons[a]=new JSM.Polygon2D);this.polygons[a].AddVertex(b,c)};JSM.OldContourPolygon2D.prototype.VertexCount=function(a){return void 0===this.polygons[a]?0:this.polygons[a].VertexCount()};JSM.OldContourPolygon2D.prototype.GetVertex=function(a,b){return this.polygons[a].GetVertex(b)};JSM.OldContourPolygon2D.prototype.SetVertex=function(a,b,c,d){this.polygons[a].SetVertex(b,c,d)}; +JSM.OldContourPolygon2D.prototype.AddContour=function(){this.polygons.push(new JSM.Polygon2D)};JSM.OldContourPolygon2D.prototype.ContourCount=function(){return this.polygons.length};JSM.OldContourPolygon2D.prototype.GetContour=function(a){return this.polygons[a]};JSM.OldContourPolygon2D.prototype.Clear=function(){this.polygons=[]};JSM.OldContourPolygon2D.prototype.Clone=function(){var a=new JSM.OldContourPolygon2D,b;for(b=0;b=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, b.children[7]):null};JSM.Octree.prototype.SplitNode=function(a){var b=this,c=JSM.CreateOctreeChildNodes(a.box,function(c){return b.CreateNewNode(a,c)});if(null===c)return!1;a.children=c;c=a.coords;a.coords=[];var d,e;for(d=0;db.VertexCount())return!1;var d;if(null===a.polygon){d=JSM.CalculateNormal(b.vertices);var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0b.VertexCount())return!1;var d;if(null===a.polygon){d=b.GetNormal();var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0k;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== -b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var h=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; -JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fk;k++)0===k?m=e:1===k?m=f:2===k&&(m=g),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(h=k,l=n);if(-1===h)return d;b=null;0===h?b=new JSM.CoordSystem(c.origo,f,g,new JSM.Coord(0,0,0)):1===h?b=new JSM.CoordSystem(c.origo,e,g,new JSM.Coord(0,0,0)):2===h&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var g=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,g,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; +JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,g;for(f=0;fe;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),v.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(v)}}var f=new JSM.Body;(function(){var d; -for(d=0;de;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),v.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(v)}}}var f=new JSM.Body; +(function(){var d;for(d=0;dw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, -p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var g,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),g=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, +p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,g,n,p);else if(g=!0,void 0!==c&&c&&(g=!1),q=JSM.CalculateBodyPolygonNormal(a,b),g){g=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, -c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=g(b,p.v0,c,d,f),p.n1=g(b,p.v1,c,d,f),p.n2=g(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= -new JSM.Polygon;for(e=0;eh))if(3==h)f=g.GetVertexIndex(0),h=g.GetVertexIndex(1),k=g.GetVertexIndex(2),b(c,g,f,h,k);else{l= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; -var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; +JSM.RayBoxIntersection=function(a,b,c){var d=a.GetOrigin(),e=a.GetDirection(),f=JSM.CoordToArray(d),e=JSM.CoordToArray(e);b=JSM.CoordToArray(b);c=JSM.CoordToArray(c);var g=[0,0,0],h=[0,0,0],l=!0,k;for(k=0;3>k;k++)JSM.IsLower(f[k],b[k])?(g[k]=-1,h[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(g[k]=1,h[k]=c[k],l=!1):g[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==g[k]&&!JSM.IsZero(e[k])?l[k]=(h[k]-f[k])/e[k]:l[k]=-1;g=0;for(k=1;3>k;k++)JSM.IsLower(l[g],l[k])&&(g=k);if(JSM.IsNegative(l[g]))return null; +var m=[0,0,0];for(k=0;3>k;k++)if(g!=k){if(m[k]=f[k]+l[g]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=h[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -296,11 +285,11 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,s,t,v,u,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;s=19;t=41472;v=41728;u=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +JSM.Read3dsFile=function(a,b){var c,d,e,f,g,h,l,k,m,n,p,q,s,t,v,u,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;g=40992;h=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;s=19;t=41472;v=41728;u=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ 255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==s?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= [1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==h?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +", "+d+")",3),n.ambient=V(a,b,p)):b==g?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==h?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= W(a,b,p)):b==t?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],s=[],t;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); -var b,c;for(b=0;bn.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=h(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=h(a,"mtllib"),n=g(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fc;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,g,h,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= @@ -336,9 +325,9 @@ JSM.ImportFileList.prototype.InitFromURLs=function(a){this.originalList=a;this.d JSM.ImportFileList.prototype.GetInputList=function(){var a=[],b,c,d;for(b=0;br;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rr;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg;g++)k=0===g?h.pgon1:h.pgon2,-1===k&&(k=0===g?h.pgon2:h.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],g,h,l,k;for(l=0;lthis.cameraFarDistanceLimit)return 0;c*=0.1;a||(c*=-1);this.camera.eye.Offset(b,c)};JSM.Navigation.prototype.DrawCallback=function(){void 0!==this.drawCallback&&null!==this.drawCallback&&this.drawCallback()};JSM.Navigation.prototype.ResizeCallback=function(){void 0!==this.resizeCallback&&null!==this.resizeCallback&&this.resizeCallback()}; JSM.Navigation.prototype.OnMouseDown=function(a){a.preventDefault();this.mouse.Down(a,this.canvas)};JSM.Navigation.prototype.OnMouseMove=function(a){a.preventDefault();this.mouse.Move(a,this.canvas);this.mouse.down&&(a=0,1==this.mouse.button?this.cameraEnableOrbit&&(a=0.5,this.Orbit(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()):3==this.mouse.button&&this.cameraEnablePan&&(a=0.001*this.camera.eye.DistanceTo(this.camera.center),this.Pan(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()))}; @@ -554,7 +543,7 @@ JSM.SoftwareViewer.prototype.GetBoundingSphere=function(){var a=this.GetCenter() JSM.SoftwareViewer.prototype.Draw=function(){var a,b;this.drawer.Clear();for(a=0;a + diff --git a/sandbox/bezier.html b/sandbox/bezier.html index cf752609..00bbcb88 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index ca24cc45..cc52390b 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/bspline.html b/sandbox/bspline.html index 6f73275d..9ae293bf 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/charts.html b/sandbox/charts.html index 59458150..36713e85 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index c4eef96d..b828e5d6 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 9b848705..4e74a1f8 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/csg.html b/sandbox/csg.html index 34a3cc72..cc548866 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/csg2.html b/sandbox/csg2.html index 4742ae25..8f5070ac 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index 159ce967..401d4a9e 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/docimages.html b/sandbox/docimages.html index 7cf03fc4..06566c09 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index db471198..88f95ee1 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index b66c9ebf..1d803622 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index 86065ac3..620afd0e 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 82cd8fe0..545ecbcf 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/importer.html b/sandbox/importer.html index e078db15..6a3e0de7 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index 97e04de8..359ebf61 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index 5206bec5..ea3c28fe 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/minimal.html b/sandbox/minimal.html index afb86484..710adef7 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index ca5442af..fba3edbb 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/octree.html b/sandbox/octree.html index 9ca2e54c..dd6ff440 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index f98bbe41..2e172a1e 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index 42ab93dc..7fe3146e 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/print.html b/sandbox/print.html index 8bf362cf..1049270d 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index f24f4f46..8dda1294 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/randommat.html b/sandbox/randommat.html index 69f64f00..de7dde29 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/renderer.html b/sandbox/renderer.html index 250cedc7..b50a9d67 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/revolved.html b/sandbox/revolved.html index 73d80cf2..118c4243 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index a8c120fa..4ae6aded 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index 37039343..70a303a5 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/solids.html b/sandbox/solids.html index 8139af55..bca469f3 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/specular.html b/sandbox/specular.html index 083052dc..7ae0297e 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index c1f5bfa0..2f2c24b7 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index 2277075b..7564695f 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/svgtomodel2.html b/sandbox/svgtomodel2.html index decaaf26..a7db8d58 100644 --- a/sandbox/svgtomodel2.html +++ b/sandbox/svgtomodel2.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 6c0b13fb..16b2f163 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/tasks.html b/sandbox/tasks.html index a4f6bdfa..76b43972 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/texture.html b/sandbox/texture.html index e907a037..04da9c77 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index 945b471f..cfbb23e3 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index 831e026c..fcb700a0 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/triangulationspeed.html b/sandbox/triangulationspeed.html deleted file mode 100644 index 62c1e163..00000000 --- a/sandbox/triangulationspeed.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example - - - - - - -
- - - diff --git a/sandbox/tube.html b/sandbox/tube.html index d846328b..a7de7a3f 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index 206e983d..78ddd4ce 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -29,6 +29,7 @@ + diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 0f091ae0..16bfb9a3 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -29,6 +29,7 @@ + diff --git a/src/extras/drawing.js b/src/extras/drawing.js index 914c4954..50fedbe0 100644 --- a/src/extras/drawing.js +++ b/src/extras/drawing.js @@ -62,7 +62,7 @@ JSM.CanvasDrawer.prototype.DrawLine = function (from, to) * Function: CanvasDrawer.DrawPolygon * Description: Draws a polygon to the target. * Parameters: -* polygon {OldPolygon2D} the polygon +* polygon {Polygon2D} the polygon * color {string} the hex color string * contour {boolean} need to draw contour */ @@ -168,7 +168,7 @@ JSM.SVGDrawer.prototype.DrawLine = function (from, to) * Function: SVGDrawer.DrawPolygon * Description: Draws a polygon to the target. * Parameters: -* polygon {OldPolygon2D} the polygon +* polygon {Polygon2D} the polygon * color {string} the hex color string * contour {boolean} need to draw contour */ @@ -222,7 +222,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, function GetProjectedPolygonFromBody (polygon) { - var projectedPolygon = new JSM.OldPolygon2D (); + var projectedPolygon = new JSM.Polygon2D (); var i, coord; for (i = 0; i < polygon.VertexIndexCount (); i++) { coord = body.GetVertexPosition (polygon.GetVertexIndex (i)); @@ -233,7 +233,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, function GetProjectedPolygonFromPolygon (polygon) { - var projectedPolygon = new JSM.OldPolygon2D (); + var projectedPolygon = new JSM.Polygon2D (); var i, coord; for (i = 0; i < polygon.VertexCount (); i++) { coord = polygon.GetVertex (i); @@ -294,7 +294,7 @@ JSM.DrawProjectedBody = function (body, materials, camera, drawMode, needClear, for (i = 0; i < body.PolygonCount (); i++) { polygon = body.GetPolygon (i); projected = GetProjectedPolygonFromBody (polygon); - if (JSM.PolygonOrientation2D (projected) == JSM.Orientation.CounterClockwise) { + if (projected.GetOrientation () == JSM.Orientation.CounterClockwise) { materialIndex = polygon.GetMaterialIndex (); color = materials.GetMaterial (materialIndex).diffuse; drawer.DrawPolygon (projected, color, true); diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index f6ec91ea..99d4782d 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -343,18 +343,18 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var basePolygon, baseOrientation, prism; var contourCount = polygon.ContourCount (); if (contourCount == 1) { - baseOrientation = JSM.PolygonOrientation2D (polygon.GetContour (0)); + baseOrientation = polygon.GetContour (0).GetOrientation (); basePolygon = CreateBasePolygon (polygon.GetContour (0), baseOrientation); prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true); prisms.push (prism); } else if (contourCount > 1) { - baseOrientation = JSM.PolygonOrientation2D (polygon.GetContour (0)); + baseOrientation = polygon.GetContour (0).GetOrientation (); var holeBasePolygon = CreateBasePolygon (polygon.GetContour (0), baseOrientation); var hasHoles = false; var i, orientation; for (i = 1; i < polygon.ContourCount (); i++) { - orientation = JSM.PolygonOrientation2D (polygon.GetContour (i)); + orientation = polygon.GetContour (i).GetOrientation (); if (orientation == baseOrientation) { basePolygon = CreateBasePolygon (polygon.GetContour (i), baseOrientation); prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true); diff --git a/src/geometry/bsptree.js b/src/geometry/bsptree.js index 2f08a1ce..b6f6bdee 100644 --- a/src/geometry/bsptree.js +++ b/src/geometry/bsptree.js @@ -100,7 +100,7 @@ JSM.BSPTree.prototype.AddPolygonToNode = function (node, polygon, userData) var normal; if (node.polygon === null) { - normal = JSM.CalculateNormal (polygon.vertices); + normal = polygon.GetNormal (); var plane = JSM.GetPlaneFromCoordAndDirection (polygon.GetVertex (0), normal); node.polygon = polygon; if (userData !== undefined) { @@ -120,7 +120,7 @@ JSM.BSPTree.prototype.AddPolygonToNode = function (node, polygon, userData) this.AddOutsidePolygonsToNode (node, frontPolygons, userData); } if (planePolygons.length > 0) { - normal = JSM.CalculateNormal (polygon.vertices); + normal = polygon.GetNormal (); if (JSM.VectorDot (normal, node.plane.GetNormal ()) > 0) { this.AddInsidePolygonsToNode (node, planePolygons, userData); } else { @@ -228,7 +228,7 @@ JSM.ClipPolygonWithBSPTree = function (polygon, bspTree, frontPolygons, backPoly AddOutsidePolygons (node, cutFrontPolygons, isPlanar); } if (cutPlanarPolygons.length > 0) { - var normal = JSM.CalculateNormal (polygon.vertices); + var normal = polygon.GetNormal (); if (JSM.VectorDot (normal, node.plane.GetNormal ()) > 0) { AddInsidePolygons (node, cutPlanarPolygons, true); } else { diff --git a/src/geometry/coord.js b/src/geometry/coord.js index 6d9329d3..83a86d58 100644 --- a/src/geometry/coord.js +++ b/src/geometry/coord.js @@ -214,17 +214,6 @@ JSM.Coord.prototype.Rotate = function (axis, angle, origo) return this; }; -/** -* Function: Coord.ToString -* Description: Converts the coordinate values to string. -* Returns: -* {string} the string representation of the coordinate -*/ -JSM.Coord.prototype.ToString = function () -{ - return ('(' + this.x + ', ' + this.y + ', ' + this.z + ')'); -}; - /** * Function: Coord.ToCoord2D * Description: Converts the coordinate to a 2D coordinate. @@ -243,6 +232,17 @@ JSM.Coord.prototype.ToCoord2D = function (normal) return new JSM.Coord2D (rotated.x, rotated.y); }; +/** +* Function: Coord.ToString +* Description: Converts the coordinate values to string. +* Returns: +* {string} the string representation of the coordinate +*/ +JSM.Coord.prototype.ToString = function () +{ + return ('(' + this.x + ', ' + this.y + ', ' + this.z + ')'); +}; + /** * Function: Coord.Clone * Description: Clones the coordinate. diff --git a/src/geometry/oldpolygon.js b/src/geometry/oldpolygon.js index 9f1dce2c..85fb24ec 100644 --- a/src/geometry/oldpolygon.js +++ b/src/geometry/oldpolygon.js @@ -1,86 +1,3 @@ -/** -* Class: OldPolygon2D -* Description: Represents a 2D polygon. -*/ -JSM.OldPolygon2D = function () -{ - this.vertices = []; -}; - -/** -* Function: OldPolygon2D.AddVertex -* Description: Adds a vertex to the polygon. -* Parameters: -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -*/ -JSM.OldPolygon2D.prototype.AddVertex = function (x, y) -{ - this.vertices.push (new JSM.Coord2D (x, y)); -}; - -/** -* Function: OldPolygon2D.GetVertex -* Description: Returns the vertex with the given index. -* Parameters: -* index {integer} the index of the vertex -* Returns: -* {Coord2D} the vertex -*/ -JSM.OldPolygon2D.prototype.GetVertex = function (index) -{ - return this.vertices[index]; -}; - -/** -* Function: OldPolygon2D.SetVertex -* Description: Modifies the coordinates of an existing vertex. -* Parameters: -* index {integer} the index of the vertex -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -*/ -JSM.OldPolygon2D.prototype.SetVertex = function (index, x, y) -{ - this.vertices[index].Set (x, y); -}; - -/** -* Function: OldPolygon2D.VertexCount -* Description: Returns the vertex count of the polygon. -* Returns: -* {integer} vertex count -*/ -JSM.OldPolygon2D.prototype.VertexCount = function () -{ - return this.vertices.length; -}; - -/** -* Function: OldPolygon2D.Clear -* Description: Makes the polygon empty. -*/ -JSM.OldPolygon2D.prototype.Clear = function () -{ - this.vertices = []; -}; - -/** -* Function: OldPolygon2D.Clone -* Description: Clones the polygon. -* Returns: -* {OldPolygon2D} a cloned instance -*/ -JSM.OldPolygon2D.prototype.Clone = function () -{ - var result = new JSM.OldPolygon2D (); - var i; - for (i = 0; i < this.vertices.length; i++) { - result.vertices.push (this.vertices[i].Clone ()); - } - return result; -}; - /** * Class: OldContourPolygon2D * Description: Represents a 2D polygon with more contours. @@ -101,7 +18,7 @@ JSM.OldContourPolygon2D = function () JSM.OldContourPolygon2D.prototype.AddVertex = function (contour, x, y) { if (this.polygons[contour] === undefined) { - this.polygons[contour] = new JSM.OldPolygon2D (); + this.polygons[contour] = new JSM.Polygon2D (); } this.polygons[contour].AddVertex (x, y); }; @@ -156,7 +73,7 @@ JSM.OldContourPolygon2D.prototype.SetVertex = function (contour, index, x, y) */ JSM.OldContourPolygon2D.prototype.AddContour = function () { - this.polygons.push (new JSM.OldPolygon2D ()); + this.polygons.push (new JSM.Polygon2D ()); }; /** @@ -176,7 +93,7 @@ JSM.OldContourPolygon2D.prototype.ContourCount = function () * Parameters: * contour {integer} the index of the contour * Returns: -* {OldPolygon2D} the contour +* {Polygon2D} the contour */ JSM.OldContourPolygon2D.prototype.GetContour = function (contour) { @@ -207,88 +124,3 @@ JSM.OldContourPolygon2D.prototype.Clone = function () } return result; }; - -/** -* Class: Polygon -* Description: Represents a 3D polygon. -*/ -JSM.Polygon = function () -{ - this.vertices = []; -}; - -/** -* Function: Polygon.AddVertex -* Description: Adds a vertex to the polygon. -* Parameters: -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -* z {number} the z coordinate of the vertex -*/ -JSM.Polygon.prototype.AddVertex = function (x, y, z) -{ - this.vertices.push (new JSM.Coord (x, y, z)); -}; - -/** -* Function: Polygon.GetVertex -* Description: Returns the vertex with the given index. -* Parameters: -* index {integer} the index of the vertex -* Returns: -* {Coord} the vertex -*/ -JSM.Polygon.prototype.GetVertex = function (index) -{ - return this.vertices[index]; -}; - -/** -* Function: Polygon.SetVertex -* Description: Modifies the coordinates of an existing vertex. -* Parameters: -* index {integer} the index of the vertex -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -* z {number} the z coordinate of the vertex -*/ -JSM.Polygon.prototype.SetVertex = function (index, x, y, z) -{ - this.vertices[index].Set (x, y, z); -}; - -/** -* Function: Polygon.VertexCount -* Description: Returns the vertex count of the polygon. -* Returns: -* {integer} vertex count -*/ -JSM.Polygon.prototype.VertexCount = function () -{ - return this.vertices.length; -}; - -/** -* Function: Polygon.Clear -* Description: Makes the polygon empty. -*/ -JSM.Polygon.prototype.Clear = function () -{ - this.vertices = []; -}; - -/** -* Function: Polygon.Clone -* Description: Clones the polygon. -* Returns: -* {Polygon} a cloned instance -*/ -JSM.Polygon.prototype.Clone = function () -{ - var result = new JSM.Polygon (); - var i; - for (i = 0; i < this.vertices.length; i++) { - result.vertices.push (this.vertices[i].Clone ()); - } - return result; -}; diff --git a/src/geometry/oldpolygonutils.js b/src/geometry/oldpolygonutils.js index dfc3e587..24ceb1be 100644 --- a/src/geometry/oldpolygonutils.js +++ b/src/geometry/oldpolygonutils.js @@ -4,11 +4,11 @@ * Parameters: * vertices {Coord2D[*]} the vertices * Returns: -* {OldPolygon2D} the result +* {Polygon2D} the result */ JSM.CreatePolygonFromVertices = function (vertices) { - var polygon = new JSM.OldPolygon2D (); + var polygon = new JSM.Polygon2D (); var i, current; for (i = 0; i < vertices.length; i++) { @@ -19,70 +19,11 @@ JSM.CreatePolygonFromVertices = function (vertices) return polygon; }; -/** -* Function: PolygonSignedArea2D -* Description: -* Calculates the signed area of a polygon. The result is positive if the polygon has -* counter clockwise orientation, negative if it has clockwise orientation. -* Parameters: -* polygon {OldPolygon2D} the polygon -* Returns: -* {number} the result -*/ -JSM.PolygonSignedArea2D = function (polygon) -{ - var count = polygon.VertexCount (); - var area = 0.0; - - var i, current, next; - for (i = 0; i < count; i++) { - current = polygon.GetVertex (i); - next = polygon.GetVertex ((i + 1) % count); - area += current.x * next.y - next.x * current.y; - } - - area /= 2.0; - return area; -}; - -/** -* Function: PolygonArea2D -* Description: Calculates the area of a polygon. -* Parameters: -* polygon {OldPolygon2D} the polygon -* Returns: -* {number} the result -*/ -JSM.PolygonArea2D = function (polygon) -{ - return Math.abs (JSM.PolygonSignedArea2D (polygon)); -}; - -/** -* Function: PolygonOrientation2D -* Description: Calculates the orientation of a polygon. -* Parameters: -* polygon {OldPolygon2D} the polygon -* Returns: -* {Orientation} the result -*/ -JSM.PolygonOrientation2D = function (polygon) -{ - var signedArea = JSM.PolygonSignedArea2D (polygon); - if (JSM.IsPositive (signedArea)) { - return JSM.Orientation.CounterClockwise; - } else if (JSM.IsNegative (signedArea)) { - return JSM.Orientation.Clockwise; - } - - return JSM.Orientation.Invalid; -}; - /** * Function: ChangePolygonOrientation2D * Description: Reverses the orientation of a polygon. * Parameters: -* polygon {OldPolygon2D} the polygon +* polygon {Polygon2D} the polygon */ JSM.ChangePolygonOrientation2D = function (polygon) { @@ -102,206 +43,17 @@ JSM.ChangePolygonOrientation2D = function (polygon) * Parameters: * vertices {Coord2D[*]} the vertices * Returns: -* {OldPolygon2D} the result +* {Polygon2D} the result */ JSM.CreateCCWPolygonFromVertices = function (vertices) { var polygon = JSM.CreatePolygonFromVertices (vertices); - if (JSM.PolygonOrientation2D (polygon) != JSM.Orientation.CounterClockwise) { + if (polygon.GetOrientation () != JSM.Orientation.CounterClockwise) { JSM.ChangePolygonOrientation2D (polygon); } return polygon; }; -/** -* Function: PolygonComplexity2D -* Description: Calculates the complexity of a polygon. -* Parameters: -* polygon {OldPolygon2D} the polygon -* Returns: -* {Complexity} the result -*/ -JSM.PolygonComplexity2D = function (polygon) -{ - var hasCounterClockwiseVertex = false; - var hasClockWiseVertex = false; - - var count = polygon.VertexCount (); - - var i, prevIndex, currIndex, nextIndex; - var prev, curr, next, orientation; - for (i = 0; i < count; i++) { - prevIndex = (i === 0 ? count - 1 : i - 1); - currIndex = i; - nextIndex = (i === count - 1 ? 0 : i + 1); - - prev = polygon.GetVertex (prevIndex); - curr = polygon.GetVertex (currIndex); - next = polygon.GetVertex (nextIndex); - - orientation = JSM.CoordOrientation2D (prev, curr, next); - if (orientation == JSM.Orientation.CounterClockwise) { - hasCounterClockwiseVertex = true; - } else if (orientation == JSM.Orientation.Clockwise) { - hasClockWiseVertex = true; - } - - if (hasCounterClockwiseVertex && hasClockWiseVertex) { - return JSM.Complexity.Concave; - } - } - - if (!hasCounterClockwiseVertex && !hasClockWiseVertex) { - return JSM.Complexity.Invalid; - } - - return JSM.Complexity.Convex; -}; - -/** -* Function: CoordPolygonPosition2D -* Description: Calculates the position of a coordinate and a polygon. -* Parameters: -* coord {Coord} the coordinate -* polygon {OldPolygon2D} the polygon -* Returns: -* {string} 'CoordOutsideOfPolygon', 'CoordInsideOfPolygon', or 'CoordOnPolygonEdge' -*/ -JSM.CoordPolygonPosition2D = function (coord, polygon) -{ - var count = polygon.VertexCount (); - - var i, current, next, sector; - for (i = 0; i < count; i++) { - current = polygon.GetVertex (i); - next = polygon.GetVertex ((i + 1) % count); - sector = new JSM.Sector2D (current, next); - - if (sector.CoordPosition (coord) != JSM.CoordSectorPosition2D.CoordOutsideOfSector) { - return 'CoordOnPolygonEdge'; - } - } - - var maxHorizontalDistance = 0.0; - var currentDistance; - for (i = 0; i < count; i++) { - currentDistance = Math.abs (polygon.GetVertex (i).x - coord.x); - if (JSM.IsGreater (currentDistance, maxHorizontalDistance)) { - maxHorizontalDistance = currentDistance; - } - } - - var ray = new JSM.Sector2D (coord, new JSM.Coord2D (coord.x + 2.0 * maxHorizontalDistance, coord.y)); - - var intersections = 0; - var intersection, ssp; - for (i = 0; i < count; i++) { - current = polygon.GetVertex (i); - next = polygon.GetVertex ((i + 1) % count); - - sector = new JSM.Sector2D (current, next); - intersection = new JSM.Coord2D (0.0, 0.0); - ssp = ray.OldSectorPosition (sector, intersection); - if (ssp === JSM.OldSectorSectorPosition2D.SectorsDontIntersect) { - continue; - } - - if (ssp === JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint) { - intersections++; - } else if (ssp === JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint) { - if (intersection.IsEqual (sector.beg)) { - if (JSM.IsGreater (sector.beg.y, sector.end.y)) { - intersections++; - } - } else if (intersection.IsEqual (sector.end)) { - if (JSM.IsLower (sector.beg.y, sector.end.y)) { - intersections++; - } - } - } - } - - if (intersections % 2 === 0) { - return 'CoordOutsideOfPolygon'; - } - - return 'CoordInsideOfPolygon'; -}; - -/** -* Function: SectorIntersectsPolygon2D -* Description: -* Determines if a sector intersects a polygon. The sides next to the starting and -* ending vertices will be skipped. To avoid this, give -1 for these values. -* Parameters: -* polygon {OldPolygon2D} the polygon -* sector {Sector2D} the sector -* from {integer} index of starting vertex -* end {integer} index of ending vertex -* Returns: -* {boolean} the result -*/ -JSM.SectorIntersectsPolygon2D = function (polygon, sector, from, to) -{ - var count = polygon.VertexCount (); - - var i, sectorBeg, sectorEnd, currentSector, position; - for (i = 0; i < count; i++) { - sectorBeg = i; - sectorEnd = (i + 1) % count; - if (sectorBeg == from || sectorEnd == from || sectorBeg == to || sectorEnd == to) { - continue; - } - - currentSector = new JSM.Sector2D (polygon.GetVertex (sectorBeg), polygon.GetVertex (sectorEnd)); - position = sector.OldSectorPosition (currentSector); - if (position !== JSM.OldSectorSectorPosition2D.SectorsDontIntersect) { - return true; - } - } - - return false; -}; - -/** -* Function: IsPolygonVertexVisible2D -* Description: -* Determines if a polygons vertex is visible from an another vertex. It means that the -* sector between the vertices does not intersects any side of the polygon and the sector -* lies fully inside the polygon. -* Parameters: -* polygon {OldPolygon2D} the polygon -* from {integer} index of starting vertex -* end {integer} index of ending vertex -* Returns: -* {boolean} the result -*/ -JSM.IsPolygonVertexVisible2D = function (polygon, from, to) -{ - if (from === to) { - return false; - } - - var count = polygon.VertexCount (); - var prev = (from > 0 ? from - 1 : count - 1); - var next = (from < count - 1 ? from + 1 : 0); - if (to === prev || to === next) { - return false; - } - - var diagonalSector = new JSM.Sector2D (polygon.GetVertex (from), polygon.GetVertex (to)); - if (JSM.SectorIntersectsPolygon2D (polygon, diagonalSector, from, to)) { - return false; - } - - var midCoord = JSM.MidCoord2D (diagonalSector.beg, diagonalSector.end); - if (JSM.CoordPolygonPosition2D (midCoord, polygon) !== 'CoordInsideOfPolygon') { - return false; - } - - return true; -}; - /** * Function: CreatePolygonWithHole2D * Description: @@ -336,7 +88,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) for (i = 0; i < contourCount; i++) { from = contourEnds[i] + 1; to = contourEnds[i + 1]; - polygon = new JSM.OldPolygon2D (); + polygon = new JSM.Polygon2D (); for (j = from; j < to; j++) { vertex = vertices[j]; polygon.AddVertex (vertex.x, vertex.y); @@ -350,11 +102,11 @@ JSM.CreatePolygonWithHole2D = function (vertices) { function IsNotIntersectingSector (currentSector, originalIndex, currentHoleIndex, originalPolygon, currentHolePolygon, contourPolygons, finishedContours) { - if (JSM.SectorIntersectsPolygon2D (originalPolygon, currentSector, originalIndex, -1)) { + if (originalPolygon.SectorPosition (currentSector, originalIndex, -1) != JSM.SectorPolygonPosition.NoIntersection) { return false; } - if (JSM.SectorIntersectsPolygon2D (currentHolePolygon, currentSector, -1, currentHoleIndex)) { + if (currentHolePolygon.SectorPosition (currentSector, -1, currentHoleIndex) != JSM.SectorPolygonPosition.NoIntersection) { return false; } @@ -364,7 +116,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) continue; } currentContourPolygon = contourPolygons[i]; - if (JSM.SectorIntersectsPolygon2D (currentContourPolygon, currentSector, -1, -1)) { + if (currentContourPolygon.SectorPosition (currentSector, -1, -1) != JSM.SectorPolygonPosition.NoIntersection) { return false; } } @@ -372,7 +124,7 @@ JSM.CreatePolygonWithHole2D = function (vertices) return true; } - var originalPolygon = new JSM.OldPolygon2D (); + var originalPolygon = new JSM.Polygon2D (); var i, j, vertex; for (i = 0; i < resultIndices.length; i++) { vertex = vertices[resultIndices[i]]; @@ -505,183 +257,6 @@ JSM.CreatePolygonWithHole2D = function (vertices) return resultIndices; }; -/** -* Function: PolygonTriangulate2D -* Description: -* Triangulates a polygon. The result defines triangles as an -* array of arrays with three original vertex indices. -* Parameters: -* polygon {OldPolygon2D} the polygon -* Returns: -* {integer[3][*]} the result -*/ -JSM.PolygonTriangulate2D = function (polygon) -{ - function Increase (value, count) - { - if (value < count - 1) { - return value + 1; - } else { - return 0; - } - } - - function Decrease (value, count) - { - if (value > 0) { - return value - 1; - } else { - return count - 1; - } - } - - function GetResult (resultPolygons, orientation) - { - var result = []; - var i, j, resultPolygon, resultTriangle; - for (i = 0; i < resultPolygons.length; i++) { - resultPolygon = resultPolygons[i]; - if (resultPolygon.length !== 3) { - continue; - } - - if (orientation == JSM.Orientation.CounterClockwise) { - result.push (resultPolygon); - } else { - resultTriangle = []; - for (j = resultPolygon.length - 1; j >= 0; j--) { - resultTriangle.push (count - resultPolygon[j] - 1); - } - result.push (resultTriangle); - } - } - return result; - } - - function IsVisibleVertex (polygon, vertex1, vertex2) - { - if (vertex1 === vertex2) { - return false; - } - - var currentVertexCount = polygon.VertexCount (); - if (Increase (vertex1, currentVertexCount) === vertex2 || Decrease (vertex1, currentVertexCount) === vertex2) { - return false; - } - - return JSM.IsPolygonVertexVisible2D (polygon, vertex1, vertex2); - } - - function SplitPolygon (polygon, vertex1, vertex2, resultPolygons) - { - var currentVertexCount = polygon.length; - if (currentVertexCount <= 3) { - return true; - } - - var i, j, start, end, resultPolygon; - for (i = 0; i < 2; i++) { - start = -1; - end = -1; - if (i === 0) { - start = vertex1; - end = vertex2; - } else if (i === 1) { - start = vertex2; - end = vertex1; - } - - resultPolygon = []; - resultPolygon.push (polygon[end]); - for (j = start; j !== end; j = Increase (j, currentVertexCount)) { - resultPolygon.push (polygon[j]); - } - resultPolygons.push (resultPolygon); - } - - return true; - } - - var workPolygon = polygon.Clone (); - var count = workPolygon.VertexCount (); - if (count < 3) { - return []; - } - - var resultPolygons = []; - var firstPolygon = []; - - var i, j, k; - for (i = 0; i < count; i++) { - firstPolygon.push (i); - } - - resultPolygons.push (firstPolygon); - if (count === 3) { - return resultPolygons; - } - - var complexity = JSM.PolygonComplexity2D (workPolygon); - var orientation = JSM.PolygonOrientation2D (workPolygon); - if (complexity == JSM.Complexity.Invalid || orientation == JSM.Orientation.Invalid) { - return []; - } - - if (orientation !== JSM.Orientation.CounterClockwise) { - var i1, i2, tmp; - for (i = 0; i < count / 2; i++) { - i1 = i; - i2 = count - i - 1; - tmp = workPolygon.vertices[i1]; - workPolygon.vertices[i1] = workPolygon.vertices[i2]; - workPolygon.vertices[i2] = tmp; - } - } - - if (complexity == JSM.Complexity.Convex) { - var triangle; - for (i = 0; i < count - 2; i++) { - triangle = []; - triangle.push (0); - triangle.push ((i + 1) % count); - triangle.push ((i + 2) % count); - resultPolygons.push (triangle); - } - return GetResult (resultPolygons, orientation); - } - - var currentPolygon, currentVertexCount, currentPolygon2D, createdNewPolygons, vertex; - for (i = 0; i < resultPolygons.length; i++) { - currentPolygon = resultPolygons[i]; - currentVertexCount = currentPolygon.length; - if (currentVertexCount === 3) { - continue; - } - - currentPolygon2D = new JSM.OldPolygon2D (); - for (j = 0; j < currentVertexCount; j++) { - vertex = workPolygon.GetVertex (currentPolygon[j]); - currentPolygon2D.AddVertex (vertex.x, vertex.y); - } - - createdNewPolygons = false; - for (j = 0; j < currentVertexCount; j++) { - for (k = 0; k < currentVertexCount; k++) { - if (IsVisibleVertex (currentPolygon2D, j, k)) { - SplitPolygon (currentPolygon, j, k, resultPolygons); - createdNewPolygons = true; - break; - } - } - if (createdNewPolygons) { - break; - } - } - } - - return GetResult (resultPolygons, orientation); -}; - /** * Function: CreatePolygonWithHole * Description: @@ -716,372 +291,3 @@ JSM.CreatePolygonWithHole = function (vertices) return JSM.CreatePolygonWithHole2D (vertices2D); }; - -/** -* Function: PolygonTriangulate -* Description: -* Triangulates a polygon. The result defines triangles as an -* array of arrays with three original vertex indices. -* Parameters: -* polygon {Polygon} the polygon -* Returns: -* {integer[3][*]} the result -*/ -JSM.PolygonTriangulate = function (polygon) -{ - var polygon2D = new JSM.OldPolygon2D (); - var normal = JSM.CalculateNormal (polygon.vertices); - - var vertexCount = polygon.VertexCount (); - var i, vertex; - for (i = 0; i < vertexCount; i++) { - vertex = polygon.GetVertex (i).ToCoord2D (normal); - polygon2D.AddVertex (vertex.x, vertex.y); - } - - return JSM.PolygonTriangulate2D (polygon2D); -}; - -/** -* Function: OffsetPolygonContour -* Description: Offsets all vertices of a polygon. -* Parameters: -* polygon {Polygon} the polygon -* width {number} the width of the offset -* Returns: -* {Polygon} the result -*/ -JSM.OffsetPolygonContour = function (polygon, width) -{ - var count = polygon.VertexCount (); - var normal = JSM.CalculateNormal (polygon.vertices); - - var prev, curr, next; - var prevVertex, currVertex, nextVertex; - var prevDir, nextDir; - var distance, offsetedCoord; - - var result = new JSM.Polygon (); - - var i, angle; - for (i = 0; i < count; i++) { - prev = (i === 0 ? count - 1 : i - 1); - curr = i; - next = (i === count - 1 ? 0 : i + 1); - - prevVertex = polygon.GetVertex (prev); - currVertex = polygon.GetVertex (curr); - nextVertex = polygon.GetVertex (next); - - prevDir = JSM.CoordSub (prevVertex, currVertex); - nextDir = JSM.CoordSub (nextVertex, currVertex); - angle = prevDir.AngleTo (nextDir) / 2.0; - if (JSM.CoordOrientation (prevVertex, currVertex, nextVertex, normal) == JSM.Orientation.Clockwise) { - angle = Math.PI - angle; - } - - distance = width / Math.sin (angle); - offsetedCoord = currVertex.Clone (); - offsetedCoord.Offset (nextDir, distance); - offsetedCoord.Rotate (normal, angle, currVertex); - result.AddVertex (offsetedCoord.x, offsetedCoord.y, offsetedCoord.z); - } - - return result; -}; - -/** -* Function: CutPolygonWithPlane -* Description: -* Cuts a polygon with a plane. The result array contains cutted -* polygons grouped by their position to the plane. -* Parameters: -* polygon {Polygon} the polygon -* plane {Plane} the plane -* frontPolygons {Polygon[*]} (out) polygons in front of the plane -* backPolygons {Polygon[*]} (out) polygons at the back of the plane -* planePolygons {Polygon[*]} (out) polygons on the plane -* Returns: -* {boolean} success -*/ -JSM.CutPolygonWithPlane = function (polygon, plane, frontPolygons, backPolygons, planePolygons) -{ - function AddCutVerticesToPolygon (polygon, plane, cutPolygon, vertexTypes) - { - function AddVertex (polygon, index, cutPolygon, originalTypes, vertexTypes) - { - function AddIntersectionVertex (polygon, cutPolygon, vertexTypes, prevIndex, currIndex, currType) - { - var prevType = vertexTypes[vertexTypes.length - 1]; - if (prevType !== 0 && currType !== 0 && prevType != currType) { - var prevVertex = polygon.GetVertex (prevIndex); - var currVertex = polygon.GetVertex (currIndex); - var line = new JSM.Line (currVertex, JSM.CoordSub (currVertex, prevVertex)); - var intersection = new JSM.Coord (0.0, 0.0, 0.0); - var linePlanePosition = plane.LinePosition (line, intersection); - if (linePlanePosition == JSM.LinePlanePosition.LineIntersectsPlane) { - cutPolygon.AddVertex (intersection.x, intersection.y, intersection.z); - vertexTypes.push (0); - } - } - } - - function AddOriginalVertex (polygon, cutPolygon, vertexTypes, currIndex, currType) - { - var currVertex = polygon.GetVertex (currIndex); - cutPolygon.AddVertex (currVertex.x, currVertex.y, currVertex.z); - vertexTypes.push (currType); - } - - var firstVertex = (index === 0); - var lastVertex = (index === polygon.VertexCount ()); - - var currIndex, prevIndex; - if (lastVertex) { - currIndex = 0; - prevIndex = polygon.VertexCount () - 1; - } else { - currIndex = index; - prevIndex = currIndex - 1; - } - - var currType = originalTypes[currIndex]; - if (!firstVertex) { - AddIntersectionVertex (polygon, cutPolygon, vertexTypes, prevIndex, currIndex, currType); - } - - if (!lastVertex) { - AddOriginalVertex (polygon, cutPolygon, vertexTypes, currIndex, currType); - } - - return currType; - } - - var originalTypes = []; - var backFound = false; - var frontFound = false; - - var i, position, currVertex, currType; - for (i = 0; i < polygon.VertexCount (); i++) { - currVertex = polygon.GetVertex (i); - position = plane.CoordPosition (currVertex); - currType = 0; - if (position == JSM.CoordPlanePosition.CoordInFrontOfPlane) { - currType = 1; - frontFound = true; - } else if (position == JSM.CoordPlanePosition.CoordAtBackOfPlane) { - currType = -1; - backFound = true; - } - originalTypes.push (currType); - } - - if (backFound && frontFound) { - for (i = 0; i <= polygon.VertexCount (); i++) { - AddVertex (polygon, i, cutPolygon, originalTypes, vertexTypes); - } - return 0; - } else { - if (backFound) { - return -1; - } else if (frontFound) { - return 1; - } - return 0; - } - } - - function AddSimplePolygon (polygon, foundSide, frontPolygons, backPolygons, planePolygons) - { - if (foundSide == 1) { - frontPolygons.push (polygon); - } else if (foundSide == -1) { - backPolygons.push (polygon); - } else { - planePolygons.push (polygon); - } - } - - function AddCuttedPolygons (cutPolygon, vertexTypes, frontPolygons, backPolygons) - { - function GetEntryVertices (vertexTypes) - { - function FindPrevSide (index, vertexTypes) - { - var currIndex = index; - while (vertexTypes[currIndex] === 0) { - currIndex = (currIndex > 0 ? currIndex - 1 : vertexTypes.length - 1); - } - return vertexTypes[currIndex]; - } - - var entryVertices = []; - var i, currSide, prevIndex, nextIndex, prevSide, nextSide; - for (i = 0; i < vertexTypes.length; i++) { - currSide = vertexTypes[i]; - if (currSide === 0) { - prevIndex = (i > 0 ? i - 1 : vertexTypes.length - 1); - nextIndex = (i < vertexTypes.length - 1 ? i + 1 : 0); - prevSide = vertexTypes[prevIndex]; - nextSide = vertexTypes[nextIndex]; - if (nextSide !== 0 && prevSide === 0) { - prevSide = FindPrevSide (prevIndex, vertexTypes); - } - - if ((prevSide == -1 && nextSide == 1) || (prevSide == 1 && nextSide == -1)) { - entryVertices.push (i); - } - } - } - return entryVertices; - } - - function SortEntryVertices (cutPolygon, entryVertices) - { - function SwapArrayValues (array, from, to) - { - var temp = array[from]; - array[from] = array[to]; - array[to] = temp; - } - - if (entryVertices.length < 2) { - return; - } - - var referenceCoord1 = cutPolygon.GetVertex (entryVertices[0]); - var referenceCoord2 = cutPolygon.GetVertex (entryVertices[1]); - var direction = JSM.CoordSub (referenceCoord2, referenceCoord1); - var referencePlane = JSM.GetPlaneFromCoordAndDirection (referenceCoord1, direction); - - var i, j, vertex; - var distances = []; - for (i = 0; i < entryVertices.length; i++) { - vertex = cutPolygon.GetVertex (entryVertices[i]); - distances.push (referencePlane.CoordSignedDistance (vertex)); - } - - for (i = 0; i < entryVertices.length - 1; i++) { - for (j = 0; j < entryVertices.length - i - 1; j++) { - if (JSM.IsGreater (distances[j], distances[j + 1])) { - SwapArrayValues (distances, j, j + 1); - SwapArrayValues (entryVertices, j, j + 1); - } - } - } - } - - function GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, reversed) - { - function AddEntryPairToArray (entryPairs, entryVertices, index) - { - entryPairs[entryVertices[index]] = entryVertices[index + 1]; - entryPairs[entryVertices[index + 1]] = entryVertices[index]; - } - - function RemoveEntryPairFromArray (entryPairs, index) - { - entryPairs[entryPairs[index]] = -1; - entryPairs[index] = -1; - } - - function CreateEntryPairsArray (cutPolygon, entryVertices, entryPairs) - { - var i; - for (i = 0; i < cutPolygon.VertexCount (); i++) { - entryPairs.push (-1); - } - - for (i = 0; i < entryVertices.length; i = i + 2) { - AddEntryPairToArray (entryPairs, entryVertices, i); - } - } - - var entryPairs = []; - CreateEntryPairsArray (cutPolygon, entryVertices, entryPairs); - - var currEntryVertex = 0; - if (reversed) { - currEntryVertex = entryVertices.length - 1; - } - - var startVertexIndex = entryVertices[currEntryVertex]; - var currVertexIndex = startVertexIndex; - - var sideFound = false; - var polygonSide = 0; - - var currPolygon = new JSM.Polygon (); - var currVertex; - - while (true) { - if (!sideFound) { - polygonSide = vertexTypes[currVertexIndex]; - if (polygonSide !== 0) { - sideFound = true; - } - } - - if (currPolygon.VertexCount () > 0 && currVertexIndex == startVertexIndex) { - if (polygonSide == 1) { - frontPolygons.push (currPolygon); - } else if (polygonSide == -1) { - backPolygons.push (currPolygon); - } - - currPolygon = new JSM.Polygon (); - if (currEntryVertex > 0 && currEntryVertex < entryVertices.length) { - startVertexIndex = entryVertices[currEntryVertex]; - currVertexIndex = startVertexIndex; - continue; - } else { - break; - } - } - - currVertex = cutPolygon.GetVertex (currVertexIndex); - currPolygon.AddVertex (currVertex.x, currVertex.y, currVertex.z); - - if (entryPairs[currVertexIndex] != -1) { - if (!reversed) { - currEntryVertex = currEntryVertex + 2; - } else { - currEntryVertex = currEntryVertex - 2; - } - currVertexIndex = entryPairs[currVertexIndex]; - RemoveEntryPairFromArray (entryPairs, currVertexIndex); - } else { - if (currVertexIndex < cutPolygon.VertexCount () - 1) { - currVertexIndex = currVertexIndex + 1; - } else { - currVertexIndex = 0; - } - } - } - } - - var entryVertices = GetEntryVertices (vertexTypes); - if (entryVertices.length === 0 || entryVertices.length % 2 !== 0) { - return; - } - - SortEntryVertices (cutPolygon, entryVertices); - GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, false); - GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, true); - } - - var cutPolygon = new JSM.Polygon (); - - var vertexTypes = []; - var foundSide = AddCutVerticesToPolygon (polygon, plane, cutPolygon, vertexTypes); - if (cutPolygon.VertexCount () === 0 && vertexTypes.length === 0) { - AddSimplePolygon (polygon, foundSide, frontPolygons, backPolygons, planePolygons); - } else { - AddCuttedPolygons (cutPolygon, vertexTypes, frontPolygons, backPolygons); - } - - if (frontPolygons.length + backPolygons.length + planePolygons.length === 0) { - return false; - } - return true; -}; diff --git a/src/geometry/polygon.js b/src/geometry/polygon.js new file mode 100644 index 00000000..b7d379cb --- /dev/null +++ b/src/geometry/polygon.js @@ -0,0 +1,458 @@ +/** +* Class: Polygon +* Description: Represents a 3D polygon. +*/ +JSM.Polygon = function () +{ + this.vertices = []; +}; + +/** +* Function: Polygon.AddVertex +* Description: Adds a vertex to the polygon. +* Parameters: +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +* z {number} the z coordinate of the vertex +*/ +JSM.Polygon.prototype.AddVertex = function (x, y, z) +{ + this.vertices.push (new JSM.Coord (x, y, z)); +}; + +/** +* Function: Polygon.GetVertex +* Description: Returns the vertex with the given index. +* Parameters: +* index {integer} the index of the vertex +* Returns: +* {Coord} the vertex +*/ +JSM.Polygon.prototype.GetVertex = function (index) +{ + return this.vertices[index]; +}; + +/** +* Function: Polygon.SetVertex +* Description: Modifies the coordinates of an existing vertex. +* Parameters: +* index {integer} the index of the vertex +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +* z {number} the z coordinate of the vertex +*/ +JSM.Polygon.prototype.SetVertex = function (index, x, y, z) +{ + this.vertices[index].Set (x, y, z); +}; + +/** +* Function: Polygon.VertexCount +* Description: Returns the vertex count of the polygon. +* Returns: +* {integer} vertex count +*/ +JSM.Polygon.prototype.VertexCount = function () +{ + return this.vertices.length; +}; + +/** +* Function: Polygon.GetNormal +* Description: Calculates the normal vector of the polygon. +* Returns: +* {Vector} the result +*/ +JSM.Polygon.prototype.GetNormal = function () +{ + return JSM.CalculateNormal (this.vertices); +}; + +/** +* Function: Polygon.ToPolygon2D +* Description: Converts the polygon to a 2D polygon. +* Returns: +* {Polygon2D} the result +*/ +JSM.Polygon.prototype.ToPolygon2D = function () +{ + var normal = this.GetNormal (); + var result = new JSM.Polygon2D (); + var i, vertex; + for (i = 0; i < this.vertices.length; i++) { + vertex = this.vertices[i].ToCoord2D (normal); + result.AddVertex (vertex.x, vertex.y); + } + return result; +}; + +/** +* Function: Polygon.Clear +* Description: Makes the polygon empty. +*/ +JSM.Polygon.prototype.Clear = function () +{ + this.vertices = []; +}; + +/** +* Function: Polygon.Clone +* Description: Clones the polygon. +* Returns: +* {Polygon} a cloned instance +*/ +JSM.Polygon.prototype.Clone = function () +{ + var result = new JSM.Polygon (); + var i, vertex; + for (i = 0; i < this.vertices.length; i++) { + vertex = this.vertices[i]; + result.AddVertex (vertex.x, vertex.y); + } + return result; +}; + +/** +* Function: OffsetPolygonContour +* Description: Offsets all vertices of a polygon. +* Parameters: +* polygon {Polygon} the polygon +* width {number} the width of the offset +* Returns: +* {Polygon} the result +*/ +JSM.OffsetPolygonContour = function (polygon, width) +{ + var count = polygon.VertexCount (); + var normal = polygon.GetNormal (); + + var prev, curr, next; + var prevVertex, currVertex, nextVertex; + var prevDir, nextDir; + var distance, offsetedCoord; + + var result = new JSM.Polygon (); + + var i, angle; + for (i = 0; i < count; i++) { + prev = (i === 0 ? count - 1 : i - 1); + curr = i; + next = (i === count - 1 ? 0 : i + 1); + + prevVertex = polygon.GetVertex (prev); + currVertex = polygon.GetVertex (curr); + nextVertex = polygon.GetVertex (next); + + prevDir = JSM.CoordSub (prevVertex, currVertex); + nextDir = JSM.CoordSub (nextVertex, currVertex); + angle = prevDir.AngleTo (nextDir) / 2.0; + if (JSM.CoordOrientation (prevVertex, currVertex, nextVertex, normal) == JSM.Orientation.Clockwise) { + angle = Math.PI - angle; + } + + distance = width / Math.sin (angle); + offsetedCoord = currVertex.Clone (); + offsetedCoord.Offset (nextDir, distance); + offsetedCoord.Rotate (normal, angle, currVertex); + result.AddVertex (offsetedCoord.x, offsetedCoord.y, offsetedCoord.z); + } + + return result; +}; + +/** +* Function: CutPolygonWithPlane +* Description: +* Cuts a polygon with a plane. The result array contains cutted +* polygons grouped by their position to the plane. +* Parameters: +* polygon {Polygon} the polygon +* plane {Plane} the plane +* frontPolygons {Polygon[*]} (out) polygons in front of the plane +* backPolygons {Polygon[*]} (out) polygons at the back of the plane +* planePolygons {Polygon[*]} (out) polygons on the plane +* Returns: +* {boolean} success +*/ +JSM.CutPolygonWithPlane = function (polygon, plane, frontPolygons, backPolygons, planePolygons) +{ + function AddCutVerticesToPolygon (polygon, plane, cutPolygon, vertexTypes) + { + function AddVertex (polygon, index, cutPolygon, originalTypes, vertexTypes) + { + function AddIntersectionVertex (polygon, cutPolygon, vertexTypes, prevIndex, currIndex, currType) + { + var prevType = vertexTypes[vertexTypes.length - 1]; + if (prevType !== 0 && currType !== 0 && prevType != currType) { + var prevVertex = polygon.GetVertex (prevIndex); + var currVertex = polygon.GetVertex (currIndex); + var line = new JSM.Line (currVertex, JSM.CoordSub (currVertex, prevVertex)); + var intersection = new JSM.Coord (0.0, 0.0, 0.0); + var linePlanePosition = plane.LinePosition (line, intersection); + if (linePlanePosition == JSM.LinePlanePosition.LineIntersectsPlane) { + cutPolygon.AddVertex (intersection.x, intersection.y, intersection.z); + vertexTypes.push (0); + } + } + } + + function AddOriginalVertex (polygon, cutPolygon, vertexTypes, currIndex, currType) + { + var currVertex = polygon.GetVertex (currIndex); + cutPolygon.AddVertex (currVertex.x, currVertex.y, currVertex.z); + vertexTypes.push (currType); + } + + var firstVertex = (index === 0); + var lastVertex = (index === polygon.VertexCount ()); + + var currIndex, prevIndex; + if (lastVertex) { + currIndex = 0; + prevIndex = polygon.VertexCount () - 1; + } else { + currIndex = index; + prevIndex = currIndex - 1; + } + + var currType = originalTypes[currIndex]; + if (!firstVertex) { + AddIntersectionVertex (polygon, cutPolygon, vertexTypes, prevIndex, currIndex, currType); + } + + if (!lastVertex) { + AddOriginalVertex (polygon, cutPolygon, vertexTypes, currIndex, currType); + } + + return currType; + } + + var originalTypes = []; + var backFound = false; + var frontFound = false; + + var i, position, currVertex, currType; + for (i = 0; i < polygon.VertexCount (); i++) { + currVertex = polygon.GetVertex (i); + position = plane.CoordPosition (currVertex); + currType = 0; + if (position == JSM.CoordPlanePosition.CoordInFrontOfPlane) { + currType = 1; + frontFound = true; + } else if (position == JSM.CoordPlanePosition.CoordAtBackOfPlane) { + currType = -1; + backFound = true; + } + originalTypes.push (currType); + } + + if (backFound && frontFound) { + for (i = 0; i <= polygon.VertexCount (); i++) { + AddVertex (polygon, i, cutPolygon, originalTypes, vertexTypes); + } + return 0; + } else { + if (backFound) { + return -1; + } else if (frontFound) { + return 1; + } + return 0; + } + } + + function AddSimplePolygon (polygon, foundSide, frontPolygons, backPolygons, planePolygons) + { + if (foundSide == 1) { + frontPolygons.push (polygon); + } else if (foundSide == -1) { + backPolygons.push (polygon); + } else { + planePolygons.push (polygon); + } + } + + function AddCuttedPolygons (cutPolygon, vertexTypes, frontPolygons, backPolygons) + { + function GetEntryVertices (vertexTypes) + { + function FindPrevSide (index, vertexTypes) + { + var currIndex = index; + while (vertexTypes[currIndex] === 0) { + currIndex = (currIndex > 0 ? currIndex - 1 : vertexTypes.length - 1); + } + return vertexTypes[currIndex]; + } + + var entryVertices = []; + var i, currSide, prevIndex, nextIndex, prevSide, nextSide; + for (i = 0; i < vertexTypes.length; i++) { + currSide = vertexTypes[i]; + if (currSide === 0) { + prevIndex = (i > 0 ? i - 1 : vertexTypes.length - 1); + nextIndex = (i < vertexTypes.length - 1 ? i + 1 : 0); + prevSide = vertexTypes[prevIndex]; + nextSide = vertexTypes[nextIndex]; + if (nextSide !== 0 && prevSide === 0) { + prevSide = FindPrevSide (prevIndex, vertexTypes); + } + + if ((prevSide == -1 && nextSide == 1) || (prevSide == 1 && nextSide == -1)) { + entryVertices.push (i); + } + } + } + return entryVertices; + } + + function SortEntryVertices (cutPolygon, entryVertices) + { + function SwapArrayValues (array, from, to) + { + var temp = array[from]; + array[from] = array[to]; + array[to] = temp; + } + + if (entryVertices.length < 2) { + return; + } + + var referenceCoord1 = cutPolygon.GetVertex (entryVertices[0]); + var referenceCoord2 = cutPolygon.GetVertex (entryVertices[1]); + var direction = JSM.CoordSub (referenceCoord2, referenceCoord1); + var referencePlane = JSM.GetPlaneFromCoordAndDirection (referenceCoord1, direction); + + var i, j, vertex; + var distances = []; + for (i = 0; i < entryVertices.length; i++) { + vertex = cutPolygon.GetVertex (entryVertices[i]); + distances.push (referencePlane.CoordSignedDistance (vertex)); + } + + for (i = 0; i < entryVertices.length - 1; i++) { + for (j = 0; j < entryVertices.length - i - 1; j++) { + if (JSM.IsGreater (distances[j], distances[j + 1])) { + SwapArrayValues (distances, j, j + 1); + SwapArrayValues (entryVertices, j, j + 1); + } + } + } + } + + function GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, reversed) + { + function AddEntryPairToArray (entryPairs, entryVertices, index) + { + entryPairs[entryVertices[index]] = entryVertices[index + 1]; + entryPairs[entryVertices[index + 1]] = entryVertices[index]; + } + + function RemoveEntryPairFromArray (entryPairs, index) + { + entryPairs[entryPairs[index]] = -1; + entryPairs[index] = -1; + } + + function CreateEntryPairsArray (cutPolygon, entryVertices, entryPairs) + { + var i; + for (i = 0; i < cutPolygon.VertexCount (); i++) { + entryPairs.push (-1); + } + + for (i = 0; i < entryVertices.length; i = i + 2) { + AddEntryPairToArray (entryPairs, entryVertices, i); + } + } + + var entryPairs = []; + CreateEntryPairsArray (cutPolygon, entryVertices, entryPairs); + + var currEntryVertex = 0; + if (reversed) { + currEntryVertex = entryVertices.length - 1; + } + + var startVertexIndex = entryVertices[currEntryVertex]; + var currVertexIndex = startVertexIndex; + + var sideFound = false; + var polygonSide = 0; + + var currPolygon = new JSM.Polygon (); + var currVertex; + + while (true) { + if (!sideFound) { + polygonSide = vertexTypes[currVertexIndex]; + if (polygonSide !== 0) { + sideFound = true; + } + } + + if (currPolygon.VertexCount () > 0 && currVertexIndex == startVertexIndex) { + if (polygonSide == 1) { + frontPolygons.push (currPolygon); + } else if (polygonSide == -1) { + backPolygons.push (currPolygon); + } + + currPolygon = new JSM.Polygon (); + if (currEntryVertex > 0 && currEntryVertex < entryVertices.length) { + startVertexIndex = entryVertices[currEntryVertex]; + currVertexIndex = startVertexIndex; + continue; + } else { + break; + } + } + + currVertex = cutPolygon.GetVertex (currVertexIndex); + currPolygon.AddVertex (currVertex.x, currVertex.y, currVertex.z); + + if (entryPairs[currVertexIndex] != -1) { + if (!reversed) { + currEntryVertex = currEntryVertex + 2; + } else { + currEntryVertex = currEntryVertex - 2; + } + currVertexIndex = entryPairs[currVertexIndex]; + RemoveEntryPairFromArray (entryPairs, currVertexIndex); + } else { + if (currVertexIndex < cutPolygon.VertexCount () - 1) { + currVertexIndex = currVertexIndex + 1; + } else { + currVertexIndex = 0; + } + } + } + } + + var entryVertices = GetEntryVertices (vertexTypes); + if (entryVertices.length === 0 || entryVertices.length % 2 !== 0) { + return; + } + + SortEntryVertices (cutPolygon, entryVertices); + GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, false); + GetOneSideCuttedPolygons (cutPolygon, entryVertices, vertexTypes, frontPolygons, backPolygons, true); + } + + var cutPolygon = new JSM.Polygon (); + + var vertexTypes = []; + var foundSide = AddCutVerticesToPolygon (polygon, plane, cutPolygon, vertexTypes); + if (cutPolygon.VertexCount () === 0 && vertexTypes.length === 0) { + AddSimplePolygon (polygon, foundSide, frontPolygons, backPolygons, planePolygons); + } else { + AddCuttedPolygons (cutPolygon, vertexTypes, frontPolygons, backPolygons); + } + + if (frontPolygons.length + backPolygons.length + planePolygons.length === 0) { + return false; + } + return true; +}; diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js index 96793cdb..081b4a10 100644 --- a/src/geometry/polygon2d.js +++ b/src/geometry/polygon2d.js @@ -5,14 +5,14 @@ JSM.Complexity = { Complex : 3 }; -JSM.CoordPosition = { +JSM.CoordPolygonPosition = { OnVertex : 0, OnEdge : 1, Inside : 2, Outside : 3 }; -JSM.SectorPosition = { +JSM.SectorPolygonPosition = { IntersectionOnePoint : 0, IntersectionCoincident : 1, IntersectionOnVertex : 2, @@ -218,29 +218,29 @@ JSM.Polygon2D.prototype.CoordPosition = function (coord) sector = new JSM.Sector2D (edgeFrom, edgeTo); position = sector.CoordPosition (coord); if (position == JSM.CoordSectorPosition2D.CoordInsideOfSector) { - return JSM.CoordPosition.OnEdge; + return JSM.CoordPolygonPosition.OnEdge; } else if (position == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - return JSM.CoordPosition.OnVertex; + return JSM.CoordPolygonPosition.OnVertex; } intersections += IntersectionCount (coord, edgeFrom, edgeTo); } if (intersections % 2 !== 0) { - return JSM.CoordPosition.Inside; + return JSM.CoordPolygonPosition.Inside; } - return JSM.CoordPosition.Outside; + return JSM.CoordPolygonPosition.Outside; }; -JSM.Polygon2D.prototype.SectorPosition = function (beg, end, begIndex, endIndex) +JSM.Polygon2D.prototype.SectorPosition = function (sector, begIndex, endIndex) { - var result = JSM.SectorPosition.NoIntersection; + var result = JSM.SectorPolygonPosition.NoIntersection; var vertexCount = this.vertices.length; if (vertexCount < 3) { return result; } var i, edgeBegIndex, edgeEndIndex, edgeBeg, edgeEnd; - var sector1, sector2, position; + var currentSector, position; for (i = 0; i < vertexCount; i++) { edgeBegIndex = i; edgeEndIndex = (i + 1) % vertexCount; @@ -249,15 +249,14 @@ JSM.Polygon2D.prototype.SectorPosition = function (beg, end, begIndex, endIndex) if (edgeBegIndex == begIndex || edgeEndIndex == begIndex || edgeBegIndex == endIndex || edgeEndIndex == endIndex) { continue; } - sector1 = new JSM.Sector2D (edgeBeg, edgeEnd); - sector2 = new JSM.Sector2D (beg, end); - position = sector1.SectorPosition (sector2); + currentSector = new JSM.Sector2D (edgeBeg, edgeEnd); + position = sector.SectorPosition (currentSector); if (position == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint) { - return JSM.SectorPosition.IntersectionOnePoint; + return JSM.SectorPolygonPosition.IntersectionOnePoint; } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectCoincident) { - return JSM.SectorPosition.IntersectionCoincident; + return JSM.SectorPolygonPosition.IntersectionCoincident; } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint) { - result = JSM.SectorPosition.IntersectionOnVertex; + result = JSM.SectorPolygonPosition.IntersectionOnVertex; } } @@ -270,8 +269,9 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) { var fromVertex = polygon.GetVertex (from); var toVertex = polygon.GetVertex (to); - var position = polygon.SectorPosition (fromVertex, toVertex, from, to); - if (position != JSM.SectorPosition.NoIntersection) { + var sector = new JSM.Sector2D (fromVertex, toVertex); + var position = polygon.SectorPosition (sector, from, to); + if (position != JSM.SectorPolygonPosition.NoIntersection) { return true; } return false; @@ -286,7 +286,7 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) (fromVertex.y + toVertex.y) / 2.0 ); var position = polygon.CoordPosition (midCoord); - return position == JSM.CoordPosition.Inside; + return position == JSM.CoordPolygonPosition.Inside; } if (from == to) { diff --git a/src/geometry/triangulation.js b/src/geometry/triangulation.js index adc42eea..3ab14453 100644 --- a/src/geometry/triangulation.js +++ b/src/geometry/triangulation.js @@ -8,8 +8,9 @@ JSM.ConvertContourPolygonToPolygon2D = function (inputPolygon) { function SegmentIntersectsPolygon (polygon, segmentBeg, segmentEnd) { - var position = polygon.SectorPosition (segmentBeg, segmentEnd, -1, -1); - if (position == JSM.SectorPosition.IntersectionOnePoint || position == JSM.SectorPosition.IntersectionCoincident) { + var sector = new JSM.Sector2D (segmentBeg, segmentEnd); + var position = polygon.SectorPosition (sector, -1, -1); + if (position == JSM.SectorPolygonPosition.IntersectionOnePoint || position == JSM.SectorPolygonPosition.IntersectionCoincident) { return true; } return false; @@ -163,6 +164,12 @@ JSM.TriangulateConcavePolygon2D = function (inputPolygon) function SplitPolygon (polygonData, diagonal) { + function AddVertex (polygonData, resultData, index) + { + resultData.polygon.AddVertexCoord (polygonData.polygon.GetVertex (index)); + resultData.map.push (polygonData.map[index]); + } + var resultData1 = { polygon : new JSM.Polygon2D (), map : [] @@ -171,14 +178,23 @@ JSM.TriangulateConcavePolygon2D = function (inputPolygon) polygon : new JSM.Polygon2D (), map : [] }; - polygonData.polygon.EnumerateVertices (diagonal.beg, diagonal.end, function (index) { - resultData1.polygon.AddVertexCoord (polygonData.polygon.GetVertex (index)); - resultData1.map.push (polygonData.map[index]); + + var beg, end; + + beg = diagonal.beg; + end = polygonData.polygon.GetPrevVertex (diagonal.end); + AddVertex (polygonData, resultData1, diagonal.end); + polygonData.polygon.EnumerateVertices (beg, end, function (index) { + AddVertex (polygonData, resultData1, index); }); - polygonData.polygon.EnumerateVertices (diagonal.end, diagonal.beg, function (index) { - resultData2.polygon.AddVertexCoord (polygonData.polygon.GetVertex (index)); - resultData2.map.push (polygonData.map[index]); + + beg = diagonal.end; + end = polygonData.polygon.GetPrevVertex (diagonal.beg); + AddVertex (polygonData, resultData2, diagonal.beg); + polygonData.polygon.EnumerateVertices (beg, end, function (index) { + AddVertex (polygonData, resultData2, index); }); + return { resultData1 : resultData1, resultData2 : resultData2 @@ -242,3 +258,19 @@ JSM.TriangulatePolygon2D = function (polygon) return JSM.TriangulateConcavePolygon2D (polygon); }; + +/** +* Function: TriangulatePolygon +* Description: +* Triangulates a polygon. The result defines triangles as an +* array of arrays with three original vertex indices. +* Parameters: +* polygon {Polygon} the polygon +* Returns: +* {integer[3][*]} the result +*/ +JSM.TriangulatePolygon = function (polygon) +{ + var polygon2D = polygon.ToPolygon2D (); + return JSM.TriangulatePolygon2D (polygon2D); +}; diff --git a/src/modeler/bodyutils.js b/src/modeler/bodyutils.js index 31013791..47e17ffe 100644 --- a/src/modeler/bodyutils.js +++ b/src/modeler/bodyutils.js @@ -274,16 +274,18 @@ JSM.TriangulatePolygons = function (body) coord = body.GetVertexPosition (bodyPolygon.GetVertexIndex (j)); polygon.AddVertex (coord.x, coord.y, coord.z); } - triangleIndices = JSM.PolygonTriangulate (polygon); - for (j = 0; j < triangleIndices.length; j++) { - triangle = triangleIndices[j]; - bodyTriangle = new JSM.BodyPolygon ([ - bodyPolygon.GetVertexIndex (triangle[0]), - bodyPolygon.GetVertexIndex (triangle[1]), - bodyPolygon.GetVertexIndex (triangle[2]) - ]); - bodyTriangle.InheritAttributes (bodyPolygon); - result.AddPolygon (bodyTriangle); + triangleIndices = JSM.TriangulatePolygon (polygon); + if (triangleIndices !== null) { + for (j = 0; j < triangleIndices.length; j++) { + triangle = triangleIndices[j]; + bodyTriangle = new JSM.BodyPolygon ([ + bodyPolygon.GetVertexIndex (triangle[0]), + bodyPolygon.GetVertexIndex (triangle[1]), + bodyPolygon.GetVertexIndex (triangle[2]) + ]); + bodyTriangle.InheritAttributes (bodyPolygon); + result.AddPolygon (bodyTriangle); + } } } diff --git a/src/modeler/converter.js b/src/modeler/converter.js index bf67816f..f04b4f1c 100644 --- a/src/modeler/converter.js +++ b/src/modeler/converter.js @@ -50,13 +50,15 @@ JSM.ConvertBodyToTriangleBody = function (body) } normal = JSM.CalculateBodyPolygonNormal (body, i); - triangles = JSM.PolygonTriangulate (polygon3D, normal); - for (j = 0; j < triangles.length; j++) { - triangle = triangles[j]; - v0 = polygon.GetVertexIndex (triangle[0]); - v1 = polygon.GetVertexIndex (triangle[1]); - v2 = polygon.GetVertexIndex (triangle[2]); - AddTriangle (result, polygon, v0, v1, v2); + triangles = JSM.TriangulatePolygon (polygon3D, normal); + if (triangles !== null) { + for (j = 0; j < triangles.length; j++) { + triangle = triangles[j]; + v0 = polygon.GetVertexIndex (triangle[0]); + v1 = polygon.GetVertexIndex (triangle[1]); + v2 = polygon.GetVertexIndex (triangle[2]); + AddTriangle (result, polygon, v0, v1, v2); + } } } } diff --git a/src/modeler/explode.js b/src/modeler/explode.js index 3ca494de..6b9e82d5 100644 --- a/src/modeler/explode.js +++ b/src/modeler/explode.js @@ -65,7 +65,7 @@ JSM.ExplodeBodyToTriangles = function (body, materials, explodeData) } var normal = JSM.CalculateBodyPolygonNormal (body, index); - var triangles = JSM.PolygonTriangulate (polygon3D, normal); + var triangles = JSM.TriangulatePolygon (polygon3D, normal); if (triangles !== null) { var triangle; for (i = 0; i < triangles.length; i++) { diff --git a/src/modeler/exporter.js b/src/modeler/exporter.js index 77ebf108..1bbaeb1a 100644 --- a/src/modeler/exporter.js +++ b/src/modeler/exporter.js @@ -59,15 +59,16 @@ JSM.ExportBodyContentToStl = function (body, name, hasConvexPolygons) polygon3D.AddVertex (vertex.position.x, vertex.position.y, vertex.position.z); } - var triangles = JSM.PolygonTriangulate (polygon3D, normal); - - var triangle; - for (i = 0; i < triangles.length; i++) { - triangle = triangles[i]; - vertex1 = body.GetVertex (polygon.GetVertexIndex (triangle[0])).position; - vertex2 = body.GetVertex (polygon.GetVertexIndex (triangle[1])).position; - vertex3 = body.GetVertex (polygon.GetVertexIndex (triangle[2])).position; - AddTriangleToContent (normal, vertex1, vertex2, vertex3); + var triangles = JSM.TriangulatePolygon (polygon3D, normal); + if (triangles !== null) { + var triangle; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + vertex1 = body.GetVertex (polygon.GetVertexIndex (triangle[0])).position; + vertex2 = body.GetVertex (polygon.GetVertexIndex (triangle[1])).position; + vertex3 = body.GetVertex (polygon.GetVertexIndex (triangle[2])).position; + AddTriangleToContent (normal, vertex1, vertex2, vertex3); + } } } else { for (i = 0; i < count - 2; i++) { diff --git a/src/modeler/generator.js b/src/modeler/generator.js index c0122607..93504f54 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -954,19 +954,20 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd vertex = basePolygon[polygonIndices[i]]; polygon.AddVertex (vertex.x, vertex.y, vertex.z); } - var triangles = JSM.PolygonTriangulate (polygon); - - var triangle, topTriangle, bottomTriangle; - for (i = 0; i < triangles.length; i++) { - triangle = triangles[i]; - topTriangle = new JSM.BodyPolygon ([]); - bottomTriangle = new JSM.BodyPolygon ([]); - for (j = 0; j < 3; j++) { - topTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[j]]] + 1); - bottomTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[3 - j - 1]]]); + var triangles = JSM.TriangulatePolygon (polygon); + if (triangles !== null) { + var triangle, topTriangle, bottomTriangle; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + topTriangle = new JSM.BodyPolygon ([]); + bottomTriangle = new JSM.BodyPolygon ([]); + for (j = 0; j < 3; j++) { + topTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[j]]] + 1); + bottomTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[3 - j - 1]]]); + } + result.AddPolygon (topTriangle); + result.AddPolygon (bottomTriangle); } - result.AddPolygon (topTriangle); - result.AddPolygon (bottomTriangle); } } diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index 495c7641..2b814040 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -23,6 +23,7 @@ unitTest.AddSourceFile ('../../src/geometry/plane.js'); unitTest.AddSourceFile ('../../src/geometry/projection.js'); unitTest.AddSourceFile ('../../src/geometry/convexhull.js'); unitTest.AddSourceFile ('../../src/geometry/polygon2d.js'); +unitTest.AddSourceFile ('../../src/geometry/polygon.js'); unitTest.AddSourceFile ('../../src/geometry/triangulation.js'); unitTest.AddSourceFile ('../../src/geometry/oldpolygon.js'); unitTest.AddSourceFile ('../../src/geometry/oldpolygonutils.js'); diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index fef723d4..dbf6ab3b 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -1546,68 +1546,9 @@ generalSuite.AddTest ('TriangleOctreeTest', function (test) var polygonSuite = unitTest.AddTestSuite ('GeometryPolygon'); -polygonSuite.AddTest ('ContourPolygon2DTest', function (test) -{ - var polygon = new JSM.OldContourPolygon2D (); - test.Assert (polygon.ContourCount () == 0); - test.Assert (polygon.VertexCount (0) == 0); - test.Assert (polygon.VertexCount (1) == 0); - test.Assert (polygon.VertexCount (2) == 0); - - polygon.AddVertex (0, 0, 0); - polygon.AddVertex (0, 1, 0); - polygon.AddVertex (0, 1, 1); - test.Assert (polygon.ContourCount () == 1); - test.Assert (polygon.VertexCount (0) == 3); - test.Assert (polygon.VertexCount (1) == 0); - test.Assert (polygon.VertexCount (2) == 0); - - polygon.AddVertex (1, 0, 0); - polygon.AddVertex (1, 2, 0); - polygon.AddVertex (1, 2, 2); - test.Assert (polygon.ContourCount () == 2); - test.Assert (polygon.VertexCount (0) == 3); - test.Assert (polygon.VertexCount (1) == 3); - test.Assert (polygon.VertexCount (2) == 0); - - polygon.AddContour (); - test.Assert (polygon.ContourCount () == 3); - polygon.AddVertex (2, 0, 0); - polygon.AddVertex (2, 3, 0); - polygon.AddVertex (2, 3, 3); - test.Assert (polygon.ContourCount () == 3); - test.Assert (polygon.VertexCount (0) == 3); - test.Assert (polygon.VertexCount (1) == 3); - test.Assert (polygon.VertexCount (2) == 3); - - test.Assert (polygon.GetVertex (0, 1).IsEqual (new JSM.Coord2D (1, 0))); - test.Assert (polygon.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); - test.Assert (polygon.GetVertex (2, 1).IsEqual (new JSM.Coord2D (3, 0))); - - var cloned = polygon.Clone (); - test.Assert (cloned.ContourCount () == 3); - test.Assert (cloned.VertexCount (0) == 3); - test.Assert (cloned.VertexCount (1) == 3); - test.Assert (cloned.VertexCount (2) == 3); - - test.Assert (cloned.GetVertex (0, 1).IsEqual (new JSM.Coord2D (1, 0))); - test.Assert (cloned.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); - test.Assert (cloned.GetVertex (2, 1).IsEqual (new JSM.Coord2D (3, 0))); - - cloned.SetVertex (1, 1, 5, 6); - test.Assert (polygon.GetVertex (1, 1).IsEqual (new JSM.Coord2D (2, 0))); - test.Assert (cloned.GetVertex (1, 1).IsEqual (new JSM.Coord2D (5, 6))); - - polygon.Clear (); - test.Assert (polygon.ContourCount () == 0); - test.Assert (polygon.VertexCount (0) == 0); - test.Assert (polygon.VertexCount (1) == 0); - test.Assert (polygon.VertexCount (2) == 0); -}); - polygonSuite.AddTest ('CoordPolygonPosition2DTest', function (test) { - var polygon = new JSM.OldPolygon2D (); + var polygon = new JSM.Polygon2D (); polygon.AddVertex (0.0, 2.0); polygon.AddVertex (0.0, 1.0); polygon.AddVertex (1.0, 1.0); @@ -1618,30 +1559,30 @@ polygonSuite.AddTest ('CoordPolygonPosition2DTest', function (test) polygon.AddVertex (3.0, 2.0); polygon.AddVertex (1.5, 3.0); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 0.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.5, 5.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 3.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.0, 4.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (3.0, 0.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (2.5, 0.5), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (4.0, 2.0), polygon) == 'CoordOutsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (-1.0, 1.0), polygon) == 'CoordOutsideOfPolygon'); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 1.5), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.5, 1.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.0, 0.5), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 0.0), polygon) == 'CoordOnPolygonEdge'); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 2.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.0, 1.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.0, 1.0), polygon) == 'CoordOnPolygonEdge'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (3.0, 2.0), polygon) == 'CoordOnPolygonEdge'); - - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (0.5, 1.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 0.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 1.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (2.5, 1.5), polygon) == 'CoordInsideOfPolygon'); - test.Assert (JSM.CoordPolygonPosition2D (new JSM.Coord2D (1.5, 1.0), polygon) == 'CoordInsideOfPolygon'); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 5.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 3.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 4.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 0.5)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 2.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)) == JSM.CoordPolygonPosition.Outside); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.5)) == JSM.CoordPolygonPosition.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.0)) == JSM.CoordPolygonPosition.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.5)) == JSM.CoordPolygonPosition.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.0)) == JSM.CoordPolygonPosition.OnEdge); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.0)) == JSM.CoordPolygonPosition.Inside); }); polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) @@ -1658,14 +1599,14 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) { var result = []; for (var i = 0; i < polygon.VertexCount (); i++) { - if (JSM.IsPolygonVertexVisible2D (polygon, from, i)) { + if (polygon.IsDiagonal (from, i)) { result.push (i); } } return result; } - var polygon = new JSM.OldPolygon2D (); + var polygon = new JSM.Polygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (3.0, 0.0); polygon.AddVertex (3.0, 2.0); @@ -1684,26 +1625,26 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (GetVisibleVertices (polygon, 6).toString () == [0].toString ()); test.Assert (GetVisibleVertices (polygon, 7).toString () == [5].toString ()); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0, 0, 1, 1), 0, 5) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0, 0, 1, 1), 0, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0, 0, 1, 1), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0, 0, 0.5, 0.5), 0, -1) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0, 0, 0.5, 0.5), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.3, 0.3, 0.8, 0.8), -1, -1) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.3, 0.3, 1, 1), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.3, 0.3, 1.5, 1.5), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.5, 1.5, 0.8, 1.5), -1, -1) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.5, 1.5, 1, 1.5), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.5, 1.5, 1, 2), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (0.5, 1.5, 1, 2.5), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1.1, 1.5, 1.9, 1.5), -1, -1) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 1.9, 1.5), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 1.9, 1.5), 6, -1) == false); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 2, 2), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 2, 2), 6, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon, GetSector (1, 2, 2, 2), 6, 3) == false); - - var polygon2 = new JSM.OldPolygon2D (); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 5) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 0.8, 0.8), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1.5, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 0.8, 1.5), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (1.1, 1.5, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), 6, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, 3) == JSM.SectorPolygonPosition.NoIntersection); + + var polygon2 = new JSM.Polygon2D (); polygon2.AddVertex (118, 121); polygon2.AddVertex (244, 89); polygon2.AddVertex (188, 222); @@ -1714,9 +1655,9 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) polygon2.AddVertex (170, 189); polygon2.AddVertex (192, 118); - test.Assert (JSM.IsPolygonVertexVisible2D (polygon2, 1, 4) == false); + test.Assert (polygon2.IsDiagonal (1, 4) == false); - var polygon3 = new JSM.OldPolygon2D (); + var polygon3 = new JSM.Polygon2D (); polygon3.AddVertex (1, 0); polygon3.AddVertex (2, 0); polygon3.AddVertex (2, 1); @@ -1742,14 +1683,14 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (GetVisibleVertices (polygon3, 10).toString () == [4, 5, 8].toString ()); test.Assert (GetVisibleVertices (polygon3, 11).toString () == [1, 2, 4, 5, 6, 8, 9].toString ()); - var polygon4 = new JSM.OldPolygon2D (); + var polygon4 = new JSM.Polygon2D (); polygon4.AddVertex (0, 0); polygon4.AddVertex (3, 0); polygon4.AddVertex (3, 3); polygon4.AddVertex (0, 3); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon4, GetSector (0, 0, 1, 1), -1, -1) == true); - test.Assert (JSM.SectorIntersectsPolygon2D (polygon4, GetSector (0, 0, 1, 1), 0, -1) == false); + test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); + test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition.NoIntersection); }); polygonSuite.AddTest ('PolygonTriangulationTest', function (test) @@ -1761,7 +1702,7 @@ polygonSuite.AddTest ('PolygonTriangulationTest', function (test) polygon.AddVertex (1.5, 3.0, 0.0); polygon.AddVertex (0.0, 2.0, 0.0); - var triangles = JSM.PolygonTriangulate (polygon); + var triangles = JSM.TriangulatePolygon (polygon); test.Assert (triangles.length == 3); test.Assert (triangles[0].toString () == [0, 1, 2].toString ()); test.Assert (triangles[1].toString () == [0, 2, 3].toString ()); diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index a0c7cb43..79946c58 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -386,26 +386,26 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (0.0, 2.0); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)), JSM.CoordPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 0.0)), JSM.CoordPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)), JSM.CoordPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)), JSM.CoordPosition.OnVertex); - - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.0)), JSM.CoordPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 2.0)), JSM.CoordPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPosition.OnEdge); - - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)), JSM.CoordPosition.Inside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 1.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)), JSM.CoordPolygonPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 0.0)), JSM.CoordPolygonPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)), JSM.CoordPolygonPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)), JSM.CoordPolygonPosition.OnVertex); + + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.0)), JSM.CoordPolygonPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 2.0)), JSM.CoordPolygonPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition.OnEdge); + + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)), JSM.CoordPolygonPosition.Inside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 1.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)), JSM.CoordPolygonPosition.Outside); var polygon2 = new JSM.Polygon2D (); polygon2.AddVertex (0.0, 0.0); @@ -413,13 +413,13 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon2.AddVertex (0.0, 2.0); polygon2.AddVertex (-1.0, 1.0); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPosition.Inside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 0.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.CoordPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 2.0)), JSM.CoordPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition.Inside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 0.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 2.0)), JSM.CoordPolygonPosition.Outside); }); var diagonalSuite = unitTest.AddTestSuite ('IsDiagonalSuite'); @@ -918,53 +918,69 @@ var polygonSectorTest = unitTest.AddTestSuite ('PolygonSectorPositionTest'); polygonSectorTest.AddTest ('PolygonSectorPositionTest01', function (test) { + function GetSector (x1, y1, x2, y2) + { + var beg = new JSM.Coord2D (x1, y1); + var end = new JSM.Coord2D (x2, y2); + var sector = new JSM.Sector2D (beg, end); + return sector; + } + var polygon = new JSM.Polygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); polygon.AddVertex (1.0, 1.0); polygon.AddVertex (0.0, 1.0); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (3, 0), -1, -1), JSM.SectorPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (2, 1), -1, -1), JSM.SectorPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 3, 0), -1, -1), JSM.SectorPolygonPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 2, 1), -1, -1), JSM.SectorPolygonPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (2, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 2, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (2, 2), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 2), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 2, 2), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 2, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (2, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (2, 0.5), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 2, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0.5, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (-1.0, 0.5), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (-1.0, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (-1.0, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1), new JSM.Coord2D (-1.0, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); }); polygonSectorTest.AddTest ('PolygonSectorPositionTest02', function (test) { + function GetSector (x1, y1, x2, y2) + { + var beg = new JSM.Coord2D (x1, y1); + var end = new JSM.Coord2D (x2, y2); + var sector = new JSM.Sector2D (beg, end); + return sector; + } + var polygon = new JSM.Polygon2D (); polygon.AddVertex (0.0, 0.0); polygon.AddVertex (1.0, 0.0); polygon.AddVertex (1.0, 1.0); polygon.AddVertex (0.0, 1.0); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0.5), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (0.5, 0.5), 0, -1), JSM.SectorPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0.5, 0.5), new JSM.Coord2D (0, 0), 0, -1), JSM.SectorPosition.NoIntersection); - - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), -1, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, -1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, 1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, 1), JSM.SectorPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (0, 0), new JSM.Coord2D (1, 1), 0, 2), JSM.SectorPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (new JSM.Coord2D (1, 1), new JSM.Coord2D (0, 0), 0, 2), JSM.SectorPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1), JSM.SectorPolygonPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), 0, -1), JSM.SectorPolygonPosition.NoIntersection); + + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 2), JSM.SectorPolygonPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 2), JSM.SectorPolygonPosition.NoIntersection); }); var polygonSuite = unitTest.AddTestSuite ('ContourPolygonTest'); diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index 3b86091d..4fe3e15d 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -234,21 +234,21 @@ simplePolygonSuite.AddTest ('OldTriangulationTest02', function (test) test.Assert (JSM.IsEqual (polygon.GetSignedArea (), 8.0)); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordPosition.OnVertex); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, -1.0)) == JSM.CoordPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 4.0)) == JSM.CoordPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.5)) == JSM.CoordPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 1.5)) == JSM.CoordPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPosition.Outside); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 2.5)) == JSM.CoordPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordPolygonPosition.OnVertex); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, -1.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 4.0)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.5)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 1.5)) == JSM.CoordPolygonPosition.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition.Outside); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 2.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition.Inside); var triangles = JSM.TriangulatePolygon2D (polygon); test.Assert (CheckCalculatedTriangulation (polygon, triangles)); diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index 024fa997..b9d2946d 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 1e6ba3f6..1dc875e4 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index 8baab746..cf66ff26 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index 591c1330..b11e7503 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index 14286652..8bb60174 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index adff42fd..053aba75 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -31,6 +31,7 @@ + diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index 50c41909..2d8a4d9b 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -31,6 +31,7 @@ + diff --git a/tools/files.txt b/tools/files.txt index 95691ef6..50a1f7fb 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -19,6 +19,7 @@ ../src/geometry/projection.js ../src/geometry/convexhull.js ../src/geometry/polygon2d.js +../src/geometry/polygon.js ../src/geometry/triangulation.js ../src/geometry/oldpolygon.js ../src/geometry/oldpolygonutils.js From c8a0778debf6d7f0abcf0d96c9583368a6ab45f0 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 20 Jul 2015 18:04:31 +0200 Subject: [PATCH 15/27] Add PolygonEditor from JSPolygon. --- build/jsmodeler.js | 1 - documentation/demo/include/shapegenerators.js | 34 +++ documentation/jsmdoc/include/jsmdoc.json | 24 -- sandbox/triangulation/polygoneditor.css | 56 +++++ sandbox/triangulation/polygoneditor.html | 231 ++++++++++++++++++ sandbox/triangulation/polygoneditor.js | 220 +++++++++++++++++ src/geometry/oldpolygonutils.js | 56 ----- test/unittest/tests/polygon.js | 16 ++ test/unittest/tests/triangulation.js | 2 +- 9 files changed, 558 insertions(+), 82 deletions(-) create mode 100644 sandbox/triangulation/polygoneditor.css create mode 100644 sandbox/triangulation/polygoneditor.html create mode 100644 sandbox/triangulation/polygoneditor.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 31d7aefc..8b1843f4 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -113,7 +113,6 @@ c(a,e,b.beg);a.polygon.EnumerateVertices(f,p,function(b){c(a,e,b)});return{resul JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)};JSM.OldContourPolygon2D=function(){this.polygons=[]}; JSM.OldContourPolygon2D.prototype.AddVertex=function(a,b,c){void 0===this.polygons[a]&&(this.polygons[a]=new JSM.Polygon2D);this.polygons[a].AddVertex(b,c)};JSM.OldContourPolygon2D.prototype.VertexCount=function(a){return void 0===this.polygons[a]?0:this.polygons[a].VertexCount()};JSM.OldContourPolygon2D.prototype.GetVertex=function(a,b){return this.polygons[a].GetVertex(b)};JSM.OldContourPolygon2D.prototype.SetVertex=function(a,b,c,d){this.polygons[a].SetVertex(b,c,d)}; JSM.OldContourPolygon2D.prototype.AddContour=function(){this.polygons.push(new JSM.Polygon2D)};JSM.OldContourPolygon2D.prototype.ContourCount=function(){return this.polygons.length};JSM.OldContourPolygon2D.prototype.GetContour=function(a){return this.polygons[a]};JSM.OldContourPolygon2D.prototype.Clear=function(){this.polygons=[]};JSM.OldContourPolygon2D.prototype.Clone=function(){var a=new JSM.OldContourPolygon2D,b;for(b=0;b= 0; i--) { + oldVertex = oldPolygon.GetVertex (i); + polygon.AddVertex (oldVertex.x, oldVertex.y); + } +}; + +JSM.CreateCCWPolygonFromVertices = function (vertices) +{ + var polygon = JSM.CreatePolygonFromVertices (vertices); + if (polygon.GetOrientation () != JSM.Orientation.CounterClockwise) { + JSM.ChangePolygonOrientation2D (polygon); + } + return polygon; +}; + JSM.ShapeGenerator = function () { this.parameters = null; diff --git a/documentation/jsmdoc/include/jsmdoc.json b/documentation/jsmdoc/include/jsmdoc.json index 745f436c..92ae4446 100644 --- a/documentation/jsmdoc/include/jsmdoc.json +++ b/documentation/jsmdoc/include/jsmdoc.json @@ -942,30 +942,6 @@ ["integer[3][*]", "the result"] ] }, - "CreatePolygonFromVertices" : { - "description" : "Creates a cloned polygon from the given vertices.", - "parameters" : [ - ["vertices", "Coord2D[*]", "the vertices"] - ], - "returns" : [ - ["Polygon2D", "the result"] - ] - }, - "ChangePolygonOrientation2D" : { - "description" : "Reverses the orientation of a polygon.", - "parameters" : [ - ["polygon", "Polygon2D", "the polygon"] - ] - }, - "CreateCCWPolygonFromVertices" : { - "description" : "Creates a cloned polygon from the given vertices with couter clockwise orientation.", - "parameters" : [ - ["vertices", "Coord2D[*]", "the vertices"] - ], - "returns" : [ - ["Polygon2D", "the result"] - ] - }, "CreatePolygonWithHole2D" : { "description" : "Creates a simple polygon from multiple contours by creating in-out edges between contours. The input array should contain null values at contour ends.", "parameters" : [ diff --git a/sandbox/triangulation/polygoneditor.css b/sandbox/triangulation/polygoneditor.css new file mode 100644 index 00000000..b8b12d12 --- /dev/null +++ b/sandbox/triangulation/polygoneditor.css @@ -0,0 +1,56 @@ +html, body +{ + color : #000000; + background : #f8f8f8; + font-size : 12px; + font-family : Arial, cursive; + margin : 0px; + padding : 0px; + width : 100%; + height : 100%; +} + +div.frame +{ + width : 802px; + padding : 20px; + margin : 0px auto; +} + +div.buttons +{ + color : #333333; + background : transparent; + margin : 5px 0px; + overflow : auto; +} + +div.info +{ + color : #333333; + background : transparent; +} + +div.button +{ + cursor : pointer; + padding : 5px 10px; + margin-right : 5px; + border : 1px solid #cccccc; + border-radius : 5px; + float : left; +} + +pre.test +{ + color : #666666; + background : transparent; + margin : 5px 0px; +} + +canvas +{ + color : #000000; + background : #ffffff; + border : 1px solid #cccccc; +} diff --git a/sandbox/triangulation/polygoneditor.html b/sandbox/triangulation/polygoneditor.html new file mode 100644 index 00000000..314384ae --- /dev/null +++ b/sandbox/triangulation/polygoneditor.html @@ -0,0 +1,231 @@ + + + + + + ContourPolygon2D Editor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+

+	
+ + + diff --git a/sandbox/triangulation/polygoneditor.js b/sandbox/triangulation/polygoneditor.js new file mode 100644 index 00000000..2ed67520 --- /dev/null +++ b/sandbox/triangulation/polygoneditor.js @@ -0,0 +1,220 @@ +function DrawSimplePolygon (context, polygon, fillStyle, extraLineEnd, alpha) +{ + context.beginPath (); + context.fillStyle = fillStyle; + context.strokeStyle = '#222222'; + context.globalAlpha = 1.0; + if (alpha !== undefined && alpha !== null) { + context.globalAlpha = alpha; + } + + var vertexIndex, vertex; + for (vertexIndex = 0; vertexIndex < polygon.VertexCount (); vertexIndex++) { + vertex = polygon.GetVertex (vertexIndex); + if (vertexIndex === 0) { + context.moveTo (vertex.x, vertex.y); + } else { + context.lineTo (vertex.x, vertex.y); + } + } + + if (extraLineEnd !== undefined && extraLineEnd !== null) { + context.lineTo (extraLineEnd.x, extraLineEnd.y); + } + + context.closePath (); + context.fill (); + context.stroke (); + + var coordToText = {}; + var canvasCoord; + var showVertexIndices = true; + if (showVertexIndices) { + for (vertexIndex = 0; vertexIndex < polygon.VertexCount (); vertexIndex++) { + vertex = polygon.GetVertex (vertexIndex); + canvasCoord = { + x : parseInt (vertex.x), + y : parseInt (vertex.y) + }; + if (coordToText[canvasCoord.x] === undefined) { + coordToText[canvasCoord.x] = {}; + } + if (coordToText[canvasCoord.x][canvasCoord.y] === undefined) { + coordToText[canvasCoord.x][canvasCoord.y] = vertexIndex; + } else { + coordToText[canvasCoord.x][canvasCoord.y] += ', ' + vertexIndex; + } + } + + var xCoord, yCoord; + context.beginPath (); + context.fillStyle = '#cc0000'; + for (xCoord in coordToText) { + for (yCoord in coordToText[xCoord]) { + context.fillText (coordToText[xCoord][yCoord], xCoord, yCoord); + } + } + context.closePath (); + context.fill (); + } + + context.globalAlpha = 1.0; +} + +function DrawPolygon (context, polygon, extraLineEnd, alpha) +{ + var contourIndex, contour, fillStyle, myExtraLineEnd; + for (contourIndex = 0; contourIndex < polygon.ContourCount (); contourIndex++) { + contour = polygon.GetContour (contourIndex); + fillStyle = (contourIndex === 0 ? '#dedecd' : '#ffffff'); + myExtraLineEnd = null; + if (extraLineEnd !== null && contourIndex == polygon.ContourCount () - 1) { + myExtraLineEnd = extraLineEnd; + } + DrawSimplePolygon (context, contour, fillStyle, myExtraLineEnd, alpha); + } +} + +function DrawLine (context, from, to) +{ + context.beginPath (); + context.fillStyle = '#0000aa'; + context.strokeStyle = '#0000aa'; + context.arc (from.x, from.y, 2, 0, 2 * Math.PI, false); + context.arc (to.x, to.y, 2, 0, 2 * Math.PI, false); + context.closePath (); + context.fill (); + + context.beginPath (); + context.fillStyle = '#0000aa'; + context.strokeStyle = '#0000aa'; + context.moveTo (from.x, from.y); + context.lineTo (to.x, to.y); + context.closePath (); + context.fill (); + context.stroke (); +} + +PolygonEditor = function () +{ + this.canvas = null; + this.context = null; + this.polygon = null; + this.prevCoord = null; + this.mouseCoord = null; + this.editing = null; +}; + +PolygonEditor.prototype.Init = function (canvas) +{ + function AddVertex (x, y) + { + polygon.AddVertex (100 + x * 10, 200 + y * 10); + } + + this.canvas = canvas; + this.context = this.canvas.getContext ('2d'); + this.context.translate (0.5, 0.5); + + this.polygon = new JSM.ContourPolygon2D (); + + this.prevCoord = { x : -1, y : -1 }; + this.mouseCoord = { x : -1, y : -1 }; + this.editing = false; + + this.canvas.addEventListener ('click', this.MouseClick.bind (this)); + this.canvas.addEventListener ('mousemove', this.MouseMove.bind (this)); + + this.Draw (); +}; + +PolygonEditor.prototype.GetPolygon = function () +{ + return this.polygon; +}; + +PolygonEditor.prototype.ConvertToSimplePolygon = function () +{ + var simple = JSM.ConvertContourPolygonToPolygon2D (this.polygon); + if (simple === null) { + return; + } + this.polygon.Clear (); + this.polygon.AddContour (); + var i; + for (i = 0; i < simple.VertexCount (); i++) { + this.polygon.AddVertexCoord (simple.GetVertex (i)); + } + this.Draw (); +}; + +PolygonEditor.prototype.GenerateRandomPolygon = function () +{ + var simple = null; + while (simple === null) { + simple = GenerateRandomSimplePolygon (); + } + this.polygon.Clear (); + this.polygon.AddContour (simple); + this.Draw (); +}; + +PolygonEditor.prototype.Clear = function () +{ + this.polygon.Clear (); + this.prevCoord = { x : -1, y : -1 }; + this.editing = false; + this.Draw (); +}; + +PolygonEditor.prototype.MouseClick = function (event) +{ + if (!this.editing) { + this.editing = true; + this.polygon.AddContour (); + } + if (this.prevCoord.x == this.mouseCoord.x && this.prevCoord.y == this.mouseCoord.y) { + this.editing = false; + } else { + this.editing = true; + this.polygon.AddVertex (this.mouseCoord.x, this.mouseCoord.y); + this.prevCoord = { x : this.mouseCoord.x, y : this.mouseCoord.y }; + } + + this.Draw (); +}; + +PolygonEditor.prototype.MouseMove = function (event) +{ + this.mouseCoord = { + x : event.clientX - this.canvas.offsetLeft, + y : event.clientY - this.canvas.offsetTop + }; + if (this.editing) { + this.Draw (); + } +}; + +PolygonEditor.prototype.Draw = function () +{ + this.context.clearRect (0, 0, this.canvas.width, this.canvas.height); + + var extraLineEnd = null; + if (this.editing) { + extraLineEnd = this.mouseCoord; + } + DrawPolygon (this.context, this.polygon, extraLineEnd); +}; + +PolygonEditor.prototype.DrawAdditionalTriangle = function (v0, v1, v2) +{ + this.context.beginPath (); + this.context.fillStyle = 'rgba(0, 0, 0, 0.2)'; + this.context.strokeStyle = '#222222'; + this.context.moveTo (v0.x, v0.y); + this.context.lineTo (v1.x, v1.y); + this.context.lineTo (v2.x, v2.y); + this.context.closePath (); + this.context.fill (); + this.context.stroke (); +}; diff --git a/src/geometry/oldpolygonutils.js b/src/geometry/oldpolygonutils.js index 24ceb1be..d9e88eca 100644 --- a/src/geometry/oldpolygonutils.js +++ b/src/geometry/oldpolygonutils.js @@ -1,59 +1,3 @@ -/** -* Function: CreatePolygonFromVertices -* Description: Creates a cloned polygon from the given vertices. -* Parameters: -* vertices {Coord2D[*]} the vertices -* Returns: -* {Polygon2D} the result -*/ -JSM.CreatePolygonFromVertices = function (vertices) -{ - var polygon = new JSM.Polygon2D (); - - var i, current; - for (i = 0; i < vertices.length; i++) { - current = vertices[i]; - polygon.AddVertex (current.x, current.y); - } - - return polygon; -}; - -/** -* Function: ChangePolygonOrientation2D -* Description: Reverses the orientation of a polygon. -* Parameters: -* polygon {Polygon2D} the polygon -*/ -JSM.ChangePolygonOrientation2D = function (polygon) -{ - var oldPolygon = polygon.Clone (); - polygon.Clear (); - - var i, oldVertex; - for (i = oldPolygon.VertexCount () - 1; i >= 0; i--) { - oldVertex = oldPolygon.GetVertex (i); - polygon.AddVertex (oldVertex.x, oldVertex.y); - } -}; - -/** -* Function: CreateCCWPolygonFromVertices -* Description: Creates a cloned polygon from the given vertices with couter clockwise orientation. -* Parameters: -* vertices {Coord2D[*]} the vertices -* Returns: -* {Polygon2D} the result -*/ -JSM.CreateCCWPolygonFromVertices = function (vertices) -{ - var polygon = JSM.CreatePolygonFromVertices (vertices); - if (polygon.GetOrientation () != JSM.Orientation.CounterClockwise) { - JSM.ChangePolygonOrientation2D (polygon); - } - return polygon; -}; - /** * Function: CreatePolygonWithHole2D * Description: diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index 79946c58..345f85b6 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -376,6 +376,22 @@ simpleSuite.AddTest ('JsonTest', function (test) test.AssertEqual (polygon.GetComplexity (), polygon2.GetComplexity ()); }); +simpleSuite.AddTest ('ChangeOrientation', function (test) +{ + var polygon = new JSM.Polygon2D (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (1.0, 0.0); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (0.0, 1.0); + + var polygon2 = new JSM.Polygon2D (); + polygon2.FromJson (polygon.ToJson ()); + + test.AssertEqualNum (polygon.GetArea (), polygon2.GetArea (), JSM.Eps); + test.AssertEqual (polygon.GetOrientation (), polygon2.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), polygon2.GetComplexity ()); +}); + var pointInPolygonSuite = unitTest.AddTestSuite ('PointInPolygonTest'); pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index 4fe3e15d..bba1c209 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -71,7 +71,7 @@ function CheckCalculatedTriangulation (polygon, triangles) return true; } -function CheckSimpleTriangulation (polygon, triangles) +function CheckSimpleTriangulation (polygon) { var triangles = JSM.TriangulatePolygon2D (polygon); return CheckCalculatedTriangulation (polygon, triangles); From ca0caddf3c2c37ea009151692a814fa696fa16a0 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 21 Jul 2015 19:51:00 +0200 Subject: [PATCH 16/27] Rename ToJson/FromJson to ToArray/FromArray. --- build/jsmodeler.js | 11 ++-- sandbox/triangulation/polygoneditor.html | 1 - src/core/algorithm.js | 15 ++++++ src/geometry/polygon2d.js | 67 +++++++++++++++++------- test/unittest/tests/polygon.js | 40 +++++++++----- 5 files changed, 96 insertions(+), 38 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 8b1843f4..ddb29682 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,7 +1,7 @@ /* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=37};JSM.RandomNumber=function(a,b){return Math.random()*(b-a)+a};JSM.RandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1)+a)};JSM.SeededRandomInt=function(a,b,c){return Math.floor((9301*c+49297)%233280/233280*(b-a+1)+a)};JSM.ValueOrDefault=function(a,b){return void 0===a||null===a?b:a}; JSM.CopyObjectProperties=function(a,b,c){if(!(void 0===a||null===a||void 0===b||null===b))for(var d in a)if(a.hasOwnProperty(d)&&(c||void 0===b[d]||null===b[d]))b[d]=a[d]};JSM.Assert=function(a,b){if(!a){var c="Assertion failed.";void 0!==b&&null!==b&&(c+=" "+b);alert(c)}};JSM.Timer=function(){this.stop=this.start=0};JSM.Timer.prototype.Start=function(){this.start=(new Date).getTime()};JSM.Timer.prototype.Stop=function(){this.end=(new Date).getTime()}; JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter=function(){this.current=this.frames=this.start=null};JSM.FPSCounter.prototype.Get=function(a){var b=(new Date).getTime();null===this.start&&(this.start=b,this.current=this.frames=0);if(null===a||void 0===a)a=1E3;this.frames+=1;var c=b-this.start;c>=a&&(this.current=1E3*(this.frames/c),this.start=b,this.frames=0);return parseInt(this.current,10)}; -JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;ca.length||void 0===b||null===b)){var c,d;for(c=0;cJSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)n)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qa)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;c=c+this.contours[b].VertexCount();)c+=this.contours[b].VertexCount(),b+=1;return this.GetContourVertex(b,a-c)};JSM.ContourPolygon2D.prototype.VertexCount=function(){var a=0,b;for(b=0;b Date: Wed, 22 Jul 2015 19:04:48 +0200 Subject: [PATCH 17/27] Add AddContourVertex to ContourPolygon2D. --- src/geometry/polygon2d.js | 10 ++++++++++ test/unittest/tests/polygon.js | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js index 66fc6bfe..db47581d 100644 --- a/src/geometry/polygon2d.js +++ b/src/geometry/polygon2d.js @@ -403,6 +403,16 @@ JSM.ContourPolygon2D.prototype.AddVertexCoord = function (coord) this.lastContour.AddVertexCoord (coord); }; +JSM.ContourPolygon2D.prototype.AddContourVertex = function (contourIndex, x, y) +{ + return this.contours[contourIndex].AddVertex (x, y); +}; + +JSM.ContourPolygon2D.prototype.AddContourVertexCoord = function (contourIndex, coord) +{ + return this.contours[contourIndex].AddVertexCoord (coord); +}; + JSM.ContourPolygon2D.prototype.GetVertex = function (index) { var contourIndex = 0; diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index e7c24d07..11e57e90 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -1027,6 +1027,8 @@ polygonSuite.AddTest ('AddVertexTest', function (test) polygon.AddVertex (0.0, 3.0); test.AssertEqual (polygon.ContourCount (), 1); test.AssertEqual (polygon.VertexCount (), 4); + test.AssertEqualNum (polygon.GetArea (), 15.0, JSM.Eps); + test.AssertEqual (polygon.GetVertex (0).x, 0.0); test.AssertEqual (polygon.GetVertex (0).y, 0.0); test.AssertEqual (polygon.GetVertex (1).x, 5.0); @@ -1044,6 +1046,8 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.ContourCount (), 2); test.AssertEqual (polygon.VertexCount (), 8); + test.AssertEqualNum (polygon.GetArea (), 14.0, JSM.Eps); + test.AssertEqual (polygon.GetVertex (0).x, 0.0); test.AssertEqual (polygon.GetVertex (0).y, 0.0); test.AssertEqual (polygon.GetVertex (1).x, 5.0); @@ -1069,6 +1073,7 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.ContourCount (), 3); test.AssertEqual (polygon.VertexCount (), 12); + test.AssertEqualNum (polygon.GetArea (), 13.0, JSM.Eps); test.AssertEqual (polygon.GetVertex (0).x, 0.0); test.AssertEqual (polygon.GetVertex (0).y, 0.0); @@ -1107,6 +1112,12 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.GetVertex (9).IsEqual (polygon.GetContourVertex (2, 1)), true); test.AssertEqual (polygon.GetVertex (10).IsEqual (polygon.GetContourVertex (2, 2)), true); test.AssertEqual (polygon.GetVertex (11).IsEqual (polygon.GetContourVertex (2, 3)), true); + + polygon.AddContourVertex (0, -1.0, 3.0); + polygon.AddContourVertexCoord (0, new JSM.Coord2D (-1.0, 0.0)); + test.AssertEqual (polygon.ContourCount (), 3); + test.AssertEqual (polygon.VertexCount (), 14); + test.AssertEqualNum (polygon.GetArea (), 16.0, JSM.Eps); }); polygonSuite.AddTest ('CloneTest', function (test) From d337494305b41a824e2a4526afaa857393c06cb5 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 25 Jul 2015 10:35:03 +0200 Subject: [PATCH 18/27] Remove GetVertex function from ContourPolygon. --- src/geometry/polygon2d.js | 12 ---- test/unittest/tests/polygon.js | 109 +++++++++++++++------------------ 2 files changed, 48 insertions(+), 73 deletions(-) diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js index db47581d..67b33553 100644 --- a/src/geometry/polygon2d.js +++ b/src/geometry/polygon2d.js @@ -413,18 +413,6 @@ JSM.ContourPolygon2D.prototype.AddContourVertexCoord = function (contourIndex, c return this.contours[contourIndex].AddVertexCoord (coord); }; -JSM.ContourPolygon2D.prototype.GetVertex = function (index) -{ - var contourIndex = 0; - var currentIndex = 0; - while (index >= currentIndex + this.contours[contourIndex].VertexCount ()) { - currentIndex += this.contours[contourIndex].VertexCount (); - contourIndex += 1; - } - var vertexIndex = index - currentIndex; - return this.GetContourVertex (contourIndex, vertexIndex); -}; - JSM.ContourPolygon2D.prototype.VertexCount = function () { var vertexCount = 0; diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index 11e57e90..161272cc 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -1029,14 +1029,14 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.VertexCount (), 4); test.AssertEqualNum (polygon.GetArea (), 15.0, JSM.Eps); - test.AssertEqual (polygon.GetVertex (0).x, 0.0); - test.AssertEqual (polygon.GetVertex (0).y, 0.0); - test.AssertEqual (polygon.GetVertex (1).x, 5.0); - test.AssertEqual (polygon.GetVertex (1).y, 0.0); - test.AssertEqual (polygon.GetVertex (2).x, 5.0); - test.AssertEqual (polygon.GetVertex (2).y, 3.0); - test.AssertEqual (polygon.GetVertex (3).x, 0.0); - test.AssertEqual (polygon.GetVertex (3).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (0, 0).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 0).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).y, 3.0); polygon.AddContour (); polygon.AddVertex (1.0, 1.0); @@ -1048,22 +1048,22 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.VertexCount (), 8); test.AssertEqualNum (polygon.GetArea (), 14.0, JSM.Eps); - test.AssertEqual (polygon.GetVertex (0).x, 0.0); - test.AssertEqual (polygon.GetVertex (0).y, 0.0); - test.AssertEqual (polygon.GetVertex (1).x, 5.0); - test.AssertEqual (polygon.GetVertex (1).y, 0.0); - test.AssertEqual (polygon.GetVertex (2).x, 5.0); - test.AssertEqual (polygon.GetVertex (2).y, 3.0); - test.AssertEqual (polygon.GetVertex (3).x, 0.0); - test.AssertEqual (polygon.GetVertex (3).y, 3.0); - test.AssertEqual (polygon.GetVertex (4).x, 1.0); - test.AssertEqual (polygon.GetVertex (4).y, 1.0); - test.AssertEqual (polygon.GetVertex (5).x, 1.0); - test.AssertEqual (polygon.GetVertex (5).y, 2.0); - test.AssertEqual (polygon.GetVertex (6).x, 2.0); - test.AssertEqual (polygon.GetVertex (6).y, 2.0); - test.AssertEqual (polygon.GetVertex (7).x, 2.0); - test.AssertEqual (polygon.GetVertex (7).y, 1.0); + test.AssertEqual (polygon.GetContourVertex (0, 0).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 0).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (1, 0).x, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 0).y, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 1).x, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 1).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 2).x, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 2).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 3).x, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 3).y, 1.0); polygon.AddContour (); polygon.AddVertexCoord (new JSM.Coord2D (3.0, 1.0)); @@ -1075,43 +1075,30 @@ polygonSuite.AddTest ('AddVertexTest', function (test) test.AssertEqual (polygon.VertexCount (), 12); test.AssertEqualNum (polygon.GetArea (), 13.0, JSM.Eps); - test.AssertEqual (polygon.GetVertex (0).x, 0.0); - test.AssertEqual (polygon.GetVertex (0).y, 0.0); - test.AssertEqual (polygon.GetVertex (1).x, 5.0); - test.AssertEqual (polygon.GetVertex (1).y, 0.0); - test.AssertEqual (polygon.GetVertex (2).x, 5.0); - test.AssertEqual (polygon.GetVertex (2).y, 3.0); - test.AssertEqual (polygon.GetVertex (3).x, 0.0); - test.AssertEqual (polygon.GetVertex (3).y, 3.0); - test.AssertEqual (polygon.GetVertex (4).x, 1.0); - test.AssertEqual (polygon.GetVertex (4).y, 1.0); - test.AssertEqual (polygon.GetVertex (5).x, 1.0); - test.AssertEqual (polygon.GetVertex (5).y, 2.0); - test.AssertEqual (polygon.GetVertex (6).x, 2.0); - test.AssertEqual (polygon.GetVertex (6).y, 2.0); - test.AssertEqual (polygon.GetVertex (7).x, 2.0); - test.AssertEqual (polygon.GetVertex (7).y, 1.0); - test.AssertEqual (polygon.GetVertex (8).x, 3.0); - test.AssertEqual (polygon.GetVertex (8).y, 1.0); - test.AssertEqual (polygon.GetVertex (9).x, 3.0); - test.AssertEqual (polygon.GetVertex (9).y, 2.0); - test.AssertEqual (polygon.GetVertex (10).x, 4.0); - test.AssertEqual (polygon.GetVertex (10).y, 2.0); - test.AssertEqual (polygon.GetVertex (11).x, 4.0); - test.AssertEqual (polygon.GetVertex (11).y, 1.0); - - test.AssertEqual (polygon.GetVertex (0).IsEqual (polygon.GetContourVertex (0, 0)), true); - test.AssertEqual (polygon.GetVertex (1).IsEqual (polygon.GetContourVertex (0, 1)), true); - test.AssertEqual (polygon.GetVertex (2).IsEqual (polygon.GetContourVertex (0, 2)), true); - test.AssertEqual (polygon.GetVertex (3).IsEqual (polygon.GetContourVertex (0, 3)), true); - test.AssertEqual (polygon.GetVertex (4).IsEqual (polygon.GetContourVertex (1, 0)), true); - test.AssertEqual (polygon.GetVertex (5).IsEqual (polygon.GetContourVertex (1, 1)), true); - test.AssertEqual (polygon.GetVertex (6).IsEqual (polygon.GetContourVertex (1, 2)), true); - test.AssertEqual (polygon.GetVertex (7).IsEqual (polygon.GetContourVertex (1, 3)), true); - test.AssertEqual (polygon.GetVertex (8).IsEqual (polygon.GetContourVertex (2, 0)), true); - test.AssertEqual (polygon.GetVertex (9).IsEqual (polygon.GetContourVertex (2, 1)), true); - test.AssertEqual (polygon.GetVertex (10).IsEqual (polygon.GetContourVertex (2, 2)), true); - test.AssertEqual (polygon.GetVertex (11).IsEqual (polygon.GetContourVertex (2, 3)), true); + test.AssertEqual (polygon.GetContourVertex (0, 0).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 0).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 1).y, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).x, 5.0); + test.AssertEqual (polygon.GetContourVertex (0, 2).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).x, 0.0); + test.AssertEqual (polygon.GetContourVertex (0, 3).y, 3.0); + test.AssertEqual (polygon.GetContourVertex (1, 0).x, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 0).y, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 1).x, 1.0); + test.AssertEqual (polygon.GetContourVertex (1, 1).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 2).x, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 2).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 3).x, 2.0); + test.AssertEqual (polygon.GetContourVertex (1, 3).y, 1.0); + test.AssertEqual (polygon.GetContourVertex (2, 0).x, 3.0); + test.AssertEqual (polygon.GetContourVertex (2, 0).y, 1.0); + test.AssertEqual (polygon.GetContourVertex (2, 1).x, 3.0); + test.AssertEqual (polygon.GetContourVertex (2, 1).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (2, 2).x, 4.0); + test.AssertEqual (polygon.GetContourVertex (2, 2).y, 2.0); + test.AssertEqual (polygon.GetContourVertex (2, 3).x, 4.0); + test.AssertEqual (polygon.GetContourVertex (2, 3).y, 1.0); polygon.AddContourVertex (0, -1.0, 3.0); polygon.AddContourVertexCoord (0, new JSM.Coord2D (-1.0, 0.0)); From 759aa04aac4e9967001029752414d70c1a371265 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sat, 25 Jul 2015 10:54:13 +0200 Subject: [PATCH 19/27] Add ContourPolygon class. --- build/jsmodeler.js | 15 ++- documentation/jsmdoc/include/jsmdoc.json | 25 ++++ src/geometry/polygon.js | 157 ++++++++++++++++++++++- test/unittest/tests/polygon.js | 138 +++++++++++++++++++- 4 files changed, 328 insertions(+), 7 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index ddb29682..6834968b 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -92,14 +92,19 @@ g==JSM.SectorSectorPosition2D.SectorsIntersectEndPoint&&(d=JSM.SectorPolygonPosi JSM.Polygon2D.prototype.IsDiagonal=function(a,b){return a==b||(this.GetPrevVertex(a)==b||this.GetNextVertex(a)==b)||this.vertices[a].IsEqual(this.vertices[b])||function(a,b,e){var f=a.GetVertex(b),g=a.GetVertex(e),f=new JSM.Sector2D(f,g);return a.SectorPosition(f,b,e)!=JSM.SectorPolygonPosition.NoIntersection?!0:!1}(this,a,b)||!function(a,b,e){b=a.GetVertex(b);e=a.GetVertex(e);e=new JSM.Coord2D((b.x+e.x)/2,(b.y+e.y)/2);return a.CoordPosition(e)==JSM.CoordPolygonPosition.Inside}(this,a,b)?!1:!0}; JSM.Polygon2D.prototype.GetComplexity=function(){if(null!==this.cache.complexity)return this.cache.complexity;var a=this.vertices.length;if(3>a)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;c=c+this.contours[b].VertexCount();)c+=this.contours[b].VertexCount(),b+=1;return this.GetContourVertex(b,a-c)};JSM.ContourPolygon2D.prototype.VertexCount=function(){var a=0,b;for(b=0;bb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;c Date: Sat, 25 Jul 2015 11:12:40 +0200 Subject: [PATCH 20/27] Add ToContourPolygon2D function. --- build/jsmodeler.js | 9 +-- src/geometry/polygon.js | 18 +++++- src/geometry/polygon2d.js | 2 +- test/unittest/tests/polygon.js | 115 ++++++++++++++++++++++++--------- 4 files changed, 108 insertions(+), 36 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 6834968b..4fc5a5f4 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -91,7 +91,7 @@ JSM.Polygon2D.prototype.SectorPosition=function(a,b,c){var d=JSM.SectorPolygonPo g==JSM.SectorSectorPosition2D.SectorsIntersectEndPoint&&(d=JSM.SectorPolygonPosition.IntersectionOnVertex)}return d}; JSM.Polygon2D.prototype.IsDiagonal=function(a,b){return a==b||(this.GetPrevVertex(a)==b||this.GetNextVertex(a)==b)||this.vertices[a].IsEqual(this.vertices[b])||function(a,b,e){var f=a.GetVertex(b),g=a.GetVertex(e),f=new JSM.Sector2D(f,g);return a.SectorPosition(f,b,e)!=JSM.SectorPolygonPosition.NoIntersection?!0:!1}(this,a,b)||!function(a,b,e){b=a.GetVertex(b);e=a.GetVertex(e);e=new JSM.Coord2D((b.x+e.x)/2,(b.y+e.y)/2);return a.CoordPosition(e)==JSM.CoordPolygonPosition.Inside}(this,a,b)?!1:!0}; JSM.Polygon2D.prototype.GetComplexity=function(){if(null!==this.cache.complexity)return this.cache.complexity;var a=this.vertices.length;if(3>a)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;c Date: Wed, 29 Jul 2015 17:33:29 +0200 Subject: [PATCH 21/27] Add vertex mapping calculation to ConvertContourPolygonToPolygon2D. --- build/jsmodeler.js | 413 ++++++++++++++------------- src/geometry/triangulation.js | 55 +++- src/modeler/generator.js | 71 ++--- test/unittest/tests/triangulation.js | 94 +++++- 4 files changed, 370 insertions(+), 263 deletions(-) diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 4fc5a5f4..81a1ca09 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -1,9 +1,9 @@ /* JSModeler 0.37 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM=function(){this.mainVersion=0;this.subVersion=37};JSM.RandomNumber=function(a,b){return Math.random()*(b-a)+a};JSM.RandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1)+a)};JSM.SeededRandomInt=function(a,b,c){return Math.floor((9301*c+49297)%233280/233280*(b-a+1)+a)};JSM.ValueOrDefault=function(a,b){return void 0===a||null===a?b:a}; JSM.CopyObjectProperties=function(a,b,c){if(!(void 0===a||null===a||void 0===b||null===b))for(var d in a)if(a.hasOwnProperty(d)&&(c||void 0===b[d]||null===b[d]))b[d]=a[d]};JSM.Assert=function(a,b){if(!a){var c="Assertion failed.";void 0!==b&&null!==b&&(c+=" "+b);alert(c)}};JSM.Timer=function(){this.stop=this.start=0};JSM.Timer.prototype.Start=function(){this.start=(new Date).getTime()};JSM.Timer.prototype.Stop=function(){this.end=(new Date).getTime()}; JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter=function(){this.current=this.frames=this.start=null};JSM.FPSCounter.prototype.Get=function(a){var b=(new Date).getTime();null===this.start&&(this.start=b,this.current=this.frames=0);if(null===a||void 0===a)a=1E3;this.frames+=1;var c=b-this.start;c>=a&&(this.current=1E3*(this.frames/c),this.start=b,this.frames=0);return parseInt(this.current,10)}; -JSM.BubbleSort=function(a,b){if(!(2>a.length||void 0===b||null===b)){var c,d;for(c=0;ca.length||void 0===b||null===b)){var c,d;for(c=0;cJSM.Eps};JSM.IsNegative=function(a){return a<-JSM.Eps};JSM.IsLower=function(a,b){return b-a>JSM.Eps};JSM.IsGreater=function(a,b){return a-b>JSM.Eps};JSM.IsEqual=function(a,b){return Math.abs(b-a)a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(g);b=b.DistanceTo(g);g=c.DistanceTo(g);c=h(l,k,m);if(JSM.IsZero(c))return d;l=h(l,a,b);k=h(k,b,g);m=h(m,a,g);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.BarycentricInterpolation=function(a,b,c,d,e,f,h){function g(a,b,c){var d=(a+b+c)/2;a=d*(d-a)*(d-b)*(d-c);return 0>a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=a[1],h=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],s=a[11],t=a[13],v=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*g+d*k+e*p+f*t;r[2]=c*h+d*m+e*q+f*v;r[3]=c*l+d*n+e*s+f*u;return r}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],s=a[12],t=a[13],v=a[14],u=a[15],r=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*r+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=g*r+h*x+l*L+k*N;F[5]=g*w+h*A+l*H+k*O;F[6]=g*y+h*B+l*C+k*J;F[7]=g*z+h*K+l*E+k*I;F[8]=m*r+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=s*r+t*x+v*L+u*N;F[13]=s*w+t*A+v*H+u*O;F[14]=s*y+t*B+v*C+u*J;F[15]=s*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];return(b*g-c*f)*(n*a-p*t)-(b*h-d*f)*(m*a-p*s)+(b*l-e*f)*(m*t-n*s)+(c*h-d*g)*(k*a-p*q)-(c*l-e*g)*(k*t-n*q)+(d*l-e*h)*(k*s-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],s=a[13],t=a[14];a=a[15];var v=b*g-c*f,u=b*h-d*f,r=b*l-e*f,w=c*h-d*g,y=c*l-e*g,z=d*l-e*h,x=k*s-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*s,L=m*a-p*s,H=n*a-p*t,C=v*H-u*L+r*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(g*H-h*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(s*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(h*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*r-q*z-a*u)/C;E[7]=(k*z-n*r+p* -u)/C;E[8]=(f*L-g*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-s*r+a*v)/C;E[11]=(m*r-k*y-p*v)/C;E[12]=(g*A-f*K-h*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(s*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,g=e*e,h=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(g+h)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=g+(f+h)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=h+(f+g)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(g+h)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=g+(f+h)*b;k[6]=e*d*(1- -b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=h+(f+g)*b;k[11]=0;k[12]=(m*(g+h)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+h)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+g)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,g=c+c,h=d+d;a=b*f;var l=b*g,b=b*h,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h,h=[];h[0]=1-(k+d);h[1]=l+e;h[2]=b-g;h[3]=0;h[4]=l-e;h[5]=1-(a+d);h[6]=c+f;h[7]=0;h[8]=b+g;h[9]=c-f;h[10]=1-(a+k);h[11]=0;h[12]=0;h[13]=0;h[14]=0;h[15]=1;return h};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],r=a[11],t=a[13],v=a[14],u=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*k+e*p+f*t;s[2]=c*g+d*m+e*q+f*v;s[3]=c*l+d*n+e*r+f*u;return s}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],r=a[12],t=a[13],v=a[14],u=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*s+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*s+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*s+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ +p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=r*s+t*x+v*L+u*N;F[13]=r*w+t*A+v*H+u*O;F[14]=r*y+t*B+v*C+u*J;F[15]=r*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],r=a[13],t=a[14];a=a[15];return(b*h-c*f)*(n*a-p*t)-(b*g-d*f)*(m*a-p*r)+(b*l-e*f)*(m*t-n*r)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*t-n*q)+(d*l-e*g)*(k*r-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],r=a[13],t=a[14];a=a[15];var v=b*h-c*f,u=b*g-d*f,s=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*r-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*r,L=m*a-p*r,H=n*a-p*t,C=v*H-u*L+s*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(r*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*s-q*z-a*u)/C;E[7]=(k*z-n*s+p* +u)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-r*s+a*v)/C;E[11]=(m*s-k*y-p*v)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(r*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- +b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.ToDirectionVectors=function(){this.e1=JSM.CoordSub(this.e1,this.origo);this.e2=JSM.CoordSub(this.e2,this.origo);this.e3=JSM.CoordSub(this.e3,this.origo);return this};JSM.CoordSystem.prototype.ToAbsoluteCoords=function(){this.e1=JSM.CoordAdd(this.e1,this.origo);this.e2=JSM.CoordAdd(this.e2,this.origo);this.e3=JSM.CoordAdd(this.e3,this.origo);return this}; JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.OldSectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3}; JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,g=this.end.y,h=this.GetLength();if(JSM.IsZero(h))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(g-e))/(h*h);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(g-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: +JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; -JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,g=a.beg.x,h=a.beg.y,l=a.end.x,k=a.end.y,m=(l-g)*(d-h)-(k-h)*(c-g),n=(e-c)*(d-h)-(f-d)*(c-g);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| +JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? -(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;g=(k-h)*(e-c)-(l-g)*(f-d);if(JSM.IsZero(g))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=g;n/= -g;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,g=a.beg,h=a.end,l=e.IsEqual(g)||e.IsEqual(h),k=f.IsEqual(g)||f.IsEqual(h);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, -q=f.y,s=g.x,t=g.y,v=h.x,u=h.y,r=(v-s)*(n-t)-(u-t)*(m-s),w=(p-m)*(n-t)-(q-n)*(m-s),s=(u-t)*(p-m)-(v-s)*(q-n);if(JSM.IsZero(s)){if(JSM.IsZero(r)&&JSM.IsZero(w)){if(c(e,f,g)||c(e,f,h)||c(g,h,e)||c(g,h,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}g=r/s;w/=s;if(JSM.IsLower(g, -0)||JSM.IsGreater(g,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+g*(p-m),b.y=n+g*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,g=d.x,h=d.y,l=(g-e)*(g-e)+(h-f)*(h-f);if(JSM.IsZero(l))return a.Clone();b=((g-e)*(b-e)+(h-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; +(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=h;n/= +h;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, +q=f.y,r=h.x,t=h.y,v=g.x,u=g.y,s=(v-r)*(n-t)-(u-t)*(m-r),w=(p-m)*(n-t)-(q-n)*(m-r),r=(u-t)*(p-m)-(v-r)*(q-n);if(JSM.IsZero(r)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/r;w/=r;if(JSM.IsLower(h, +0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),g=e.x,h=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-g)*(k-g)+(m-h)*(m-h)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-g)*(b-g)+(m-h)*(c-h)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: -JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,g,h;for(g=0;g<=b;g++)h=a.beg.Clone().Offset(d,f),c.push(h),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; +JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: +JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,h,g;for(h=0;h<=b;h++)g=a.beg.Clone().Offset(d,f),c.push(g),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; JSM.CoordLinePosition={CoordOnLine:0,CoordOutsideOfLine:1};JSM.LineLinePosition={LinesDontIntersect:0,LinesIntersectsOnePoint:1,LinesIntersectsCoincident:2};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; JSM.Line2D.prototype.CoordPosition=function(a){var b=this.start,c=this.direction;a=c.x*(a.y-b.y)-c.y*(a.x-b.x);return JSM.IsPositive(a)?JSM.CoordLinePosition2D.CoordAtLineLeft:JSM.IsNegative(a)?JSM.CoordLinePosition2D.CoordAtLineRight:JSM.CoordLinePosition2D.CoordOnLine};JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b}; -JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,g=this.direction,h=f.x,l=f.y,k=f.z,m=f.x+g.x,n=f.y+g.y,p=f.z+g.z,q=(m-h)*(m-h)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=g.Clone().MultiplyScalar(((m-h)*(c-h)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: -JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,g=a.y,h=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-g)*(k-g)+(m-h)*(m-h);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-g)*(c-g)+(m-h)*(d-h))/n);return JSM.CoordAdd(a,b)}; -JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,g=JSM.CoordAdd(f,e),h=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,h),k=[f,g,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),g=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(g*l-n*k)/m;g=(g+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= -JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(h.MultiplyScalar(g),b=JSM.CoordAdd(a,h),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; +JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: +JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-h)*(k-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; +JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,g),k=[f,h,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),h=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= +JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(g.MultiplyScalar(h),b=JSM.CoordAdd(a,g),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b}; JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)};JSM.Box.prototype.IsCoordInside=function(a){return JSM.IsLower(a.x,this.min.x)||JSM.IsLower(a.y,this.min.y)||JSM.IsLower(a.z,this.min.z)||JSM.IsGreater(a.x,this.max.x)||JSM.IsGreater(a.y,this.max.y)||JSM.IsGreater(a.z,this.max.z)?!1:!0};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())}; JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)};JSM.Sphere=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.Set=function(a,b){this.center=a;this.radius=b};JSM.Sphere.prototype.GetCenter=function(){return this.center};JSM.Sphere.prototype.GetRadius=function(){return this.radius}; @@ -67,29 +67,29 @@ JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0=== JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.CoordPlanePosition={CoordOnPlane:0,CoordInFrontOfPlane:1,CoordAtBackOfPlane:2};JSM.LinePlanePosition={LineParallelToPlane:0,LineIntersectsPlane:1};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d}; JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)};JSM.Plane.prototype.CoordSignedDistance=function(a){var b=this.a,c=this.b,d=this.c;return(b*a.x+c*a.y+d*a.z+this.d)/Math.sqrt(b*b+c*c+d*d)};JSM.Plane.prototype.CoordDistance=function(a){a=this.CoordSignedDistance(a);return Math.abs(a)}; -JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,g=this.c,h=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+g*d+h,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; -JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,g=this.a,h=this.b,l=this.c,k=this.d,m=g*(d-(a.start.x+c.x))+h*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((g*d+h*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; -JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,g=this.b,h=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+g*(d-(a.start.y+b.y))+h*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+g*d+h*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; +JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; +JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,l=this.c,k=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; +JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+h*d+g*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; -JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,g=c.a,h=c.b,l=c.c;c=c.d;var k=g*(b-(a.x+d.x))+h*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((g*b+h*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(g*b+h*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; -JSM.Project=function(a,b,c,d,e,f,g,h,l){b=JSM.MatrixView(b,c,d);g=JSM.MatrixPerspective(e,f,g,h);e=new JSM.Coord(0,0,0);h=[];f=[];h[0]=a.x;h[1]=a.y;h[2]=a.z;h[3]=1;f=JSM.MatrixVectorMultiply(g,JSM.MatrixVectorMultiply(b,h));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; +JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((h*b+g*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; +JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qe)return d;var f,g,h,l,k;for(f=0;fe)return d;var f,h,g,l,k;for(f=0;fa)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)};JSM.OldContourPolygon2D=function(){this.polygons=[]}; JSM.OldContourPolygon2D.prototype.AddVertex=function(a,b,c){void 0===this.polygons[a]&&(this.polygons[a]=new JSM.Polygon2D);this.polygons[a].AddVertex(b,c)};JSM.OldContourPolygon2D.prototype.VertexCount=function(a){return void 0===this.polygons[a]?0:this.polygons[a].VertexCount()};JSM.OldContourPolygon2D.prototype.GetVertex=function(a,b){return this.polygons[a].GetVertex(b)};JSM.OldContourPolygon2D.prototype.SetVertex=function(a,b,c,d){this.polygons[a].SetVertex(b,c,d)}; JSM.OldContourPolygon2D.prototype.AddContour=function(){this.polygons.push(new JSM.Polygon2D)};JSM.OldContourPolygon2D.prototype.ContourCount=function(){return this.polygons.length};JSM.OldContourPolygon2D.prototype.GetContour=function(a){return this.polygons[a]};JSM.OldContourPolygon2D.prototype.Clear=function(){this.polygons=[]};JSM.OldContourPolygon2D.prototype.Clone=function(){var a=new JSM.OldContourPolygon2D,b;for(b=0;b=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, b.children[7]):null};JSM.Octree.prototype.SplitNode=function(a){var b=this,c=JSM.CreateOctreeChildNodes(a.box,function(c){return b.CreateNewNode(a,c)});if(null===c)return!1;a.children=c;c=a.coords;a.coords=[];var d,e;for(d=0;db.VertexCount())return!1;var d;if(null===a.polygon){d=b.GetNormal();var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0k;k++)0===k?m=e:1===k?m=f:2===k&&(m=g),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(h=k,l=n);if(-1===h)return d;b=null;0===h?b=new JSM.CoordSystem(c.origo,f,g,new JSM.Coord(0,0,0)):1===h?b=new JSM.CoordSystem(c.origo,e,g,new JSM.Coord(0,0,0)):2===h&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== -b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var g=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,g,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; -JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,g;for(f=0;fk;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var h=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; +JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fe;e++)l.AddVertexIndex(2*c[b[h[e]]]+1),v.AddVertexIndex(2*c[b[h[3-e-1]]]);f.AddPolygon(l);f.AddPolygon(v)}}}var f=new JSM.Body; -(function(){var d;for(d=0;de;e++)q.AddVertexIndex(2*c[b[p[e]]]+1),r.AddVertexIndex(2*c[b[p[3-e-1]]]);f.AddPolygon(q);f.AddPolygon(r)}}}var f=new JSM.Body, +h=new JSM.ContourPolygon;h.FromArray(a);(function(a,b,c,d){var e,f,h,r,t;for(e=0;ew)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var g,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),g=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, -p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,g,n,p);else if(g=!0,void 0!==c&&c&&(g=!1),q=JSM.CalculateBodyPolygonNormal(a,b),g){g=new JSM.Polygon;for(b=0;bw)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, +p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, -c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=g(b,p.v0,c,d,f),p.n1=g(b,p.v1,c,d,f),p.n2=g(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eh))if(3==h)f=g.GetVertexIndex(0),h=g.GetVertexIndex(1),k=g.GetVertexIndex(2),b(c,g,f,h,k);else{l= -new JSM.Polygon;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(g[k]=-1,h[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(g[k]=1,h[k]=c[k],l=!1):g[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==g[k]&&!JSM.IsZero(e[k])?l[k]=(h[k]-f[k])/e[k]:l[k]=-1;g=0;for(k=1;3>k;k++)JSM.IsLower(l[g],l[k])&&(g=k);if(JSM.IsNegative(l[g]))return null; -var m=[0,0,0];for(k=0;3>k;k++)if(g!=k){if(m[k]=f[k]+l[g]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=h[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; +JSM.RayBoxIntersection=function(a,b,c){var d=a.GetOrigin(),e=a.GetDirection(),f=JSM.CoordToArray(d),e=JSM.CoordToArray(e);b=JSM.CoordToArray(b);c=JSM.CoordToArray(c);var h=[0,0,0],g=[0,0,0],l=!0,k;for(k=0;3>k;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; +var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -291,11 +292,11 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,g,h,l,k,m,n,p,q,s,t,v,u,r,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;g=40992;h=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;s=19;t=41472;v=41728;u=41816;r=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ -255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==s?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==g?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==h?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,r,t,v,u,s,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;r=19;t=41472;v=41728;u=41816;s=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==r?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ +", "+d+")",3),n.ambient=V(a,b,p)):b==h?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= W(a,b,p)):b==t?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), -parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],s=[],t;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=h(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=h(a,"mtllib"),n=g(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); -var b,c;for(b=0;bn.length)){var p=[],q=[],r=[],t;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== +n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,g,h,l,k;for(f=0;fc;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= @@ -331,9 +332,9 @@ JSM.ImportFileList.prototype.InitFromURLs=function(a){this.originalList=a;this.d JSM.ImportFileList.prototype.GetInputList=function(){var a=[],b,c,d;for(b=0;br;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rs;s++)u[s].z=n-c;s=JSM.GeneratePrism(u,k,c,!0);l.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;sg;g++)k=0===g?h.pgon1:h.pgon2,-1===k&&(k=0===g?h.pgon2:h.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],g,h,l,k;for(l=0;lh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0this.cameraFarDistanceLimit)return 0;c*=0.1;a||(c*=-1);this.camera.eye.Offset(b,c)};JSM.Navigation.prototype.DrawCallback=function(){void 0!==this.drawCallback&&null!==this.drawCallback&&this.drawCallback()};JSM.Navigation.prototype.ResizeCallback=function(){void 0!==this.resizeCallback&&null!==this.resizeCallback&&this.resizeCallback()}; JSM.Navigation.prototype.OnMouseDown=function(a){a.preventDefault();this.mouse.Down(a,this.canvas)};JSM.Navigation.prototype.OnMouseMove=function(a){a.preventDefault();this.mouse.Move(a,this.canvas);this.mouse.down&&(a=0,1==this.mouse.button?this.cameraEnableOrbit&&(a=0.5,this.Orbit(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()):3==this.mouse.button&&this.cameraEnablePan&&(a=0.001*this.camera.eye.DistanceTo(this.camera.center),this.Pan(this.mouse.diffX*a,this.mouse.diffY*a),this.DrawCallback()))}; @@ -549,7 +550,7 @@ JSM.SoftwareViewer.prototype.GetBoundingSphere=function(){var a=this.GetCenter() JSM.SoftwareViewer.prototype.Draw=function(){var a,b;this.drawer.Clear();for(a=0;a 0) { holeIndex = holeQueue.shift (); - if (AddContour (inputPolygon, resultPolygon, holeIndex, conversionData)) { + if (AddContour (inputPolygon, resultPolygon, holeIndex, vertexMap, conversionData)) { conversionData.addedHoles[holeIndex] = true; } else { + if (conversionData.holeTryouts[holeIndex] === undefined) { + conversionData.holeTryouts[holeIndex] = 0; + } + conversionData.holeTryouts[holeIndex] += 1; + if (conversionData.holeTryouts[holeIndex] > 10) { + return null; + } holeQueue.push (holeIndex); } } diff --git a/src/modeler/generator.js b/src/modeler/generator.js index 93504f54..53459d0f 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -876,55 +876,36 @@ JSM.GenerateCurvedPrism = function (basePolygon, curveGroups, direction, height, */ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAndBottom) { - function AddVertices () + function AddVertices (contourPolygon, direction, height, result) { - var i; - for (i = 0; i < basePolygon.length; i++) { - if (basePolygon[i] !== null) { - result.AddVertex (new JSM.BodyVertex (basePolygon[i])); - result.AddVertex (new JSM.BodyVertex (basePolygon[i].Clone ().Offset (direction, height))); - } - } - } - - function GetContourEnds () - { - var contourCount = 0; - var contourEnds = []; - contourEnds.push (0); - - var i; - for (i = 0; i < basePolygon.length; i++) { - if (basePolygon[i] === null) { - contourEnds.push (i - contourCount); - contourCount = contourCount + 1; + var i, j, contour, vertex1, vertex2; + for (i = 0; i < contourPolygon.ContourCount (); i++) { + contour = contourPolygon.GetContour (i); + for (j = 0; j < contour.VertexCount (); j++) { + vertex1 = contour.GetVertex (j).Clone (); + vertex2 = contour.GetVertex (j).Clone ().Offset (direction, height); + result.AddVertex (new JSM.BodyVertex (vertex1)); + result.AddVertex (new JSM.BodyVertex (vertex2)); } } - contourEnds.push (i - contourCount); - return contourEnds; } - function AddContourPolygons (contourIndex, contourEnds) + function AddContours (contourPolygon, result) { - var i, current, next; - var from = contourEnds[contourIndex]; - var to = contourEnds[contourIndex + 1]; - for (i = from; i < to; i++) { - current = 2 * i; - next = current + 2; - if (i === to - 1) { - next = 2 * from; + var offset = 0; + var i, j, contour, vertexCount, current, next; + for (i = 0; i < contourPolygon.ContourCount (); i++) { + contour = contourPolygon.GetContour (i); + vertexCount = contour.VertexCount (); + for (j = 0; j < vertexCount; j++) { + current = offset + 2 * j; + next = current + 2; + if (j == vertexCount - 1) { + next = offset; + } + result.AddPolygon (new JSM.BodyPolygon ([current, next, next + 1, current + 1])); } - result.AddPolygon (new JSM.BodyPolygon ([current, next, next + 1, current + 1])); - } - } - - function AddContours () - { - var contourEnds = GetContourEnds (); - var i; - for (i = 0; i < contourEnds.length - 1; i++) { - AddContourPolygons (i, contourEnds); + offset += 2 * vertexCount; } } @@ -972,8 +953,10 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd } var result = new JSM.Body (); - AddVertices (); - AddContours (); + var contourPolygon = new JSM.ContourPolygon (); + contourPolygon.FromArray (basePolygon); + AddVertices (contourPolygon, direction, height, result); + AddContours (contourPolygon, result); if (withTopAndBottom) { AddTopBottomPolygons (); diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index bba1c209..20864db1 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -77,6 +77,25 @@ function CheckSimpleTriangulation (polygon) return CheckCalculatedTriangulation (polygon, triangles); } +function CheckHoleVertexMapping (polygon) +{ + var mapping = []; + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon, mapping); + if (mapping.length != simple.VertexCount ()) { + return false; + } + var i, map, originalVertex, simpleVertex; + for (i = 0; i < mapping.length; i++) { + map = mapping[i]; + originalVertex = polygon.GetContourVertex (map[0], map[1]); + simpleVertex = simple.GetVertex (i); + if (!simpleVertex.IsEqual (originalVertex)) { + return false; + } + } + return true; +} + var simplePolygonSuite = unitTest.AddTestSuite ('SimplePolygonTriangulationTest'); simplePolygonSuite.AddTest ('InvalidPolygonTest', function (test) @@ -306,12 +325,14 @@ simplePolygonSuite.AddTest ('OldTriangulationTest03', function (test) polygon.AddVertex (2, 1); var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); test.AssertEqual (polygon.GetArea (), simple.GetArea ()); test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -337,6 +358,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest03', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -367,6 +389,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest03', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -393,6 +416,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest03', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); }); simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) @@ -650,6 +674,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -675,6 +700,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -705,6 +731,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -734,6 +761,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -773,6 +801,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon = new JSM.ContourPolygon2D (); polygon.AddContour (); @@ -812,6 +841,7 @@ simplePolygonSuite.AddTest ('OldTriangulationTest04', function (test) test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); test.Assert (CheckSimpleTriangulation (simple)); + test.Assert (CheckHoleVertexMapping (polygon)); }); simplePolygonSuite.AddTest ('ConcaveTriangulationTest01', function (test) @@ -892,6 +922,7 @@ convertToSimplePolygonSuite.AddTest ('SimplePolygonTest', function (test) test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Convex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Convex); + test.Assert (CheckHoleVertexMapping (polygon)); var polygon2 = new JSM.ContourPolygon2D (); polygon2.AddContour (); @@ -906,7 +937,8 @@ convertToSimplePolygonSuite.AddTest ('SimplePolygonTest', function (test) test.AssertEqual (polygon2.GetArea (), simple2.GetArea ()); test.AssertEqual (polygon2.GetOrientation (), simple2.GetOrientation ()); test.AssertEqual (polygon2.GetComplexity (), JSM.Complexity.Convex); - test.AssertEqual (simple2.GetComplexity (), JSM.Complexity.Convex); + test.AssertEqual (simple2.GetComplexity (), JSM.Complexity.Convex); + test.Assert (CheckHoleVertexMapping (polygon)); }); convertToSimplePolygonSuite.AddTest ('OneHoleTest01', function (test) @@ -931,6 +963,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest01', function (test) test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckHoleVertexMapping (polygon)); }); convertToSimplePolygonSuite.AddTest ('OneHoleTest02', function (test) @@ -955,6 +988,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest02', function (test) test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckHoleVertexMapping (polygon)); }); convertToSimplePolygonSuite.AddTest ('OneHoleTest03', function (test) @@ -979,6 +1013,7 @@ convertToSimplePolygonSuite.AddTest ('OneHoleTest03', function (test) test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckHoleVertexMapping (polygon)); }); convertToSimplePolygonSuite.AddTest ('TwoHolesTest', function (test) @@ -1009,6 +1044,63 @@ convertToSimplePolygonSuite.AddTest ('TwoHolesTest', function (test) test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + test.Assert (CheckHoleVertexMapping (polygon)); +}); + +convertToSimplePolygonSuite.AddTest ('MappingTest', function (test) +{ + function EqualArrayOfArrays (a, b) + { + if (a.length != b.length) { + return false; + } + var i, j; + for (i = 0; i < a.length; i++) { + if (a[i].length != b[i].length) { + return false; + } + for (j = 0; j < a[i].length; j++) { + if (a[i][j] != b[i][j]) { + return false; + } + } + } + return true; + } + + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0.0, 0.0); + polygon.AddVertex (5.0, 0.0); + polygon.AddVertex (5.0, 4.0); + polygon.AddVertex (0.0, 4.0); + + var mapping = []; + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon, mapping); + test.Assert (EqualArrayOfArrays (mapping, [[0, 0], [0, 1], [0, 2], [0, 3]])); + test.Assert (CheckHoleVertexMapping (polygon)); + + polygon.AddContour (); + polygon.AddVertex (1.0, 1.0); + polygon.AddVertex (1.0, 2.0); + polygon.AddVertex (2.0, 2.0); + polygon.AddVertex (2.0, 1.0); + + var mapping = []; + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon, mapping); + test.Assert (EqualArrayOfArrays (mapping, [[0, 1], [0, 2], [0, 3], [0, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 0], [0, 0]])); + test.Assert (CheckHoleVertexMapping (polygon)); + + polygon.AddContour (); + polygon.AddVertex (3.0, 1.0); + polygon.AddVertex (3.0, 2.0); + polygon.AddVertex (4.0, 2.0); + polygon.AddVertex (4.0, 1.0); + + var mapping = []; + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon, mapping); + test.Assert (EqualArrayOfArrays (mapping, [[0, 2], [0, 3], [0, 0], [1, 0], [1, 1], [1, 2], [1, 3], [1, 0], [0, 0], [0, 1], [2, 0], [2, 1], [2, 2], [2, 3], [2, 0], [0, 1]])); + test.Assert (CheckHoleVertexMapping (polygon)); }); var polygonSuite = unitTest.AddTestSuite ('PolygonTriangulationTest'); From 74488446348c100c16e9a889c079b12f45f953eb Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 30 Jul 2015 21:58:59 +0200 Subject: [PATCH 22/27] Remove old polygon utils. --- build/jsmodeler.js | 161 ++++++++------- documentation/jsmdoc/include/jsmdoc.json | 18 -- sandbox/3dsdump.html | 1 - sandbox/bezier.html | 1 - sandbox/beziercurve.html | 1 - sandbox/bspline.html | 1 - sandbox/charts.html | 1 - sandbox/convexhull.html | 1 - sandbox/coplanar.html | 1 - sandbox/csg.html | 1 - sandbox/csg2.html | 1 - sandbox/curvedprism.html | 1 - sandbox/docimages.html | 1 - sandbox/doublesided.html | 1 - sandbox/githublogo.html | 1 - sandbox/heightmap.html | 1 - sandbox/hiddenline.html | 1 - sandbox/importer.html | 1 - sandbox/jsonimport.html | 1 - sandbox/jsonimporttexture.html | 1 - sandbox/minimal.html | 1 - sandbox/minimal2.html | 1 - sandbox/octree.html | 1 - sandbox/pointcloud.html | 1 - sandbox/pointcloudjson.html | 1 - sandbox/print.html | 1 - sandbox/prismwithhole.html | 1 - sandbox/randommat.html | 1 - sandbox/renderer.html | 1 - sandbox/revolved.html | 1 - sandbox/smartbuilder.html | 1 - sandbox/smartbuilder2.html | 1 - sandbox/solids.html | 1 - sandbox/specular.html | 1 - sandbox/svgonthefly.html | 1 - sandbox/svgtomodel.html | 1 - sandbox/svgtomodel2.html | 1 - sandbox/svgtomodeltexture.html | 1 - sandbox/tasks.html | 1 - sandbox/texture.html | 1 - sandbox/tictactoecanvas.html | 1 - sandbox/triangulate.html | 1 - sandbox/triangulation/polygoneditor.html | 1 - sandbox/tube.html | 1 - sandbox/undermouse.html | 1 - sandbox/viewer.html | 1 - src/geometry/oldpolygonutils.js | 237 ----------------------- src/geometry/polygon.js | 9 +- src/modeler/generator.js | 72 +++---- test/unittest/jsmodelertest.js | 1 - test/unittest/tests/triangulation.js | 72 +++++++ test/viewertest/cameratest.html | 1 - test/viewertest/csgtest.html | 1 - test/viewertest/importtest.html | 1 - test/viewertest/svgtomodeltest.html | 1 - test/viewertest/texturetest.html | 1 - test/viewertest/viewertest.html | 1 - test/viewertest/viewertypes.html | 1 - tools/files.txt | 1 - 59 files changed, 189 insertions(+), 433 deletions(-) delete mode 100644 src/geometry/oldpolygonutils.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 81a1ca09..357150fc 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -16,7 +16,7 @@ JSM.Coord.prototype.Normalize=function(){var a=this.Length();JSM.IsPositive(a)&& JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,l=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*l;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*l;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*l;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this}; JSM.Coord.prototype.ToCoord2D=function(a){var b=new JSM.Coord(0,0,0),c=new JSM.Vector(0,0,1),d=JSM.VectorCross(a,c);a=a.AngleTo(c);b=this.Clone().Rotate(d,a,b);return new JSM.Coord2D(b.x,b.y)};JSM.Coord.prototype.ToString=function(){return"("+this.x+", "+this.y+", "+this.z+")"};JSM.Coord.prototype.Clone=function(){return new JSM.Coord(this.x,this.y,this.z)};JSM.Vector=JSM.Coord;JSM.CoordFromArray=function(a){return new JSM.Coord(a[0],a[1],a[2])};JSM.CoordToArray=function(a){return[a.x,a.y,a.z]}; JSM.CoordAdd=function(a,b){return new JSM.Coord(a.x+b.x,a.y+b.y,a.z+b.z)};JSM.CoordSub=function(a,b){return new JSM.Coord(a.x-b.x,a.y-b.y,a.z-b.z)};JSM.VectorDot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};JSM.VectorCross=function(a,b){var c=new JSM.Vector(0,0,0);c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};JSM.MatrixDeterminant2x2=function(a,b,c,d){return a*d-b*c}; -JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,l){var k=JSM.MatrixDeterminant2x2(e,f,g,l);f=JSM.MatrixDeterminant2x2(d,f,h,l);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*k-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,l,k,m,n,p,q,r,t){var v=JSM.MatrixDeterminant3x3(f,h,g,k,m,n,q,r,t),u=JSM.MatrixDeterminant3x3(e,h,g,l,m,n,p,r,t);g=JSM.MatrixDeterminant3x3(e,f,g,l,k,n,p,q,t);e=JSM.MatrixDeterminant3x3(e,f,h,l,k,m,p,q,r);return v*a-u*b+g*c-e*d}; +JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,l){var k=JSM.MatrixDeterminant2x2(e,f,g,l);f=JSM.MatrixDeterminant2x2(d,f,h,l);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*k-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,l,k,m,n,p,q,t,r){var u=JSM.MatrixDeterminant3x3(f,h,g,k,m,n,q,t,r),v=JSM.MatrixDeterminant3x3(e,h,g,l,m,n,p,t,r);g=JSM.MatrixDeterminant3x3(e,f,g,l,k,n,p,q,r);e=JSM.MatrixDeterminant3x3(e,f,h,l,k,m,p,q,t);return u*a-v*b+g*c-e*d}; JSM.Orientation={Invalid:0,CounterClockwise:1,Clockwise:2};JSM.MidCoord2D=function(a,b){return new JSM.Coord2D((a.x+b.x)/2,(a.y+b.y)/2)};JSM.CoordOrientation2D=function(a,b,c){var d=a.x;a=a.y;var e=b.x;b=b.y;var f=c.x;c=c.y;d=d*b+a*f+e*c-b*f-a*e-d*c;return JSM.IsPositive(d)?JSM.Orientation.CounterClockwise:JSM.IsNegative(d)?JSM.Orientation.Clockwise:JSM.Orientation.Invalid};JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c}; JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a};JSM.MidCoord=function(a,b){return new JSM.Coord((a.x+b.x)/2,(a.y+b.y)/2,(a.z+b.z)/2)};JSM.CoordSignedDistance=function(a,b,c){var d=JSM.CoordSub(b,a);a=a.DistanceTo(b);c=d.AngleTo(c);JSM.IsPositive(c)&&(a=-a);return a};JSM.GetVectorsFullAngle=function(a,b,c){var d=a.AngleTo(b),e=new JSM.Coord(0,0,0);JSM.CoordOrientation(a,e,b,c)==JSM.Orientation.Clockwise&&(d=2*Math.PI-d);return d}; JSM.CoordOrientation=function(a,b,c,d){a=a.ToCoord2D(d);b=b.ToCoord2D(d);c=c.ToCoord2D(d);c=JSM.CoordOrientation2D(a,b,c);a=new JSM.Vector(0,0,1);d=d.AngleTo(a);JSM.IsEqual(d,Math.PI)&&(c==JSM.Orientation.CounterClockwise?c=JSM.Orientation.Clockwise:c==JSM.Orientation.Clockwise&&(c=JSM.Orientation.CounterClockwise));return c};JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d}; @@ -24,11 +24,11 @@ JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math JSM.CalculateTriangleNormal=function(a,b,c){b=JSM.CoordSub(b,a);a=JSM.CoordSub(c,a);c=new JSM.Vector(0,0,0);c.x=b.y*a.z-b.z*a.y;c.y=b.z*a.x-b.x*a.z;c.z=b.x*a.y-b.y*a.x;c.Normalize();return c};JSM.CalculateNormal=function(a){var b=a.length,c=new JSM.Vector(0,0,0);if(3<=b){var d,e,f;for(d=0;da?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],r=a[11],t=a[13],v=a[14],u=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*k+e*p+f*t;s[2]=c*g+d*m+e*q+f*v;s[3]=c*l+d*n+e*r+f*u;return s}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],r=a[12],t=a[13],v=a[14],u=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],A=b[5],B=b[6],K=b[7],L=b[8],H=b[9],C=b[10],E=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*s+d*x+e*L+f*N;F[1]=c*w+d*A+e*H+f*O;F[2]=c*y+d*B+e*C+f*J;F[3]=c*z+d*K+e*E+f*I;F[4]=h*s+g*x+l*L+k*N;F[5]=h*w+g*A+l*H+k*O;F[6]=h*y+g*B+l*C+k*J;F[7]=h*z+g*K+l*E+k*I;F[8]=m*s+n*x+p*L+q*N;F[9]=m*w+n*A+p*H+q*O;F[10]=m*y+n*B+ -p*C+q*J;F[11]=m*z+n*K+p*E+q*I;F[12]=r*s+t*x+v*L+u*N;F[13]=r*w+t*A+v*H+u*O;F[14]=r*y+t*B+v*C+u*J;F[15]=r*z+t*K+v*E+u*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],r=a[13],t=a[14];a=a[15];return(b*h-c*f)*(n*a-p*t)-(b*g-d*f)*(m*a-p*r)+(b*l-e*f)*(m*t-n*r)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*t-n*q)+(d*l-e*g)*(k*r-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],r=a[13],t=a[14];a=a[15];var v=b*h-c*f,u=b*g-d*f,s=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*r-m*q,A=k*t-n*q,B=k*a-p*q,K=m*t-n*r,L=m*a-p*r,H=n*a-p*t,C=v*H-u*L+s*K+w*B-y*A+z*x;if(JSM.IsZero(C))return null;var E=[];E[0]=(h*H-g*L+l*K)/C;E[1]=(d*L-c*H-e*K)/C;E[2]=(r*z-t*y+a*w)/C;E[3]=(n*y-m*z-p*w)/C;E[4]=(g*B-f*H-l*A)/C;E[5]=(b*H-d*B+e*A)/C;E[6]=(t*s-q*z-a*u)/C;E[7]=(k*z-n*s+p* -u)/C;E[8]=(f*L-h*B+l*x)/C;E[9]=(c*B-b*L-e*x)/C;E[10]=(q*y-r*s+a*v)/C;E[11]=(m*s-k*y-p*v)/C;E[12]=(h*A-f*K-g*x)/C;E[13]=(b*K-c*A+d*x)/C;E[14]=(r*u-q*w-t*v)/C;E[15]=(k*w-m*u+n*v)/C;return E};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],r=a[13],u=a[14],v=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*k+e*p+f*r;s[2]=c*g+d*m+e*q+f*u;s[3]=c*l+d*n+e*t+f*v;return s}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],r=a[13],u=a[14],v=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],E=b[5],A=b[6],K=b[7],L=b[8],H=b[9],B=b[10],D=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*s+d*x+e*L+f*N;F[1]=c*w+d*E+e*H+f*O;F[2]=c*y+d*A+e*B+f*J;F[3]=c*z+d*K+e*D+f*I;F[4]=h*s+g*x+l*L+k*N;F[5]=h*w+g*E+l*H+k*O;F[6]=h*y+g*A+l*B+k*J;F[7]=h*z+g*K+l*D+k*I;F[8]=m*s+n*x+p*L+q*N;F[9]=m*w+n*E+p*H+q*O;F[10]=m*y+n*A+ +p*B+q*J;F[11]=m*z+n*K+p*D+q*I;F[12]=t*s+r*x+u*L+v*N;F[13]=t*w+r*E+u*H+v*O;F[14]=t*y+r*A+u*B+v*J;F[15]=t*z+r*K+u*D+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];return(b*h-c*f)*(n*a-p*r)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*r-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*r-n*q)+(d*l-e*g)*(k*t-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,s=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*t-m*q,E=k*r-n*q,A=k*a-p*q,K=m*r-n*t,L=m*a-p*t,H=n*a-p*r,B=u*H-v*L+s*K+w*A-y*E+z*x;if(JSM.IsZero(B))return null;var D=[];D[0]=(h*H-g*L+l*K)/B;D[1]=(d*L-c*H-e*K)/B;D[2]=(t*z-r*y+a*w)/B;D[3]=(n*y-m*z-p*w)/B;D[4]=(g*A-f*H-l*E)/B;D[5]=(b*H-d*A+e*E)/B;D[6]=(r*s-q*z-a*v)/B;D[7]=(k*z-n*s+p* +v)/B;D[8]=(f*L-h*A+l*x)/B;D[9]=(c*A-b*L-e*x)/B;D[10]=(q*y-t*s+a*u)/B;D[11]=(m*s-k*y-p*u)/B;D[12]=(h*E-f*K-g*x)/B;D[13]=(b*K-c*E+d*x)/B;D[14]=(t*v-q*w-r*u)/B;D[15]=(k*w-m*v+n*u)/B;return D};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; @@ -45,7 +45,7 @@ f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2 (void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=h;n/= h;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, -q=f.y,r=h.x,t=h.y,v=g.x,u=g.y,s=(v-r)*(n-t)-(u-t)*(m-r),w=(p-m)*(n-t)-(q-n)*(m-r),r=(u-t)*(p-m)-(v-r)*(q-n);if(JSM.IsZero(r)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/r;w/=r;if(JSM.IsLower(h, +q=f.y,t=h.x,r=h.y,u=g.x,v=g.y,s=(u-t)*(n-r)-(v-r)*(m-t),w=(p-m)*(n-r)-(q-n)*(m-t),t=(v-r)*(p-m)-(u-t)*(q-n);if(JSM.IsZero(t)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/t;w/=t;if(JSM.IsLower(h, 0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; @@ -103,14 +103,14 @@ JSM.Polygon.prototype.SetVertex=function(a,b,c,d){this.vertices[a].Set(b,c,d)};J JSM.Polygon.prototype.ToArray=function(){var a=[],b,c;for(b=0;bb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)};JSM.OldContourPolygon2D=function(){this.polygons=[]}; JSM.OldContourPolygon2D.prototype.AddVertex=function(a,b,c){void 0===this.polygons[a]&&(this.polygons[a]=new JSM.Polygon2D);this.polygons[a].AddVertex(b,c)};JSM.OldContourPolygon2D.prototype.VertexCount=function(a){return void 0===this.polygons[a]?0:this.polygons[a].VertexCount()};JSM.OldContourPolygon2D.prototype.GetVertex=function(a,b){return this.polygons[a].GetVertex(b)};JSM.OldContourPolygon2D.prototype.SetVertex=function(a,b,c,d){this.polygons[a].SetVertex(b,c,d)}; JSM.OldContourPolygon2D.prototype.AddContour=function(){this.polygons.push(new JSM.Polygon2D)};JSM.OldContourPolygon2D.prototype.ContourCount=function(){return this.polygons.length};JSM.OldContourPolygon2D.prototype.GetContour=function(a){return this.polygons[a]};JSM.OldContourPolygon2D.prototype.Clear=function(){this.polygons=[]};JSM.OldContourPolygon2D.prototype.Clone=function(){var a=new JSM.OldContourPolygon2D,b;for(b=0;b=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; @@ -174,8 +171,8 @@ e.curved=f.curved,b.AddPolygon(e)}return b}; JSM.TriangulatePolygons=function(a){var b=new JSM.Body,c,d,e;for(c=0;ck;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== @@ -184,19 +181,19 @@ JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b) JSM.CalculatePolygonCylindricalTextureCoords=function(a,b,c){var d=[],e=[],f=a.GetPolygon(b),h=a.GetTextureProjectionCoords(),g;for(b=0;be;e++)q.AddVertexIndex(2*c[b[p[e]]]+1),r.AddVertexIndex(2*c[b[p[3-e-1]]]);f.AddPolygon(q);f.AddPolygon(r)}}}var f=new JSM.Body, -h=new JSM.ContourPolygon;h.FromArray(a);(function(a,b,c,d){var e,f,h,r,t;for(e=0;eg;g++)r=c[h[g]],u.AddVertexIndex(2*b[r[0]]+2*r[1]+1),r=c[h[2-g]],v.AddVertexIndex(2*b[r[0]]+2*r[1]);f.AddPolygon(u);f.AddPolygon(v)}}}var f=new JSM.Body,h=[],g=new JSM.ContourPolygon;g.FromArray(a);(function(a, +b,c,d){var e,f,g,h,u;for(e=0;ew)){var H=void 0,C=void 0,E=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gw)){var H=void 0,B=void 0,D=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +JSM.TriangleBody.prototype.Finalize=function(a){function b(b,c,d,f){function h(a,b,c,d,e){var f=new JSM.Vector(0,0,0),g=0;c=a.GetTriangle(c);b=e[b];var l,k;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; @@ -292,36 +289,36 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,r,t,v,u,s,w,y,z,x,A,B,K,L,H,C,E,N,O,J,I,F,Q,G,M,T,S,U,Y;function D(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;r=19;t=41472;v=41728;u=41816;s=41818;w=41812;y=41814;z=41820;x=48;A=49;B=16384;K=16640;L=17920;H=18176;C=16656;E=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ -255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==r?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==A?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==v?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){D("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(D("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(D("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==h?(D("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(D("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(D("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(D("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(D("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= -W(a,b,p)):b==t?(D("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(D("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){D("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else D("Skip chunk ("+c.toString(16)+", "+d+")",4), -a.Skip(d-6)})}function ca(a,b,c){D("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?D("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?D("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):D("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){D("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==B?ca(a,b,c):(D("Skip chunk ("+ -b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dd;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;r=41472;u=41728;v=41816;s=41818;w=41812;y=41814;z=41820;x=48;E=49;A=16384;K=16640;L=17920;H=18176;B=16656;D=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==E?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){C("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(C("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(C("Read material ambient chunk ("+c.toString(16)+ +", "+d+")",3),n.ambient=V(a,b,p)):b==h?(C("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(C("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(C("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(C("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(C("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +W(a,b,p)):b==r?(C("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(C("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){C("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,l;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else C("Skip chunk ("+c.toString(16)+", "+d+")",4), +a.Skip(d-6)})}function ca(a,b,c){C("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?C("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?C("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):C("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){C("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==A?ca(a,b,c):(C("Skip chunk ("+ +b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), -parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],r=[],t;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== +parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],r;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; @@ -415,11 +412,11 @@ JSM.GenerateTruncatedIcosidodecahedron=function(){var a=new JSM.Body,b=(1+Math.s [18,22,46,70,66,42]);JSM.AddPolygonToBody(a,[20,44,68,71,47,23]);JSM.AddPolygonToBody(a,[72,112,88,104,80,96]);JSM.AddPolygonToBody(a,[73,97,83,107,90,114]);JSM.AddPolygonToBody(a,[74,98,81,105,91,115]);JSM.AddPolygonToBody(a,[75,99,82,106,89,113]);JSM.AddPolygonToBody(a,[76,118,94,109,85,100]);JSM.AddPolygonToBody(a,[78,117,93,108,84,102]);JSM.AddPolygonToBody(a,[79,103,87,111,95,119]);JSM.AddPolygonToBody(a,[86,101,77,116,92,110]);JSM.AddPolygonToBody(a,[0,2,26,74,115,67,64,112,72,24]);JSM.AddPolygonToBody(a, [1,25,73,114,66,70,118,76,28,4]);JSM.AddPolygonToBody(a,[3,27,75,113,65,69,117,78,30,6]);JSM.AddPolygonToBody(a,[5,7,31,79,119,71,68,116,77,29]);JSM.AddPolygonToBody(a,[8,10,34,82,99,51,48,96,80,32]);JSM.AddPolygonToBody(a,[9,33,81,98,50,54,102,84,36,12]);JSM.AddPolygonToBody(a,[11,35,83,97,49,53,101,86,38,14]);JSM.AddPolygonToBody(a,[13,15,39,87,103,55,52,100,85,37]);JSM.AddPolygonToBody(a,[16,18,42,90,107,59,56,104,88,40]);JSM.AddPolygonToBody(a,[17,41,89,106,58,62,110,92,44,20]);JSM.AddPolygonToBody(a, [19,43,91,105,57,61,109,94,46,22]);JSM.AddPolygonToBody(a,[21,23,47,95,111,63,60,108,93,45]);return a}; -JSM.GenerateSnubDodecahedron=function(){var a=new JSM.Body,b=(1+Math.sqrt(5))/2,c=Math.pow(b/2+0.5*Math.sqrt(b-5/27),1/3)+Math.pow(b/2-0.5*Math.sqrt(b-5/27),1/3),d=c-1/c,e=c*b+Math.pow(b,2)+b/c,c=2*d,f=2*e,h=d+e/b+b,g=-(d*b)+e+1/b,l=d/b+e*b-1,k=-(d/b)+e*b+1,m=-d+e/b-b,n=d*b+e-1/b,p=-(d/b)+e*b-1,q=d-e/b-b,r=d*b+e+1/b,t=d+e/b-b,v=d*b-e+1/b,b=d/b+e*b+1;JSM.AddVertexToBody(a,+c,2,-f);JSM.AddVertexToBody(a,+c,-2,+f);JSM.AddVertexToBody(a,-c,2,+f);JSM.AddVertexToBody(a,-c,-2,-f);JSM.AddVertexToBody(a,2, +JSM.GenerateSnubDodecahedron=function(){var a=new JSM.Body,b=(1+Math.sqrt(5))/2,c=Math.pow(b/2+0.5*Math.sqrt(b-5/27),1/3)+Math.pow(b/2-0.5*Math.sqrt(b-5/27),1/3),d=c-1/c,e=c*b+Math.pow(b,2)+b/c,c=2*d,f=2*e,h=d+e/b+b,g=-(d*b)+e+1/b,l=d/b+e*b-1,k=-(d/b)+e*b+1,m=-d+e/b-b,n=d*b+e-1/b,p=-(d/b)+e*b-1,q=d-e/b-b,t=d*b+e+1/b,r=d+e/b-b,u=d*b-e+1/b,b=d/b+e*b+1;JSM.AddVertexToBody(a,+c,2,-f);JSM.AddVertexToBody(a,+c,-2,+f);JSM.AddVertexToBody(a,-c,2,+f);JSM.AddVertexToBody(a,-c,-2,-f);JSM.AddVertexToBody(a,2, -f,+c);JSM.AddVertexToBody(a,-2,+f,+c);JSM.AddVertexToBody(a,2,+f,-c);JSM.AddVertexToBody(a,-2,-f,-c);JSM.AddVertexToBody(a,-f,+c,2);JSM.AddVertexToBody(a,+f,+c,-2);JSM.AddVertexToBody(a,+f,-c,2);JSM.AddVertexToBody(a,-f,-c,-2);JSM.AddVertexToBody(a,+h,+g,-l);JSM.AddVertexToBody(a,+h,-g,+l);JSM.AddVertexToBody(a,-h,+g,+l);JSM.AddVertexToBody(a,-h,-g,-l);JSM.AddVertexToBody(a,+g,-l,+h);JSM.AddVertexToBody(a,-g,+l,+h);JSM.AddVertexToBody(a,+g,+l,-h);JSM.AddVertexToBody(a,-g,-l,-h);JSM.AddVertexToBody(a, -l,+h,+g);JSM.AddVertexToBody(a,+l,+h,-g);JSM.AddVertexToBody(a,+l,-h,+g);JSM.AddVertexToBody(a,-l,-h,-g);JSM.AddVertexToBody(a,+k,+m,-n);JSM.AddVertexToBody(a,+k,-m,+n);JSM.AddVertexToBody(a,-k,+m,+n);JSM.AddVertexToBody(a,-k,-m,-n);JSM.AddVertexToBody(a,+m,-n,+k);JSM.AddVertexToBody(a,-m,+n,+k);JSM.AddVertexToBody(a,+m,+n,-k);JSM.AddVertexToBody(a,-m,-n,-k);JSM.AddVertexToBody(a,-n,+k,+m);JSM.AddVertexToBody(a,+n,+k,-m);JSM.AddVertexToBody(a,+n,-k,+m);JSM.AddVertexToBody(a,-n,-k,-m);JSM.AddVertexToBody(a, -+p,+q,-r);JSM.AddVertexToBody(a,+p,-q,+r);JSM.AddVertexToBody(a,-p,+q,+r);JSM.AddVertexToBody(a,-p,-q,-r);JSM.AddVertexToBody(a,+q,-r,+p);JSM.AddVertexToBody(a,-q,+r,+p);JSM.AddVertexToBody(a,+q,+r,-p);JSM.AddVertexToBody(a,-q,-r,-p);JSM.AddVertexToBody(a,-r,+p,+q);JSM.AddVertexToBody(a,+r,+p,-q);JSM.AddVertexToBody(a,+r,-p,+q);JSM.AddVertexToBody(a,-r,-p,-q);JSM.AddVertexToBody(a,+t,+v,-b);JSM.AddVertexToBody(a,+t,-v,+b);JSM.AddVertexToBody(a,-t,+v,+b);JSM.AddVertexToBody(a,-t,-v,-b);JSM.AddVertexToBody(a, -+v,-b,+t);JSM.AddVertexToBody(a,-v,+b,+t);JSM.AddVertexToBody(a,+v,+b,-t);JSM.AddVertexToBody(a,-v,-b,-t);JSM.AddVertexToBody(a,-b,+t,+v);JSM.AddVertexToBody(a,+b,+t,-v);JSM.AddVertexToBody(a,+b,-t,+v);JSM.AddVertexToBody(a,-b,-t,-v);JSM.AddPolygonToBody(a,[0,3,51]);JSM.AddPolygonToBody(a,[0,30,12]);JSM.AddPolygonToBody(a,[0,48,3]);JSM.AddPolygonToBody(a,[0,51,30]);JSM.AddPolygonToBody(a,[1,2,50]);JSM.AddPolygonToBody(a,[1,28,13]);JSM.AddPolygonToBody(a,[1,49,2]);JSM.AddPolygonToBody(a,[1,50,28]); ++p,+q,-t);JSM.AddVertexToBody(a,+p,-q,+t);JSM.AddVertexToBody(a,-p,+q,+t);JSM.AddVertexToBody(a,-p,-q,-t);JSM.AddVertexToBody(a,+q,-t,+p);JSM.AddVertexToBody(a,-q,+t,+p);JSM.AddVertexToBody(a,+q,+t,-p);JSM.AddVertexToBody(a,-q,-t,-p);JSM.AddVertexToBody(a,-t,+p,+q);JSM.AddVertexToBody(a,+t,+p,-q);JSM.AddVertexToBody(a,+t,-p,+q);JSM.AddVertexToBody(a,-t,-p,-q);JSM.AddVertexToBody(a,+r,+u,-b);JSM.AddVertexToBody(a,+r,-u,+b);JSM.AddVertexToBody(a,-r,+u,+b);JSM.AddVertexToBody(a,-r,-u,-b);JSM.AddVertexToBody(a, ++u,-b,+r);JSM.AddVertexToBody(a,-u,+b,+r);JSM.AddVertexToBody(a,+u,+b,-r);JSM.AddVertexToBody(a,-u,-b,-r);JSM.AddVertexToBody(a,-b,+r,+u);JSM.AddVertexToBody(a,+b,+r,-u);JSM.AddVertexToBody(a,+b,-r,+u);JSM.AddVertexToBody(a,-b,-r,-u);JSM.AddPolygonToBody(a,[0,3,51]);JSM.AddPolygonToBody(a,[0,30,12]);JSM.AddPolygonToBody(a,[0,48,3]);JSM.AddPolygonToBody(a,[0,51,30]);JSM.AddPolygonToBody(a,[1,2,50]);JSM.AddPolygonToBody(a,[1,28,13]);JSM.AddPolygonToBody(a,[1,49,2]);JSM.AddPolygonToBody(a,[1,50,28]); JSM.AddPolygonToBody(a,[2,29,14]);JSM.AddPolygonToBody(a,[2,49,29]);JSM.AddPolygonToBody(a,[3,31,15]);JSM.AddPolygonToBody(a,[3,48,31]);JSM.AddPolygonToBody(a,[4,7,55]);JSM.AddPolygonToBody(a,[4,34,16]);JSM.AddPolygonToBody(a,[4,52,7]);JSM.AddPolygonToBody(a,[4,55,34]);JSM.AddPolygonToBody(a,[5,6,54]);JSM.AddPolygonToBody(a,[5,32,17]);JSM.AddPolygonToBody(a,[5,53,6]);JSM.AddPolygonToBody(a,[5,54,32]);JSM.AddPolygonToBody(a,[6,33,18]);JSM.AddPolygonToBody(a,[6,53,33]);JSM.AddPolygonToBody(a,[7,35, 19]);JSM.AddPolygonToBody(a,[7,52,35]);JSM.AddPolygonToBody(a,[8,11,59]);JSM.AddPolygonToBody(a,[8,26,20]);JSM.AddPolygonToBody(a,[8,56,11]);JSM.AddPolygonToBody(a,[8,59,26]);JSM.AddPolygonToBody(a,[9,10,58]);JSM.AddPolygonToBody(a,[9,24,21]);JSM.AddPolygonToBody(a,[9,57,10]);JSM.AddPolygonToBody(a,[9,58,24]);JSM.AddPolygonToBody(a,[10,25,22]);JSM.AddPolygonToBody(a,[10,57,25]);JSM.AddPolygonToBody(a,[11,27,23]);JSM.AddPolygonToBody(a,[11,56,27]);JSM.AddPolygonToBody(a,[12,18,21]);JSM.AddPolygonToBody(a, [12,21,24]);JSM.AddPolygonToBody(a,[12,30,18]);JSM.AddPolygonToBody(a,[13,16,22]);JSM.AddPolygonToBody(a,[13,22,25]);JSM.AddPolygonToBody(a,[13,28,16]);JSM.AddPolygonToBody(a,[14,17,20]);JSM.AddPolygonToBody(a,[14,20,26]);JSM.AddPolygonToBody(a,[14,29,17]);JSM.AddPolygonToBody(a,[15,19,23]);JSM.AddPolygonToBody(a,[15,23,27]);JSM.AddPolygonToBody(a,[15,31,19]);JSM.AddPolygonToBody(a,[16,34,22]);JSM.AddPolygonToBody(a,[17,32,20]);JSM.AddPolygonToBody(a,[18,33,21]);JSM.AddPolygonToBody(a,[19,35,23]); @@ -441,44 +438,44 @@ JSM.GenerateCumulatedIcosahedron=function(a){var b=new JSM.Body,c=(1+Math.sqrt(5 JSM.GeneratePentakisDodecahedron=function(){var a=Math.sqrt((65+22*Math.sqrt(5))/5)/19;return JSM.GenerateCumulatedDodecahedron(a)};JSM.GenerateSmallStellatedDodecahedron=function(){var a=Math.sqrt((5+2*Math.sqrt(5))/5);return JSM.GenerateCumulatedDodecahedron(a)};JSM.GenerateGreatDodecahedron=function(){var a=Math.sqrt(3)*(Math.sqrt(5)-3)/6;return JSM.GenerateCumulatedIcosahedron(a)};JSM.GenerateSmallTriambicIcosahedron=function(){var a=Math.sqrt(15)/15;return JSM.GenerateCumulatedIcosahedron(a)}; JSM.GenerateGreatStellatedDodecahedron=function(){var a=Math.sqrt(3)*(3+Math.sqrt(5))/6;return JSM.GenerateCumulatedIcosahedron(a)};JSM.GenerateSmallTriakisOctahedron=function(){var a=Math.sqrt(3)-2*Math.sqrt(6)/3;return JSM.GenerateCumulatedOctahedron(a)};JSM.GenerateStellaOctangula=function(){var a=Math.sqrt(6)/3;return JSM.GenerateCumulatedOctahedron(a)};JSM.GenerateTriakisTetrahedron=function(){var a=Math.sqrt(6)/15;return JSM.GenerateCumulatedTetrahedron(a)}; JSM.LegoDimensions=function(){this.legoWidth=0.78;this.legoSmallHeight=0.32;this.legoLargeHeight=0.96;this.legoWallWidth=0.16;this.legoCylinderWidth=0.5;this.legoCylinderHeight=0.17;this.legoBottomSmallCylinderWidth=0.3;this.legoBottomLargeCylinderWidth=0.6;this.legoBottomLargeCylinderWallWidth=0.1}; -JSM.GenerateLegoBrick=function(a,b,c,d,e,f,h){function g(a,b){var c,d;for(c=0;cs;s++)u[s].z=n-c;s=JSM.GeneratePrism(u,k,c,!0);l.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;ss;s++)v[s].z=n-c;s=JSM.GeneratePrism(v,k,c,!0);l.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;sh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0g&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0 - diff --git a/sandbox/bezier.html b/sandbox/bezier.html index 00bbcb88..1ed55d71 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index cc52390b..e6728b93 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/bspline.html b/sandbox/bspline.html index 9ae293bf..d3a7a3dd 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/charts.html b/sandbox/charts.html index 36713e85..e83d8930 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index b828e5d6..8b89b089 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 4e74a1f8..44283192 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/csg.html b/sandbox/csg.html index cc548866..b65ef469 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/csg2.html b/sandbox/csg2.html index 8f5070ac..87b6e67d 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index 401d4a9e..d6dca66f 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/docimages.html b/sandbox/docimages.html index 06566c09..cccf9699 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index 88f95ee1..5c1d7043 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index 1d803622..9235ad5c 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index 620afd0e..a51115ce 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 545ecbcf..43458541 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/importer.html b/sandbox/importer.html index 6a3e0de7..f901218d 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index 359ebf61..d16ecb7d 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index ea3c28fe..6aaa3d5b 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/minimal.html b/sandbox/minimal.html index 710adef7..2bb3a77b 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index fba3edbb..96e226ce 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/octree.html b/sandbox/octree.html index dd6ff440..fc05610c 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 2e172a1e..866a98a0 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index 7fe3146e..59c0f92f 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/print.html b/sandbox/print.html index 1049270d..a457aab2 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index 8dda1294..ff274214 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/randommat.html b/sandbox/randommat.html index de7dde29..afecb47d 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/renderer.html b/sandbox/renderer.html index b50a9d67..69982141 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/revolved.html b/sandbox/revolved.html index 118c4243..994acdc1 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index 4ae6aded..950e7519 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index 70a303a5..96bc41c7 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/solids.html b/sandbox/solids.html index bca469f3..803aa515 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/specular.html b/sandbox/specular.html index 7ae0297e..9206a50c 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index 2f2c24b7..337665fa 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index 7564695f..e25ba760 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/svgtomodel2.html b/sandbox/svgtomodel2.html index a7db8d58..25384987 100644 --- a/sandbox/svgtomodel2.html +++ b/sandbox/svgtomodel2.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 16b2f163..24d6784b 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/tasks.html b/sandbox/tasks.html index 76b43972..7d6d16e9 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/texture.html b/sandbox/texture.html index 04da9c77..1ecbf329 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index cfbb23e3..717b8193 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index fcb700a0..35b6cd55 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/triangulation/polygoneditor.html b/sandbox/triangulation/polygoneditor.html index 30e8ef99..cefd691a 100644 --- a/sandbox/triangulation/polygoneditor.html +++ b/sandbox/triangulation/polygoneditor.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/tube.html b/sandbox/tube.html index a7de7a3f..4cb8be1e 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index 78ddd4ce..f44b545b 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 16bfb9a3..304caa6a 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -32,7 +32,6 @@ - diff --git a/src/geometry/oldpolygonutils.js b/src/geometry/oldpolygonutils.js deleted file mode 100644 index d9e88eca..00000000 --- a/src/geometry/oldpolygonutils.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* Function: CreatePolygonWithHole2D -* Description: -* Creates a simple polygon from multiple contours by creating in-out edges between -* contours. The input array should contain null values at contour ends. -* Parameters: -* vertices {Coord2D[*]} array of contour vertices with null values at contour ends -* Returns: -* {int[*]} the result -*/ -JSM.CreatePolygonWithHole2D = function (vertices) -{ - function GetContourEnds (vertices) - { - var contourEnds = []; - contourEnds.push (-1); - var i; - for (i = 0; i < vertices.length; i++) { - if (vertices[i] === null) { - contourEnds.push (i); - continue; - } - } - contourEnds.push (i); - return contourEnds; - } - - function GetContourPolygons (vertices, contourCount, contourEnds) - { - var contourPolygons = []; - var i, j, from, to, polygon, vertex; - for (i = 0; i < contourCount; i++) { - from = contourEnds[i] + 1; - to = contourEnds[i + 1]; - polygon = new JSM.Polygon2D (); - for (j = from; j < to; j++) { - vertex = vertices[j]; - polygon.AddVertex (vertex.x, vertex.y); - } - contourPolygons.push (polygon); - } - return contourPolygons; - } - - function FindHoleEntryPoint (vertices, contourIndex) - { - function IsNotIntersectingSector (currentSector, originalIndex, currentHoleIndex, originalPolygon, currentHolePolygon, contourPolygons, finishedContours) - { - if (originalPolygon.SectorPosition (currentSector, originalIndex, -1) != JSM.SectorPolygonPosition.NoIntersection) { - return false; - } - - if (currentHolePolygon.SectorPosition (currentSector, -1, currentHoleIndex) != JSM.SectorPolygonPosition.NoIntersection) { - return false; - } - - var i, currentContourPolygon; - for (i = 0; i < contourPolygons.length; i++) { - if (i == contourIndex || finishedContours[i] !== undefined) { - continue; - } - currentContourPolygon = contourPolygons[i]; - if (currentContourPolygon.SectorPosition (currentSector, -1, -1) != JSM.SectorPolygonPosition.NoIntersection) { - return false; - } - } - - return true; - } - - var originalPolygon = new JSM.Polygon2D (); - var i, j, vertex; - for (i = 0; i < resultIndices.length; i++) { - vertex = vertices[resultIndices[i]]; - originalPolygon.AddVertex (vertex.x, vertex.y); - } - - var entryPoint = null; - var from = contourEnds[contourIndex] + 1; - var currentHolePolygon = contourPolygons[contourIndex]; - - var currentSector; - for (i = 0; i < originalPolygon.VertexCount (); i++) { - for (j = 0; j < currentHolePolygon.VertexCount (); j++) { - currentSector = new JSM.Sector2D (originalPolygon.GetVertex (i), currentHolePolygon.GetVertex (j)); - if (IsNotIntersectingSector (currentSector, i, j, originalPolygon, currentHolePolygon, contourPolygons, finishedContours)) { - entryPoint = [resultIndices[i], j + from]; - break; - } - } - if (entryPoint !== null) { - break; - } - } - - return entryPoint; - } - - function AddHoleContour (vertices, contourIndex) - { - var entryPoint = FindHoleEntryPoint (vertices, contourIndex); - if (entryPoint === null) { - return false; - } - - var from = contourEnds[contourIndex] + 1; - var to = contourEnds[contourIndex + 1]; - - var oldResult = []; - var i; - for (i = 0; i < resultIndices.length; i++) { - oldResult[i] = resultIndices[i]; - } - - resultIndices = []; - var first, finished, originalInd, contourInd; - for (i = 0; i < oldResult.length; i++) { - originalInd = oldResult[i]; - resultIndices.push (originalInd); - if (originalInd == entryPoint[0]) { - contourInd = entryPoint[1]; - first = true; - finished = false; - while (!finished) { - resultIndices.push (contourInd); - if (!first && contourInd == entryPoint[1]) { - finished = true; - } - if (first) { - first = false; - } - if (contourInd < to - 1) { - contourInd = contourInd + 1; - } else { - contourInd = from; - } - } - resultIndices.push (originalInd); - } - } - - return true; - } - - function AddContour (vertices, contourIndex) - { - if (finishedContours[contourIndex] !== undefined) { - return false; - } - - var added = false; - var from = contourEnds[contourIndex] + 1; - var to = contourEnds[contourIndex + 1]; - - if (contourIndex === 0) { - var i; - for (i = from; i < to; i++) { - resultIndices.push (i); - } - finishedContours[contourIndex] = true; - } else { - if (AddHoleContour (vertices, contourIndex)) { - finishedContours[contourIndex] = true; - added = true; - } - } - - return added; - } - - var resultIndices = []; - var contourEnds = GetContourEnds (vertices); - var contourCount = contourEnds.length - 1; - if (contourCount === 0) { - contourCount = 1; - } - - var contourPolygons = GetContourPolygons (vertices, contourCount, contourEnds); - var finishedContours = {}; - var finishedContourCount = 1; - AddContour (vertices, 0); - - var i = 0; - var addedContourInCurrentRound = false; - while (finishedContourCount < contourCount) { - if (AddContour (vertices, i)) { - finishedContourCount += 1; - addedContourInCurrentRound = true; - } - if (i < contourCount - 1) { - i = i + 1; - } else { - i = 0; - if (!addedContourInCurrentRound) { - break; - } - addedContourInCurrentRound = false; - } - } - - return resultIndices; -}; - -/** -* Function: CreatePolygonWithHole -* Description: -* Creates a simple polygon from multiple contours by creating in-out edges between -* contours. The input array should contain null values at contour ends. -* Parameters: -* vertices {Coord[*]} array of contour vertices with null values at contour ends -* Returns: -* {int[*]} the result -*/ -JSM.CreatePolygonWithHole = function (vertices) -{ - var noNullVertices = []; - var i; - for (i = 0; i < vertices.length; i++) { - if (vertices[i] !== null) { - noNullVertices.push (vertices[i]); - } - } - - var normal = JSM.CalculateNormal (noNullVertices); - var vertices2D = []; - var vertex; - for (i = 0; i < vertices.length; i++) { - if (vertices[i] !== null) { - vertex = vertices[i].ToCoord2D (normal); - vertices2D.push (vertex); - } else { - vertices2D.push (null); - } - } - - return JSM.CreatePolygonWithHole2D (vertices2D); -}; diff --git a/src/geometry/polygon.js b/src/geometry/polygon.js index 7f796a16..c900a34c 100644 --- a/src/geometry/polygon.js +++ b/src/geometry/polygon.js @@ -225,11 +225,16 @@ JSM.ContourPolygon.prototype.GetNormal = function () JSM.ContourPolygon.prototype.ToContourPolygon2D = function () { + var normal = this.contours[0].GetNormal (); var result = new JSM.ContourPolygon2D (); - var i, contour; + var i, j, contour, vertex; for (i = 0; i < this.contours.length; i++) { + result.AddContour (); contour = this.contours[i]; - result.AddContour (contour.ToPolygon2D ()); + for (j = 0; j < contour.VertexCount (); j++) { + vertex = contour.GetVertex (j); + result.AddVertexCoord (vertex.ToCoord2D (normal)); + } } return result; }; diff --git a/src/modeler/generator.js b/src/modeler/generator.js index 53459d0f..49a05f4c 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -890,76 +890,66 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd } } - function AddContours (contourPolygon, result) + function AddContours (contourPolygon, contourOffsets, result) { var offset = 0; var i, j, contour, vertexCount, current, next; for (i = 0; i < contourPolygon.ContourCount (); i++) { contour = contourPolygon.GetContour (i); vertexCount = contour.VertexCount (); + contourOffsets.push (offset); for (j = 0; j < vertexCount; j++) { - current = offset + 2 * j; + current = 2 * offset + 2 * j; next = current + 2; if (j == vertexCount - 1) { - next = offset; + next = 2 * offset; } result.AddPolygon (new JSM.BodyPolygon ([current, next, next + 1, current + 1])); } - offset += 2 * vertexCount; + offset += vertexCount; } } - function GetVertexMap () + function AddTopBottomPolygons (contourPolygon, contourOffsets) { - var contourCount = 0; var vertexMap = []; - - var i; - for (i = 0; i < basePolygon.length; i++) { - if (basePolygon[i] === null) { - contourCount = contourCount + 1; - } - vertexMap.push (i - contourCount); + var contourPolygon2D = contourPolygon.ToContourPolygon2D (); + var simplePolygon = JSM.ConvertContourPolygonToPolygon2D (contourPolygon2D, vertexMap); + if (simplePolygon === null) { + return; } - return vertexMap; - } - - function AddTopBottomPolygons () - { - var vertexMap = GetVertexMap (); - - var polygonIndices = JSM.CreatePolygonWithHole (basePolygon); - var polygon = new JSM.Polygon (); - var i, j, vertex; - for (i = 0; i < polygonIndices.length; i++) { - vertex = basePolygon[polygonIndices[i]]; - polygon.AddVertex (vertex.x, vertex.y, vertex.z); + + var triangles = JSM.TriangulatePolygon2D (simplePolygon); + if (triangles === null) { + return; } - var triangles = JSM.TriangulatePolygon (polygon); - if (triangles !== null) { - var triangle, topTriangle, bottomTriangle; - for (i = 0; i < triangles.length; i++) { - triangle = triangles[i]; - topTriangle = new JSM.BodyPolygon ([]); - bottomTriangle = new JSM.BodyPolygon ([]); - for (j = 0; j < 3; j++) { - topTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[j]]] + 1); - bottomTriangle.AddVertexIndex (2 * vertexMap[polygonIndices[triangle[3 - j - 1]]]); - } - result.AddPolygon (topTriangle); - result.AddPolygon (bottomTriangle); + + var i, j, triangle, mapValue; + var topTriangle, bottomTriangle; + for (i = 0; i < triangles.length; i++) { + triangle = triangles[i]; + topTriangle = new JSM.BodyPolygon ([]); + bottomTriangle = new JSM.BodyPolygon ([]); + for (j = 0; j < 3; j++) { + mapValue = vertexMap[triangle[j]]; + topTriangle.AddVertexIndex (2 * contourOffsets[mapValue[0]] + 2 * mapValue[1] + 1); + mapValue = vertexMap[triangle[2 - j]]; + bottomTriangle.AddVertexIndex (2 * contourOffsets[mapValue[0]] + 2 * mapValue[1]); } + result.AddPolygon (topTriangle); + result.AddPolygon (bottomTriangle); } } var result = new JSM.Body (); + var contourOffsets = []; var contourPolygon = new JSM.ContourPolygon (); contourPolygon.FromArray (basePolygon); AddVertices (contourPolygon, direction, height, result); - AddContours (contourPolygon, result); + AddContours (contourPolygon, contourOffsets, result); if (withTopAndBottom) { - AddTopBottomPolygons (); + AddTopBottomPolygons (contourPolygon, contourOffsets); } var firstDirection = JSM.CoordSub (basePolygon[1], basePolygon[0]).Normalize (); diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index 2b814040..add9208b 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -26,7 +26,6 @@ unitTest.AddSourceFile ('../../src/geometry/polygon2d.js'); unitTest.AddSourceFile ('../../src/geometry/polygon.js'); unitTest.AddSourceFile ('../../src/geometry/triangulation.js'); unitTest.AddSourceFile ('../../src/geometry/oldpolygon.js'); -unitTest.AddSourceFile ('../../src/geometry/oldpolygonutils.js'); unitTest.AddSourceFile ('../../src/geometry/octree.js'); unitTest.AddSourceFile ('../../src/geometry/bsptree.js'); unitTest.AddSourceFile ('../../src/geometry/utilities.js'); diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index 20864db1..6d925539 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -1273,6 +1273,78 @@ polygonSuite.AddTest ('TwoHolesTriangulationTest04', function (test) test.Assert (CheckCalculatedTriangulation_Orientation (simple, triangles)); }); + +polygonSuite.AddTest ('ThreeHolesTriangulationTest2D', function (test) +{ + var polygon = new JSM.ContourPolygon2D (); + polygon.AddContour (); + polygon.AddVertex (0, 0); + polygon.AddVertex (7, 0); + polygon.AddVertex (7, 3); + polygon.AddVertex (0, 3); + polygon.AddContour (); + polygon.AddVertex (1, 1); + polygon.AddVertex (1, 2); + polygon.AddVertex (2, 2); + polygon.AddContour (); + polygon.AddVertex (3, 1); + polygon.AddVertex (3, 2); + polygon.AddVertex (4, 2); + polygon.AddVertex (4, 1); + polygon.AddContour (); + polygon.AddVertex (5, 1); + polygon.AddVertex (5, 2); + polygon.AddVertex (6, 2); + polygon.AddVertex (6, 1); + polygon.AddVertex (5.5, 1.5); + + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + + var triangles = JSM.TriangulatePolygon2D (simple); + test.Assert (CheckCalculatedTriangulation (simple, triangles)); +}); + +polygonSuite.AddTest ('ThreeHolesTriangulationTest', function (test) +{ + var polygon3D = new JSM.ContourPolygon (); + polygon3D.AddContour (); + polygon3D.AddVertex (0, 0, 0); + polygon3D.AddVertex (7, 0, 0); + polygon3D.AddVertex (7, 3, 0); + polygon3D.AddVertex (0, 3, 0); + polygon3D.AddContour (); + polygon3D.AddVertex (1, 1, 0); + polygon3D.AddVertex (1, 2, 0); + polygon3D.AddVertex (2, 2, 0); + polygon3D.AddContour (); + polygon3D.AddVertex (3, 1, 0); + polygon3D.AddVertex (3, 2, 0); + polygon3D.AddVertex (4, 2, 0); + polygon3D.AddVertex (4, 1, 0); + polygon3D.AddContour (); + polygon3D.AddVertex (5, 1, 0); + polygon3D.AddVertex (5, 2, 0); + polygon3D.AddVertex (6, 2, 0); + polygon3D.AddVertex (6, 1, 0); + polygon3D.AddVertex (5.5, 1.5, 0); + + var polygon = polygon3D.ToContourPolygon2D (); + var simple = JSM.ConvertContourPolygonToPolygon2D (polygon); + test.AssertEqual (polygon.GetSignedArea (), simple.GetSignedArea ()); + test.AssertEqual (polygon.GetArea (), simple.GetArea ()); + test.AssertEqual (polygon.GetOrientation (), simple.GetOrientation ()); + test.AssertEqual (polygon.GetComplexity (), JSM.Complexity.Complex); + test.AssertEqual (simple.GetComplexity (), JSM.Complexity.Concave); + + var triangles = JSM.TriangulatePolygon2D (simple); + test.Assert (CheckCalculatedTriangulation (simple, triangles)); +}); + var generatedSuite = unitTest.AddTestSuite ('GeneratedTriangulationTest'); generatedSuite.AddTest ('Test01', function (test) { diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index b9d2946d..946d2881 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index 1dc875e4..dac179c3 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index cf66ff26..17ff4cb5 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index b11e7503..d7300178 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index 8bb60174..bda5d422 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 053aba75..696e4f5d 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -34,7 +34,6 @@ - diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index 2d8a4d9b..d37bf330 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -34,7 +34,6 @@ - diff --git a/tools/files.txt b/tools/files.txt index 50a1f7fb..ebc0334a 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -22,7 +22,6 @@ ../src/geometry/polygon.js ../src/geometry/triangulation.js ../src/geometry/oldpolygon.js -../src/geometry/oldpolygonutils.js ../src/geometry/octree.js ../src/geometry/bsptree.js ../src/geometry/utilities.js From e76910d354a8f53ee95f3ca49b730c7f80f947a5 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 3 Aug 2015 18:06:32 +0200 Subject: [PATCH 23/27] Completely remove old polygon. --- build/jsmodeler.js | 385 ++++++++++--------- documentation/jsmdoc/include/jsmdoc.json | 452 ++++++++++++++++++++--- projects/jsmodeler_npp | 14 +- sandbox/3dsdump.html | 1 - sandbox/bezier.html | 1 - sandbox/beziercurve.html | 1 - sandbox/bspline.html | 1 - sandbox/charts.html | 1 - sandbox/convexhull.html | 1 - sandbox/coplanar.html | 1 - sandbox/csg.html | 1 - sandbox/csg2.html | 1 - sandbox/curvedprism.html | 1 - sandbox/docimages.html | 1 - sandbox/doublesided.html | 1 - sandbox/githublogo.html | 1 - sandbox/heightmap.html | 1 - sandbox/hiddenline.html | 1 - sandbox/importer.html | 1 - sandbox/jsonimport.html | 1 - sandbox/jsonimporttexture.html | 1 - sandbox/minimal.html | 1 - sandbox/minimal2.html | 1 - sandbox/octree.html | 1 - sandbox/pointcloud.html | 1 - sandbox/pointcloudjson.html | 1 - sandbox/print.html | 1 - sandbox/prismwithhole.html | 1 - sandbox/randommat.html | 1 - sandbox/renderer.html | 1 - sandbox/revolved.html | 1 - sandbox/smartbuilder.html | 1 - sandbox/smartbuilder2.html | 1 - sandbox/solids.html | 1 - sandbox/specular.html | 1 - sandbox/svgonthefly.html | 1 - sandbox/svgtomodel.html | 1 - sandbox/svgtomodel2.html | 1 - sandbox/svgtomodeltexture.html | 1 - sandbox/tasks.html | 1 - sandbox/texture.html | 1 - sandbox/tictactoecanvas.html | 1 - sandbox/triangulate.html | 1 - sandbox/triangulation/polygoneditor.html | 1 - sandbox/tube.html | 1 - sandbox/undermouse.html | 1 - sandbox/viewer.html | 1 - src/extras/svgtomodel.js | 71 ++-- src/geometry/oldpolygon.js | 126 ------- src/geometry/polygon.js | 140 ++++++- src/geometry/polygon2d.js | 444 +++++++++++++++++++--- src/geometry/sector.js | 91 ----- src/geometry/triangulation.js | 2 +- test/unittest/jsmodelertest.js | 1 - test/unittest/tests/geometry.js | 168 ++++----- test/unittest/tests/polygon.js | 106 +++--- test/unittest/tests/triangulation.js | 30 +- test/viewertest/cameratest.html | 1 - test/viewertest/csgtest.html | 1 - test/viewertest/importtest.html | 1 - test/viewertest/svgtomodeltest.html | 1 - test/viewertest/texturetest.html | 1 - test/viewertest/viewertest.html | 1 - test/viewertest/viewertypes.html | 1 - tools/files.txt | 1 - 65 files changed, 1312 insertions(+), 770 deletions(-) delete mode 100644 src/geometry/oldpolygon.js diff --git a/build/jsmodeler.js b/build/jsmodeler.js index 357150fc..af320803 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -13,49 +13,45 @@ JSM.Coord2D.prototype.Clone=function(){return new JSM.Coord2D(this.x,this.y)};JS JSM.Coord.prototype.IsEqual=function(a){return JSM.IsEqual(this.x,a.x)&&JSM.IsEqual(this.y,a.y)&&JSM.IsEqual(this.z,a.z)};JSM.Coord.prototype.IsEqualWithEps=function(a,b){return JSM.IsEqualWithEps(this.x,a.x,b)&&JSM.IsEqualWithEps(this.y,a.y,b)&&JSM.IsEqualWithEps(this.z,a.z,b)};JSM.Coord.prototype.DistanceTo=function(a){return Math.sqrt((a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y)+(a.z-this.z)*(a.z-this.z))}; JSM.Coord.prototype.AngleTo=function(a){var b=this.Clone().Normalize();a=a.Clone().Normalize();if(b.IsEqual(a))return 0;b=JSM.VectorDot(b,a);return JSM.ArcCos(b)};JSM.Coord.prototype.IsCollinearWith=function(a){a=this.AngleTo(a);return JSM.IsEqual(a,0)||JSM.IsEqual(a,Math.PI)};JSM.Coord.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};JSM.Coord.prototype.MultiplyScalar=function(a){this.x*=a;this.y*=a;this.z*=a;return this}; JSM.Coord.prototype.Normalize=function(){var a=this.Length();JSM.IsPositive(a)&&this.MultiplyScalar(1/a);return this};JSM.Coord.prototype.SetLength=function(a){var b=this.Length();JSM.IsPositive(b)&&this.MultiplyScalar(a/b);return this};JSM.Coord.prototype.Offset=function(a,b){var c=a.Clone().Normalize();this.x+=c.x*b;this.y+=c.y*b;this.z+=c.z*b;return this}; -JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,l=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*l;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*l;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*l;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this}; +JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,k=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*k;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*k;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*k;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this}; JSM.Coord.prototype.ToCoord2D=function(a){var b=new JSM.Coord(0,0,0),c=new JSM.Vector(0,0,1),d=JSM.VectorCross(a,c);a=a.AngleTo(c);b=this.Clone().Rotate(d,a,b);return new JSM.Coord2D(b.x,b.y)};JSM.Coord.prototype.ToString=function(){return"("+this.x+", "+this.y+", "+this.z+")"};JSM.Coord.prototype.Clone=function(){return new JSM.Coord(this.x,this.y,this.z)};JSM.Vector=JSM.Coord;JSM.CoordFromArray=function(a){return new JSM.Coord(a[0],a[1],a[2])};JSM.CoordToArray=function(a){return[a.x,a.y,a.z]}; JSM.CoordAdd=function(a,b){return new JSM.Coord(a.x+b.x,a.y+b.y,a.z+b.z)};JSM.CoordSub=function(a,b){return new JSM.Coord(a.x-b.x,a.y-b.y,a.z-b.z)};JSM.VectorDot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};JSM.VectorCross=function(a,b){var c=new JSM.Vector(0,0,0);c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};JSM.MatrixDeterminant2x2=function(a,b,c,d){return a*d-b*c}; -JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,l){var k=JSM.MatrixDeterminant2x2(e,f,g,l);f=JSM.MatrixDeterminant2x2(d,f,h,l);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*k-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,l,k,m,n,p,q,t,r){var u=JSM.MatrixDeterminant3x3(f,h,g,k,m,n,q,t,r),v=JSM.MatrixDeterminant3x3(e,h,g,l,m,n,p,t,r);g=JSM.MatrixDeterminant3x3(e,f,g,l,k,n,p,q,r);e=JSM.MatrixDeterminant3x3(e,f,h,l,k,m,p,q,t);return u*a-v*b+g*c-e*d}; +JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,k){var l=JSM.MatrixDeterminant2x2(e,f,g,k);f=JSM.MatrixDeterminant2x2(d,f,h,k);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*l-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,k,l,m,n,p,q,t,r){var u=JSM.MatrixDeterminant3x3(f,h,g,l,m,n,q,t,r),v=JSM.MatrixDeterminant3x3(e,h,g,k,m,n,p,t,r);g=JSM.MatrixDeterminant3x3(e,f,g,k,l,n,p,q,r);e=JSM.MatrixDeterminant3x3(e,f,h,k,l,m,p,q,t);return u*a-v*b+g*c-e*d}; JSM.Orientation={Invalid:0,CounterClockwise:1,Clockwise:2};JSM.MidCoord2D=function(a,b){return new JSM.Coord2D((a.x+b.x)/2,(a.y+b.y)/2)};JSM.CoordOrientation2D=function(a,b,c){var d=a.x;a=a.y;var e=b.x;b=b.y;var f=c.x;c=c.y;d=d*b+a*f+e*c-b*f-a*e-d*c;return JSM.IsPositive(d)?JSM.Orientation.CounterClockwise:JSM.IsNegative(d)?JSM.Orientation.Clockwise:JSM.Orientation.Invalid};JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c}; JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a};JSM.MidCoord=function(a,b){return new JSM.Coord((a.x+b.x)/2,(a.y+b.y)/2,(a.z+b.z)/2)};JSM.CoordSignedDistance=function(a,b,c){var d=JSM.CoordSub(b,a);a=a.DistanceTo(b);c=d.AngleTo(c);JSM.IsPositive(c)&&(a=-a);return a};JSM.GetVectorsFullAngle=function(a,b,c){var d=a.AngleTo(b),e=new JSM.Coord(0,0,0);JSM.CoordOrientation(a,e,b,c)==JSM.Orientation.Clockwise&&(d=2*Math.PI-d);return d}; JSM.CoordOrientation=function(a,b,c,d){a=a.ToCoord2D(d);b=b.ToCoord2D(d);c=c.ToCoord2D(d);c=JSM.CoordOrientation2D(a,b,c);a=new JSM.Vector(0,0,1);d=d.AngleTo(a);JSM.IsEqual(d,Math.PI)&&(c==JSM.Orientation.CounterClockwise?c=JSM.Orientation.Clockwise:c==JSM.Orientation.Clockwise&&(c=JSM.Orientation.CounterClockwise));return c};JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d}; JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return a.AngleTo(b)*c};JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c};JSM.CalculateCentroid=function(a){var b=a.length,c=new JSM.Coord(0,0,0);if(1<=b){var d;for(d=0;da?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.BarycentricInterpolation=function(a,b,c,d,e,f,h){function g(a,b,c){var d=(a+b+c)/2;a=d*(d-a)*(d-b)*(d-c);return 0>a?0:Math.sqrt(a)}var k=a.DistanceTo(b),l=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(k,l,m);if(JSM.IsZero(c))return d;k=g(k,a,b);l=g(l,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(l);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(k);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],r=a[13],u=a[14],v=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*k+e*p+f*r;s[2]=c*g+d*m+e*q+f*u;s[3]=c*l+d*n+e*t+f*v;return s}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],r=a[13],u=a[14],v=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],E=b[5],A=b[6],K=b[7],L=b[8],H=b[9],B=b[10],D=b[11],N=b[12],O=b[13],J=b[14],I=b[15],F=[];F[0]=c*s+d*x+e*L+f*N;F[1]=c*w+d*E+e*H+f*O;F[2]=c*y+d*A+e*B+f*J;F[3]=c*z+d*K+e*D+f*I;F[4]=h*s+g*x+l*L+k*N;F[5]=h*w+g*E+l*H+k*O;F[6]=h*y+g*A+l*B+k*J;F[7]=h*z+g*K+l*D+k*I;F[8]=m*s+n*x+p*L+q*N;F[9]=m*w+n*E+p*H+q*O;F[10]=m*y+n*A+ -p*B+q*J;F[11]=m*z+n*K+p*D+q*I;F[12]=t*s+r*x+u*L+v*N;F[13]=t*w+r*E+u*H+v*O;F[14]=t*y+r*A+u*B+v*J;F[15]=t*z+r*K+u*D+v*I;return F};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];return(b*h-c*f)*(n*a-p*r)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*r-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*r-n*q)+(d*l-e*g)*(k*t-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,s=b*l-e*f,w=c*g-d*h,y=c*l-e*h,z=d*l-e*g,x=k*t-m*q,E=k*r-n*q,A=k*a-p*q,K=m*r-n*t,L=m*a-p*t,H=n*a-p*r,B=u*H-v*L+s*K+w*A-y*E+z*x;if(JSM.IsZero(B))return null;var D=[];D[0]=(h*H-g*L+l*K)/B;D[1]=(d*L-c*H-e*K)/B;D[2]=(t*z-r*y+a*w)/B;D[3]=(n*y-m*z-p*w)/B;D[4]=(g*A-f*H-l*E)/B;D[5]=(b*H-d*A+e*E)/B;D[6]=(r*s-q*z-a*v)/B;D[7]=(k*z-n*s+p* -v)/B;D[8]=(f*L-h*A+l*x)/B;D[9]=(c*A-b*L-e*x)/B;D[10]=(q*y-t*s+a*u)/B;D[11]=(m*s-k*y-p*u)/B;D[12]=(h*E-f*K-g*x)/B;D[13]=(b*K-c*E+d*x)/B;D[14]=(t*v-q*w-r*u)/B;D[15]=(k*w-m*v+n*u)/B;return D};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- -b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],k=a[3],l=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],r=a[13],u=a[14],v=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*l+e*p+f*r;s[2]=c*g+d*m+e*q+f*u;s[3]=c*k+d*n+e*t+f*v;return s}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],k=a[6],l=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],r=a[13],u=a[14],v=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],D=b[5],H=b[6],K=b[7],L=b[8],G=b[9],A=b[10],C=b[11],N=b[12],O=b[13],J=b[14],I=b[15],E=[];E[0]=c*s+d*x+e*L+f*N;E[1]=c*w+d*D+e*G+f*O;E[2]=c*y+d*H+e*A+f*J;E[3]=c*z+d*K+e*C+f*I;E[4]=h*s+g*x+k*L+l*N;E[5]=h*w+g*D+k*G+l*O;E[6]=h*y+g*H+k*A+l*J;E[7]=h*z+g*K+k*C+l*I;E[8]=m*s+n*x+p*L+q*N;E[9]=m*w+n*D+p*G+q*O;E[10]=m*y+n*H+ +p*A+q*J;E[11]=m*z+n*K+p*C+q*I;E[12]=t*s+r*x+u*L+v*N;E[13]=t*w+r*D+u*G+v*O;E[14]=t*y+r*H+u*A+v*J;E[15]=t*z+r*K+u*C+v*I;return E};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],k=a[7],l=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];return(b*h-c*f)*(n*a-p*r)-(b*g-d*f)*(m*a-p*t)+(b*k-e*f)*(m*r-n*t)+(c*g-d*h)*(l*a-p*q)-(c*k-e*h)*(l*r-n*q)+(d*k-e*g)*(l*t-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],k=a[7],l=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,s=b*k-e*f,w=c*g-d*h,y=c*k-e*h,z=d*k-e*g,x=l*t-m*q,D=l*r-n*q,H=l*a-p*q,K=m*r-n*t,L=m*a-p*t,G=n*a-p*r,A=u*G-v*L+s*K+w*H-y*D+z*x;if(JSM.IsZero(A))return null;var C=[];C[0]=(h*G-g*L+k*K)/A;C[1]=(d*L-c*G-e*K)/A;C[2]=(t*z-r*y+a*w)/A;C[3]=(n*y-m*z-p*w)/A;C[4]=(g*H-f*G-k*D)/A;C[5]=(b*G-d*H+e*D)/A;C[6]=(r*s-q*z-a*v)/A;C[7]=(l*z-n*s+p* +v)/A;C[8]=(f*L-h*H+k*x)/A;C[9]=(c*H-b*L-e*x)/A;C[10]=(q*y-t*s+a*u)/A;C[11]=(m*s-l*y-p*u)/A;C[12]=(h*D-f*K-g*x)/A;C[13]=(b*K-c*D+d*x)/A;C[14]=(t*v-q*w-r*u)/A;C[15]=(l*w-m*v+n*u)/A;return C};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,k=Math.sin(b);b=Math.cos(b);var l=[];if(void 0===c||null===c)l[0]=f+(h+g)*b,l[1]=a*e*(1-b)+d*k,l[2]=a*d*(1-b)-e*k,l[3]=0,l[4]=a*e*(1-b)-d*k,l[5]=h+(f+g)*b,l[6]=e*d*(1-b)+a*k,l[7]=0,l[8]=a*d*(1-b)+e*k,l[9]=e*d*(1-b)-a*k,l[10]=g+(f+h)*b,l[11]=0,l[12]=0,l[13]=0,l[14]=0;else{var m=c.x,n=c.y;c=c.z;l[0]=f+(h+g)*b;l[1]=a*e*(1-b)+d*k;l[2]=a*d*(1-b)-e*k;l[3]=0;l[4]=a*e*(1-b)-d*k;l[5]=h+(f+g)*b;l[6]=e*d*(1- +b)+a*k;l[7]=0;l[8]=a*d*(1-b)+e*k;l[9]=e*d*(1-b)-a*k;l[10]=g+(f+h)*b;l[11]=0;l[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*k;l[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*k;l[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*k}l[15]=1;return l}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var k=b*h,b=b*g,l=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(l+d);g[1]=k+e;g[2]=b-h;g[3]=0;g[4]=k-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+l);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; JSM.CoordSystem.prototype.Set=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d};JSM.CoordSystem.prototype.ToDirectionVectors=function(){this.e1=JSM.CoordSub(this.e1,this.origo);this.e2=JSM.CoordSub(this.e2,this.origo);this.e3=JSM.CoordSub(this.e3,this.origo);return this};JSM.CoordSystem.prototype.ToAbsoluteCoords=function(){this.e1=JSM.CoordAdd(this.e1,this.origo);this.e2=JSM.CoordAdd(this.e2,this.origo);this.e3=JSM.CoordAdd(this.e3,this.origo);return this}; -JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.OldSectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3}; -JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; +JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo.Clone(),this.e1.Clone(),this.e2.Clone(),this.e3.Clone())};JSM.CoordSectorPosition2D={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2};JSM.SectorSectorPosition2D={SectorsDontIntersect:0,SectorsIntersectCoincident:1,SectorsIntersectEndPoint:2,SectorsIntersectOnePoint:3};JSM.CoordSectorPosition={CoordInsideOfSector:0,CoordOnSectorEndCoord:1,CoordOutsideOfSector:2}; +JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; -JSM.Sector2D.prototype.OldSectorPosition=function(a,b){var c=this.beg.x,d=this.beg.y,e=this.end.x,f=this.end.y,h=a.beg.x,g=a.beg.y,l=a.end.x,k=a.end.y,m=(l-h)*(d-g)-(k-g)*(c-h),n=(e-c)*(d-g)-(f-d)*(c-h);if(JSM.IsZero(m)&&JSM.IsZero(n))return c=a.CoordPosition(this.beg),d=a.CoordPosition(this.end),e=this.CoordPosition(a.beg),f=this.CoordPosition(a.end),c===JSM.CoordSectorPosition2D.CoordInsideOfSector||(d===JSM.CoordSectorPosition2D.CoordInsideOfSector||e===JSM.CoordSectorPosition2D.CoordInsideOfSector|| -f===JSM.CoordSectorPosition2D.CoordInsideOfSector)||c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident:c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord||f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord? -(void 0!==b&&(c===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.beg.Clone():d===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?this.end.Clone():e===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord?a.beg.Clone():f===JSM.CoordSectorPosition2D.CoordOnSectorEndCoord&&a.end.Clone()),JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint):JSM.OldSectorSectorPosition2D.SectorsDontIntersect;h=(k-g)*(e-c)-(l-h)*(f-d);if(JSM.IsZero(h))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;m/=h;n/= -h;if(JSM.IsLower(m,0)||JSM.IsGreater(m,1)||JSM.IsLower(n,0)||JSM.IsGreater(n,1))return JSM.OldSectorSectorPosition2D.SectorsDontIntersect;void 0!==b&&(b.x=c+m*(e-c),b.y=d+m*(f-d));return JSM.IsEqual(m,0)||JSM.IsEqual(m,1)||JSM.IsEqual(n,0)||JSM.IsEqual(n,1)?JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint:JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, -q=f.y,t=h.x,r=h.y,u=g.x,v=g.y,s=(u-t)*(n-r)-(v-r)*(m-t),w=(p-m)*(n-r)-(q-n)*(m-t),t=(v-r)*(p-m)-(u-t)*(q-n);if(JSM.IsZero(t)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/t;w/=t;if(JSM.IsLower(h, -0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,k=e.IsEqual(h)||e.IsEqual(g),l=f.IsEqual(h)||f.IsEqual(g);if(k&&l)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, +q=f.y,t=h.x,r=h.y,u=g.x,v=g.y,s=(u-t)*(n-r)-(v-r)*(m-t),w=(p-m)*(n-r)-(q-n)*(m-t),t=(v-r)*(p-m)-(u-t)*(q-n);if(JSM.IsZero(t)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(k)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(l)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/t;w/=t;if(JSM.IsLower(h, +0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(k)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(l)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,k=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(k))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/k;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: +JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,k=e.z,l=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(l-h)*(l-h)+(m-g)*(m-g)+(n-k)*(n-k);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((l-h)*(b-h)+(m-g)*(c-g)+(n-k)*(d-k))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,h,g;for(h=0;h<=b;h++)g=a.beg.Clone().Offset(d,f),c.push(g),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; JSM.CoordLinePosition={CoordOnLine:0,CoordOutsideOfLine:1};JSM.LineLinePosition={LinesDontIntersect:0,LinesIntersectsOnePoint:1,LinesIntersectsCoincident:2};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; JSM.Line2D.prototype.CoordPosition=function(a){var b=this.start,c=this.direction;a=c.x*(a.y-b.y)-c.y*(a.x-b.x);return JSM.IsPositive(a)?JSM.CoordLinePosition2D.CoordAtLineLeft:JSM.IsNegative(a)?JSM.CoordLinePosition2D.CoordAtLineRight:JSM.CoordLinePosition2D.CoordOnLine};JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b}; -JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: -JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-h)*(k-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; -JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,g),k=[f,h,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),h=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= +JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,k=f.y,l=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-k)*(n-k)+(p-l)*(p-l);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-k)*(d-k)+(p-l)*(e-l))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: +JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,k=a.x+e.x,l=a.y+e.y,m=a.z+e.z,n=(k-f)*(k-f)+(l-h)*(l-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((k-f)*(b-f)+(l-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; +JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var k=JSM.CoordAdd(a,g),l=[f,h,a,k],m=d(l,1,0,1,0),n=d(l,0,2,1,0),h=d(l,0,2,3,2),k=d(l,3,2,1,0),l=d(l,3,2,3,2),m=m*l-k*k;if(JSM.IsEqual(m,0))return!1;n=(h*k-n*l)/m;h=(h+n*k)/l;void 0!==b&&(e.MultiplyScalar(n),e= JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(g.MultiplyScalar(h),b=JSM.CoordAdd(a,g),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b}; JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)};JSM.Box.prototype.IsCoordInside=function(a){return JSM.IsLower(a.x,this.min.x)||JSM.IsLower(a.y,this.min.y)||JSM.IsLower(a.z,this.min.z)||JSM.IsGreater(a.x,this.max.x)||JSM.IsGreater(a.y,this.max.y)||JSM.IsGreater(a.z,this.max.z)?!1:!0};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())}; @@ -67,34 +63,35 @@ JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0=== JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.CoordPlanePosition={CoordOnPlane:0,CoordInFrontOfPlane:1,CoordAtBackOfPlane:2};JSM.LinePlanePosition={LineParallelToPlane:0,LineIntersectsPlane:1};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d}; JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)};JSM.Plane.prototype.CoordSignedDistance=function(a){var b=this.a,c=this.b,d=this.c;return(b*a.x+c*a.y+d*a.z+this.d)/Math.sqrt(b*b+c*c+d*d)};JSM.Plane.prototype.CoordDistance=function(a){a=this.CoordSignedDistance(a);return Math.abs(a)}; -JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; -JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,l=this.c,k=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; -JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+h*d+g*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; +JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,k=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(k=-k);b=this.GetNormal().Normalize();return a.Clone().Offset(b,k)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; +JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,k=this.c,l=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+k*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+k*f+l)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; +JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,k=this.d,l=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(l))return null;b.MultiplyScalar((f*c+h*d+g*e+k)/l);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; -JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((h*b+g*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; -JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; +JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,k=c.c;c=c.d;var l=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+k*(f-(a.z+d.z));if(JSM.IsZero(l))return 0;d.MultiplyScalar((h*b+g*e+k*f+c)/l);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+k*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; +JSM.Project=function(a,b,c,d,e,f,h,g,k){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?k=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*k[2]+k[0],f[1]=f[1]*k[3]+k[1],e.x=f[0],e.y=f[1],e.z=f[2],k=e);return k}; JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qa)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;ce)return d;var f,h,g,l,k;for(f=0;fa)return JSM.Complexity.Invalid;var b=JSM.Complexity.Invalid;if(this.GetOrientation()!=JSM.Orientation.Invalid){var b=JSM.Complexity.Convex,c;for(c=0;ce)return d;var f,h,g,k,l;for(f=0;fb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; -JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)};JSM.OldContourPolygon2D=function(){this.polygons=[]}; -JSM.OldContourPolygon2D.prototype.AddVertex=function(a,b,c){void 0===this.polygons[a]&&(this.polygons[a]=new JSM.Polygon2D);this.polygons[a].AddVertex(b,c)};JSM.OldContourPolygon2D.prototype.VertexCount=function(a){return void 0===this.polygons[a]?0:this.polygons[a].VertexCount()};JSM.OldContourPolygon2D.prototype.GetVertex=function(a,b){return this.polygons[a].GetVertex(b)};JSM.OldContourPolygon2D.prototype.SetVertex=function(a,b,c,d){this.polygons[a].SetVertex(b,c,d)}; -JSM.OldContourPolygon2D.prototype.AddContour=function(){this.polygons.push(new JSM.Polygon2D)};JSM.OldContourPolygon2D.prototype.ContourCount=function(){return this.polygons.length};JSM.OldContourPolygon2D.prototype.GetContour=function(a){return this.polygons[a]};JSM.OldContourPolygon2D.prototype.Clear=function(){this.polygons=[]};JSM.OldContourPolygon2D.prototype.Clone=function(){var a=new JSM.OldContourPolygon2D,b;for(b=0;bb)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)}; JSM.TraverseOctreeNodes=function(a,b){function c(a,b){if(b(a)&&null!==a.children){var f,h;for(f=0;f=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, @@ -134,10 +129,10 @@ JSM.BSPTree.prototype.GetNodes=function(){var a=[];this.Traverse(function(b){a.p JSM.BSPTree.prototype.AddPolygonToNode=function(a,b,c){if(3>b.VertexCount())return!1;var d;if(null===a.polygon){d=b.GetNormal();var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0k;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +JSM.CalculateCubicTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e1.Clone().Normalize(),f=c.e2.Clone().Normalize(),h=c.e3.Clone().Normalize(),g=-1,k=0,l,m,n;for(l=0;3>l;l++)0===l?m=e:1===l?m=f:2===l&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,k)&&(g=l,k=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var h=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fg;g++)r=c[h[g]],u.AddVertexIndex(2*b[r[0]]+2*r[1]+1),r=c[h[2-g]],v.AddVertexIndex(2*b[r[0]]+2*r[1]);f.AddPolygon(u);f.AddPolygon(v)}}}var f=new JSM.Body,h=[],g=new JSM.ContourPolygon;g.FromArray(a);(function(a, b,c,d){var e,f,g,h,u;for(e=0;ew)){var H=void 0,B=void 0,D=void 0,N=void 0,O=void 0,J=void 0,I=void 0,F=void 0,Q=void 0,G=void 0;if(3==w||k)for(G=0;Gw)){var G=void 0,A=void 0,C=void 0,N=void 0,O=void 0,J=void 0,I=void 0,E=void 0,Q=void 0,F=void 0;if(3==w||l)for(F=0;Ff)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +JSM.TriangleBody.prototype.Finalize=function(a){function b(b,c,d,f){function h(a,b,c,d,e){var f=new JSM.Vector(0,0,0),g=0;c=a.GetTriangle(c);b=e[b];var k,l;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= -new JSM.Polygon;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),l=h.GetVertexIndex(2),b(c,h,f,g,l);else{k= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;ak;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; -var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; -JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;cl;l++)JSM.IsLower(f[l],b[l])?(h[l]=-1,g[l]=b[l],k=!1):JSM.IsGreater(f[l],c[l])?(h[l]=1,g[l]=c[l],k=!1):h[l]=0;l=null;if(k)return l={position:d,distance:0};k=[0,0,0];for(l=0;3>l;l++)0!==h[l]&&!JSM.IsZero(e[l])?k[l]=(g[l]-f[l])/e[l]:k[l]=-1;h=0;for(l=1;3>l;l++)JSM.IsLower(k[h],k[l])&&(h=l);if(JSM.IsNegative(k[h]))return null; +var m=[0,0,0];for(l=0;3>l;l++)if(h!=l){if(m[l]=f[l]+k[h]*e[l],JSM.IsLower(m[l],b[l])||JSM.IsGreater(m[l],c[l]))return null}else m[l]=g[l];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:l={position:f,distance:d}}; +JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -289,39 +284,39 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,l,k,m,n,p,q,t,r,u,v,s,w,y,z,x,E,A,K,L,H,B,D,N,O,J,I,F,Q,G,M,T,S,U,Y;function C(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;r=41472;u=41728;v=41816;s=41818;w=41812;y=41814;z=41820;x=48;E=49;A=16384;K=16640;L=17920;H=18176;B=16656;D=16704;N=16672;O=16736;J=16688;I=16720;F=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ -255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==E?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){C("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(C("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(C("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==h?(C("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(C("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(C("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(C("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(C("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= -W(a,b,p)):b==r?(C("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(C("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){C("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,l;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else C("Skip chunk ("+c.toString(16)+", "+d+")",4), -a.Skip(d-6)})}function ca(a,b,c){C("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?C("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?C("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):C("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){C("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==A?ca(a,b,c):(C("Skip chunk ("+ -b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dd;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;k=41024;l=41025;m=41040;n=16;p=17;q=18;t=19;r=41472;u=41728;v=41816;s=41818;w=41812;y=41814;z=41820;x=48;D=49;H=16384;K=16640;L=17920;G=18176;A=16656;C=16704;N=16672;O=16736;J=16688;I=16720;E=45056;Q=45058;F=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==D?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){B("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(B("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(B("Read material ambient chunk ("+c.toString(16)+ +", "+d+")",3),n.ambient=V(a,b,p)):b==h?(B("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(B("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==k?(B("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==l?(B("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(B("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +W(a,b,p)):b==r?(B("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(B("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){B("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else B("Skip chunk ("+c.toString(16)+", "+d+")",4), +a.Skip(d-6)})}function ca(a,b,c){B("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?B("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==G?B("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):B("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){B("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==H?ca(a,b,c):(B("Skip chunk ("+ +b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],r;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); -var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; -if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; +n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&k(n))}}function k(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,k,l;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],l,m;for(l=c+1;le.length;l++)if(m=a[l].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);l+=1;if(3!=e.length)return-1; +if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return l}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}});c.Finalize();return JSM.ConvertTriangleModelToJsonData(c)};JSM.ImportFileList=function(){this.isFile=this.descriptors=this.originalList=null}; JSM.ImportFileList.prototype.InitFromFiles=function(a){this.originalList=a;this.descriptors=[];var b,c;for(b=0;bs;s++)v[s].z=n-c;s=JSM.GeneratePrism(v,k,c,!0);l.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;ss;s++)v[s].z=n-c;s=JSM.GeneratePrism(v,l,c,!0);k.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;sh;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg&&(g=3);e=m/g;for(m=1;m<=g;m++)f=l.getPointAtLength(m*e),f=c(a,h,k,b,f.x,f.y);return f}function e(a,b){var c=a.VertexCount(b);if(0!==c){var d=a.GetVertex(b,0),c=a.GetVertex(b,c-1);d.IsEqualWithEps(c,0.1)&&a.GetContour(b).vertices.pop()}}function f(a,b){return 0h;h++)l=0===h?g.pgon1:g.pgon2,-1===l&&(l=0===h?g.pgon2:g.pgon1),l=b.GetVertex(d[l]).position.Clone(),k=JSM.CoordAdd(k,l.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(k)))}})();(function(){var e=[],h,g,k,l;for(k=0;kg&&(g=3);e=k/g;for(k=1;k<=g;k++)f=l.getPointAtLength(k*e),f=c(a,h,b,f.x,f.y);return f}function e(a){a=a.GetLastContour();var b=a.VertexCount();if(0!==b){var c=a.GetVertex(0),b=a.GetVertex(b-1);c.IsEqualWithEps(b,0.1)&&a.vertices.pop()}}function f(a){0 - + - + - - - + - + - + @@ -69,12 +67,14 @@ + + diff --git a/sandbox/3dsdump.html b/sandbox/3dsdump.html index 584b35c2..17072add 100644 --- a/sandbox/3dsdump.html +++ b/sandbox/3dsdump.html @@ -32,7 +32,6 @@ - diff --git a/sandbox/bezier.html b/sandbox/bezier.html index 1ed55d71..eb289d95 100644 --- a/sandbox/bezier.html +++ b/sandbox/bezier.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/beziercurve.html b/sandbox/beziercurve.html index e6728b93..0e12d980 100644 --- a/sandbox/beziercurve.html +++ b/sandbox/beziercurve.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/bspline.html b/sandbox/bspline.html index d3a7a3dd..f289f408 100644 --- a/sandbox/bspline.html +++ b/sandbox/bspline.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/charts.html b/sandbox/charts.html index e83d8930..ce748b53 100644 --- a/sandbox/charts.html +++ b/sandbox/charts.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/convexhull.html b/sandbox/convexhull.html index 8b89b089..eaa7b52b 100644 --- a/sandbox/convexhull.html +++ b/sandbox/convexhull.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/coplanar.html b/sandbox/coplanar.html index 44283192..a689ee9a 100644 --- a/sandbox/coplanar.html +++ b/sandbox/coplanar.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/csg.html b/sandbox/csg.html index b65ef469..b1850d83 100644 --- a/sandbox/csg.html +++ b/sandbox/csg.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/csg2.html b/sandbox/csg2.html index 87b6e67d..2b8b5d28 100644 --- a/sandbox/csg2.html +++ b/sandbox/csg2.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/curvedprism.html b/sandbox/curvedprism.html index d6dca66f..ca520a41 100644 --- a/sandbox/curvedprism.html +++ b/sandbox/curvedprism.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/docimages.html b/sandbox/docimages.html index cccf9699..e99eb0e2 100644 --- a/sandbox/docimages.html +++ b/sandbox/docimages.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/doublesided.html b/sandbox/doublesided.html index 5c1d7043..a7e6e37d 100644 --- a/sandbox/doublesided.html +++ b/sandbox/doublesided.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/githublogo.html b/sandbox/githublogo.html index 9235ad5c..14682754 100644 --- a/sandbox/githublogo.html +++ b/sandbox/githublogo.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/heightmap.html b/sandbox/heightmap.html index a51115ce..85322118 100644 --- a/sandbox/heightmap.html +++ b/sandbox/heightmap.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/hiddenline.html b/sandbox/hiddenline.html index 43458541..a4b3a568 100644 --- a/sandbox/hiddenline.html +++ b/sandbox/hiddenline.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/importer.html b/sandbox/importer.html index f901218d..5e758823 100644 --- a/sandbox/importer.html +++ b/sandbox/importer.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/jsonimport.html b/sandbox/jsonimport.html index d16ecb7d..9677f126 100644 --- a/sandbox/jsonimport.html +++ b/sandbox/jsonimport.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/jsonimporttexture.html b/sandbox/jsonimporttexture.html index 6aaa3d5b..8e2678c5 100644 --- a/sandbox/jsonimporttexture.html +++ b/sandbox/jsonimporttexture.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/minimal.html b/sandbox/minimal.html index 2bb3a77b..d54d57e8 100644 --- a/sandbox/minimal.html +++ b/sandbox/minimal.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/minimal2.html b/sandbox/minimal2.html index 96e226ce..4affeb0c 100644 --- a/sandbox/minimal2.html +++ b/sandbox/minimal2.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/octree.html b/sandbox/octree.html index fc05610c..ddbd05fe 100644 --- a/sandbox/octree.html +++ b/sandbox/octree.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/pointcloud.html b/sandbox/pointcloud.html index 866a98a0..47319aff 100644 --- a/sandbox/pointcloud.html +++ b/sandbox/pointcloud.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/pointcloudjson.html b/sandbox/pointcloudjson.html index 59c0f92f..0a683c28 100644 --- a/sandbox/pointcloudjson.html +++ b/sandbox/pointcloudjson.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/print.html b/sandbox/print.html index a457aab2..44ae4a74 100644 --- a/sandbox/print.html +++ b/sandbox/print.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/prismwithhole.html b/sandbox/prismwithhole.html index ff274214..666d1715 100644 --- a/sandbox/prismwithhole.html +++ b/sandbox/prismwithhole.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/randommat.html b/sandbox/randommat.html index afecb47d..5472c715 100644 --- a/sandbox/randommat.html +++ b/sandbox/randommat.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/renderer.html b/sandbox/renderer.html index 69982141..83e648fa 100644 --- a/sandbox/renderer.html +++ b/sandbox/renderer.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/revolved.html b/sandbox/revolved.html index 994acdc1..d7f54278 100644 --- a/sandbox/revolved.html +++ b/sandbox/revolved.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/smartbuilder.html b/sandbox/smartbuilder.html index 950e7519..3018e2ea 100644 --- a/sandbox/smartbuilder.html +++ b/sandbox/smartbuilder.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/smartbuilder2.html b/sandbox/smartbuilder2.html index 96bc41c7..4251e7e8 100644 --- a/sandbox/smartbuilder2.html +++ b/sandbox/smartbuilder2.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/solids.html b/sandbox/solids.html index 803aa515..e853bdbd 100644 --- a/sandbox/solids.html +++ b/sandbox/solids.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/specular.html b/sandbox/specular.html index 9206a50c..285329ff 100644 --- a/sandbox/specular.html +++ b/sandbox/specular.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/svgonthefly.html b/sandbox/svgonthefly.html index 337665fa..83af3643 100644 --- a/sandbox/svgonthefly.html +++ b/sandbox/svgonthefly.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/svgtomodel.html b/sandbox/svgtomodel.html index e25ba760..a0b1570f 100644 --- a/sandbox/svgtomodel.html +++ b/sandbox/svgtomodel.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/svgtomodel2.html b/sandbox/svgtomodel2.html index 25384987..1b276f74 100644 --- a/sandbox/svgtomodel2.html +++ b/sandbox/svgtomodel2.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 24d6784b..44de00e9 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/tasks.html b/sandbox/tasks.html index 7d6d16e9..0b501c8f 100644 --- a/sandbox/tasks.html +++ b/sandbox/tasks.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/texture.html b/sandbox/texture.html index 1ecbf329..f23daeb1 100644 --- a/sandbox/texture.html +++ b/sandbox/texture.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/tictactoecanvas.html b/sandbox/tictactoecanvas.html index 717b8193..621d720e 100644 --- a/sandbox/tictactoecanvas.html +++ b/sandbox/tictactoecanvas.html @@ -30,7 +30,6 @@ - diff --git a/sandbox/triangulate.html b/sandbox/triangulate.html index 35b6cd55..a1f90778 100644 --- a/sandbox/triangulate.html +++ b/sandbox/triangulate.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/triangulation/polygoneditor.html b/sandbox/triangulation/polygoneditor.html index cefd691a..c16fe5c1 100644 --- a/sandbox/triangulation/polygoneditor.html +++ b/sandbox/triangulation/polygoneditor.html @@ -30,7 +30,6 @@ - diff --git a/sandbox/tube.html b/sandbox/tube.html index 4cb8be1e..4ca50b35 100644 --- a/sandbox/tube.html +++ b/sandbox/tube.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/undermouse.html b/sandbox/undermouse.html index f44b545b..1ab1aee3 100644 --- a/sandbox/undermouse.html +++ b/sandbox/undermouse.html @@ -31,7 +31,6 @@ - diff --git a/sandbox/viewer.html b/sandbox/viewer.html index 304caa6a..7d6871db 100644 --- a/sandbox/viewer.html +++ b/sandbox/viewer.html @@ -31,7 +31,6 @@ - diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index 99d4782d..d4c0940f 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -12,7 +12,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) { function SegmentElem (elem, segmentLength) { - function AddTransformedVertex (dummySVG, result, contour, elem, x, y) + function AddTransformedVertex (dummySVG, result, elem, x, y) { var point = dummySVG.createSVGPoint (); point.x = x; @@ -26,18 +26,19 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var transformedCoord = new JSM.Coord2D (transformed.x, transformed.y); var resultCoord = new JSM.Coord2D (x, y); - var contourVertexCount = result.VertexCount (contour); + var contour = result.GetLastContour (); + var contourVertexCount = contour.VertexCount (); if (contourVertexCount > 0) { - if (result.GetVertex (contour, contourVertexCount - 1).IsEqualWithEps (transformedCoord, 0.1)) { + if (contour.GetVertex (contourVertexCount - 1).IsEqualWithEps (transformedCoord, 0.1)) { return resultCoord; } } - result.AddVertex (contour, transformed.x, transformed.y); + contour.AddVertex (transformed.x, transformed.y); return resultCoord; } - function SegmentCurve (dummySVG, originalPath, segmentLength, lastCoord, items, result, currentContour) + function SegmentCurve (dummySVG, originalPath, segmentLength, lastCoord, items, result) { function CreatePath (items) { @@ -95,7 +96,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var i, point; for (i = 1; i <= segmentation; i++) { point = path.getPointAtLength (i * step); - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, originalPath, point.x, point.y); + lastCoord = AddTransformedVertex (dummySVG, result, originalPath, point.x, point.y); } return lastCoord; @@ -119,28 +120,28 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) item.pathSegType == SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; } - function RemoveEqualEndVertices (polygon, contour) + function RemoveEqualEndVertices (polygon) { - var vertexCount = polygon.VertexCount (contour); + var contour = polygon.GetLastContour (); + var vertexCount = contour.VertexCount (); if (vertexCount === 0) { return; } - var firstCoord = polygon.GetVertex (contour, 0); - var lastCoord = polygon.GetVertex (contour, vertexCount - 1); + var firstCoord = contour.GetVertex (0); + var lastCoord = contour.GetVertex (vertexCount - 1); if (firstCoord.IsEqualWithEps (lastCoord, 0.1)) { - polygon.GetContour (contour).vertices.pop (); + // TODO: Do not access vertices directly + contour.vertices.pop (); } } - function StartNewContour (result, contour) + function StartNewContour (result) { - if (result.VertexCount (contour) > 0) { - RemoveEqualEndVertices (result, contour); + if (result.GetLastContour ().VertexCount () > 0) { + RemoveEqualEndVertices (result); result.AddContour (); - return contour + 1; } - return contour; } function SVGColorToHex (path) @@ -181,7 +182,8 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) return result; } - var result = new JSM.OldContourPolygon2D (); + var result = new JSM.ContourPolygon2D (); + result.AddContour (); var dummySVG = document.createElementNS ('http://www.w3.org/2000/svg', 'svg'); @@ -196,31 +198,30 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) } var item, items, currentItem; - var currentContour = 0; for (i = 0; i < elem.pathSegList.numberOfItems; i++) { item = elem.pathSegList.getItem (i); if (item.pathSegType == SVGPathSeg.PATHSEG_CLOSEPATH) { // do nothing } else if (item.pathSegType == SVGPathSeg.PATHSEG_MOVETO_ABS) { - currentContour = StartNewContour (result, currentContour); - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, item.x, item.y); + StartNewContour (result); + lastCoord = AddTransformedVertex (dummySVG, result, elem, item.x, item.y); lastMoveCoord = lastCoord.Clone (); } else if (item.pathSegType == SVGPathSeg.PATHSEG_MOVETO_REL) { - currentContour = StartNewContour (result, currentContour); - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, lastMoveCoord.x + item.x, lastMoveCoord.y + item.y); + StartNewContour (result); + lastCoord = AddTransformedVertex (dummySVG, result, elem, lastMoveCoord.x + item.x, lastMoveCoord.y + item.y); lastMoveCoord = lastCoord.Clone (); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_ABS) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, item.x, item.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, item.x, item.y); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_REL) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, lastCoord.x + item.x, lastCoord.y + item.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, lastCoord.x + item.x, lastCoord.y + item.y); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, item.x, lastCoord.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, item.x, lastCoord.y); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, lastCoord.x, item.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, lastCoord.x, item.y); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, lastCoord.x + item.x, lastCoord.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, lastCoord.x + item.x, lastCoord.y); } else if (item.pathSegType == SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL) { - lastCoord = AddTransformedVertex (dummySVG, result, currentContour, elem, lastCoord.x, lastCoord.y + item.y); + lastCoord = AddTransformedVertex (dummySVG, result, elem, lastCoord.x, lastCoord.y + item.y); } else if (IsCurvedItem (item)) { items = []; if (IsSmoothItem (item)) { @@ -235,23 +236,23 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) } else { items.push (item); } - lastCoord = SegmentCurve (dummySVG, elem, currentSegmentLength, lastCoord, items, result, currentContour); + lastCoord = SegmentCurve (dummySVG, elem, currentSegmentLength, lastCoord, items, result); } else { // unknown segment type } } - RemoveEqualEndVertices (result, currentContour); + RemoveEqualEndVertices (result); } else if (elem instanceof SVGRectElement) { - AddTransformedVertex (dummySVG, result, 0, elem, elem.x.baseVal.value, elem.y.baseVal.value); - AddTransformedVertex (dummySVG, result, 0, elem, elem.x.baseVal.value + elem.width.baseVal.value, elem.y.baseVal.value); - AddTransformedVertex (dummySVG, result, 0, elem, elem.x.baseVal.value + elem.width.baseVal.value, elem.y.baseVal.value + elem.height.baseVal.value); - AddTransformedVertex (dummySVG, result, 0, elem, elem.x.baseVal.value, elem.y.baseVal.value + elem.height.baseVal.value); + AddTransformedVertex (dummySVG, result, elem, elem.x.baseVal.value, elem.y.baseVal.value); + AddTransformedVertex (dummySVG, result, elem, elem.x.baseVal.value + elem.width.baseVal.value, elem.y.baseVal.value); + AddTransformedVertex (dummySVG, result, elem, elem.x.baseVal.value + elem.width.baseVal.value, elem.y.baseVal.value + elem.height.baseVal.value); + AddTransformedVertex (dummySVG, result, elem, elem.x.baseVal.value, elem.y.baseVal.value + elem.height.baseVal.value); } else if (elem instanceof SVGPolygonElement) { var point; for (i = 0; i < elem.points.numberOfItems; i++) { point = elem.points.getItem (i); - AddTransformedVertex (dummySVG, result, 0, elem, point.x, point.y); + AddTransformedVertex (dummySVG, result, elem, point.x, point.y); } } result.color = SVGColorToHex (elem); diff --git a/src/geometry/oldpolygon.js b/src/geometry/oldpolygon.js deleted file mode 100644 index 85fb24ec..00000000 --- a/src/geometry/oldpolygon.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* Class: OldContourPolygon2D -* Description: Represents a 2D polygon with more contours. -*/ -JSM.OldContourPolygon2D = function () -{ - this.polygons = []; -}; - -/** -* Function: OldContourPolygon2D.AddVertex -* Description: Adds a vertex to a contour of the polygon. -* Parameters: -* contour {integer} the index of the contour -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -*/ -JSM.OldContourPolygon2D.prototype.AddVertex = function (contour, x, y) -{ - if (this.polygons[contour] === undefined) { - this.polygons[contour] = new JSM.Polygon2D (); - } - this.polygons[contour].AddVertex (x, y); -}; - -/** -* Function: OldContourPolygon2D.VertexCount -* Description: Returns the vertex count of a contour of the polygon. -* Parameters: -* contour {integer} the index of the contour -* Returns: -* {integer} vertex count -*/ -JSM.OldContourPolygon2D.prototype.VertexCount = function (contour) -{ - if (this.polygons[contour] === undefined) { - return 0; - } - return this.polygons[contour].VertexCount (); -}; - -/** -* Function: OldContourPolygon2D.GetVertex -* Description: Returns the vertex of a contour with the given index. -* Parameters: -* contour {integer} the index of the contour -* index {integer} the index of the vertex -* Returns: -* {Coord2D} the vertex -*/ -JSM.OldContourPolygon2D.prototype.GetVertex = function (contour, index) -{ - return this.polygons[contour].GetVertex (index); -}; - -/** -* Function: OldContourPolygon2D.SetVertex -* Description: Modifies the coordinates of an existing vertex of a contour. -* Parameters: -* contour {integer} the index of the contour -* index {integer} the index of the vertex -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -*/ -JSM.OldContourPolygon2D.prototype.SetVertex = function (contour, index, x, y) -{ - this.polygons[contour].SetVertex (index, x, y); -}; - -/** -* Function: OldContourPolygon2D.AddContour -* Description: Adds new contour to the polygon. -*/ -JSM.OldContourPolygon2D.prototype.AddContour = function () -{ - this.polygons.push (new JSM.Polygon2D ()); -}; - -/** -* Function: OldContourPolygon2D.ContourCount -* Description: Returns the contour count of the polygon. -* Returns: -* {integer} contour count -*/ -JSM.OldContourPolygon2D.prototype.ContourCount = function () -{ - return this.polygons.length; -}; - -/** -* Function: OldContourPolygon2D.GetContour -* Description: Returns the contour with the given index. -* Parameters: -* contour {integer} the index of the contour -* Returns: -* {Polygon2D} the contour -*/ -JSM.OldContourPolygon2D.prototype.GetContour = function (contour) -{ - return this.polygons[contour]; -}; - -/** -* Function: OldContourPolygon2D.Clear -* Description: Makes the polygon empty. -*/ -JSM.OldContourPolygon2D.prototype.Clear = function () -{ - this.polygons = []; -}; - -/** -* Function: OldContourPolygon2D.Clone -* Description: Clones the polygon. -* Returns: -* {OldContourPolygon2D} a cloned instance -*/ -JSM.OldContourPolygon2D.prototype.Clone = function () -{ - var result = new JSM.OldContourPolygon2D (); - var i; - for (i = 0; i < this.polygons.length; i++) { - result.polygons.push (this.polygons[i].Clone ()); - } - return result; -}; diff --git a/src/geometry/polygon.js b/src/geometry/polygon.js index c900a34c..12158f7e 100644 --- a/src/geometry/polygon.js +++ b/src/geometry/polygon.js @@ -24,7 +24,7 @@ JSM.Polygon.prototype.AddVertex = function (x, y, z) * Function: Polygon.AddVertexCoord * Description: Adds a vertex coordinate to the polygon. * Parameters: -* coord {coord} the coordinate +* coord {Coord} the coordinate */ JSM.Polygon.prototype.AddVertexCoord = function (coord) { @@ -116,7 +116,7 @@ JSM.Polygon.prototype.ToArray = function () }; /** -* Function: Polygon.ToArray +* Function: Polygon.FromArray * Description: Creates the polygon from an array of vertices. * Parameters: * vertices {Coord[*]} the array of vertices @@ -157,32 +157,72 @@ JSM.Polygon.prototype.Clone = function () return result; }; +/** +* Class: ContourPolygon +* Description: Represents a 3D polygon with more contours. +*/ JSM.ContourPolygon = function () { this.contours = null; this.Clear (); }; +/** +* Function: ContourPolygon.AddVertex +* Description: Adds a vertex to the last contour of the polygon. +* Parameters: +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +* z {number} the z coordinate of the vertex +*/ JSM.ContourPolygon.prototype.AddVertex = function (x, y, z) { this.lastContour.AddVertex (x, y, z); }; +/** +* Function: ContourPolygon.AddVertexCoord +* Description: Adds a vertex coordinate to the last contour of the polygon. +* Parameters: +* coord {Coord} the coordinate +*/ JSM.ContourPolygon.prototype.AddVertexCoord = function (coord) { this.lastContour.AddVertexCoord (coord); }; +/** +* Function: ContourPolygon.AddContourVertex +* Description: Adds a vertex to the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +* z {number} the z coordinate of the vertex +*/ JSM.ContourPolygon.prototype.AddContourVertex = function (contourIndex, x, y, z) { return this.contours[contourIndex].AddVertex (x, y, z); }; +/** +* Function: ContourPolygon.AddContourVertexCoord +* Description: Adds a vertex coordinate to the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* coord {Coord} the coordinate +*/ JSM.ContourPolygon.prototype.AddContourVertexCoord = function (contourIndex, coord) { return this.contours[contourIndex].AddVertexCoord (coord); }; +/** +* Function: ContourPolygon.VertexCount +* Description: Returns the vertex count of the polygon. +* Returns: +* {integer} vertex count +*/ JSM.ContourPolygon.prototype.VertexCount = function () { var vertexCount = 0; @@ -193,6 +233,27 @@ JSM.ContourPolygon.prototype.VertexCount = function () return vertexCount; }; +/** +* Function: ContourPolygon.ContourVertexCount +* Description: Returns the vertex count of the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* Returns: +* {integer} vertex count +*/ +JSM.ContourPolygon.prototype.ContourVertexCount = function (contourIndex) +{ + return this.contours[contourIndex].VertexCount (); +}; + +/** +* Function: ContourPolygon.AddContour +* Description: +* Adds a contour to the polygon. If the given contour is null, +* an empty contour is added to the polygon. +* Parameters: +* contour {Polygon} the new contour +*/ JSM.ContourPolygon.prototype.AddContour = function (contour) { if (contour === undefined || contour === null) { @@ -203,26 +264,61 @@ JSM.ContourPolygon.prototype.AddContour = function (contour) this.contours.push (this.lastContour); }; +/** +* Function: ContourPolygon.GetLastContour +* Description: Returns the last contour of the polygon. +* Returns: +* {Polygon} the result +*/ +JSM.ContourPolygon.prototype.GetLastContour = function () +{ + return this.lastContour; +}; + +/** +* Function: ContourPolygon.GetContourVertex +* Description: Returns the vertex of the given contour with the given index. +* Parameters: +* contourIndex {integer} the index of the contour +* vertexIndex {integer} the index of the vertex +* Returns: +* {Coord} the vertex +*/ JSM.ContourPolygon.prototype.GetContourVertex = function (contourIndex, vertexIndex) { return this.contours[contourIndex].GetVertex (vertexIndex); }; -JSM.ContourPolygon.prototype.GetContour = function (index) +/** +* Function: ContourPolygon.GetContour +* Description: Returns the contour with the given index. +* Parameters: +* contourIndex {integer} the index of the contour +* Returns: +* {Polygon} the contour +*/ +JSM.ContourPolygon.prototype.GetContour = function (contourIndex) { - return this.contours[index]; + return this.contours[contourIndex]; }; +/** +* Function: ContourPolygon.ContourCount +* Description: Returns the contour count of the polygon. +* Returns: +* {integer} contour count +*/ JSM.ContourPolygon.prototype.ContourCount = function () { return this.contours.length; }; -JSM.ContourPolygon.prototype.GetNormal = function () -{ - -}; - +/** +* Function: ContourPolygon.ToContourPolygon2D +* Description: Converts the polygon to a 2D polygon. +* Returns: +* {ContourPolygon2D} the result +*/ JSM.ContourPolygon.prototype.ToContourPolygon2D = function () { var normal = this.contours[0].GetNormal (); @@ -239,6 +335,14 @@ JSM.ContourPolygon.prototype.ToContourPolygon2D = function () return result; }; +/** +* Function: ContourPolygon.ToArray +* Description: +* Creates an array of vertices from polygon. The result contains +* null values between contours. +* Returns: +* {Coord[*]} the result +*/ JSM.ContourPolygon.prototype.ToArray = function () { var vertices = []; @@ -256,6 +360,14 @@ JSM.ContourPolygon.prototype.ToArray = function () return vertices; }; +/** +* Function: ContourPolygon.FromArray +* Description: +* Creates the polygon from an array of vertices. The input should contain +* null values between contours. +* Parameters: +* vertices {Coord[*]} the array of vertices +*/ JSM.ContourPolygon.prototype.FromArray = function (vertices) { this.Clear (); @@ -271,12 +383,22 @@ JSM.ContourPolygon.prototype.FromArray = function (vertices) } }; +/** +* Function: ContourPolygon.Clear +* Description: Makes the polygon empty. +*/ JSM.ContourPolygon.prototype.Clear = function () { this.contours = []; this.lastContour = null; }; +/** +* Function: ContourPolygon.Clone +* Description: Clones the polygon. +* Returns: +* {ContourPolygon} a cloned instance +*/ JSM.ContourPolygon.prototype.Clone = function () { var result = new JSM.ContourPolygon (); diff --git a/src/geometry/polygon2d.js b/src/geometry/polygon2d.js index 1001d6e1..b81e80cb 100644 --- a/src/geometry/polygon2d.js +++ b/src/geometry/polygon2d.js @@ -1,3 +1,12 @@ +/** +* Enum: Complexity +* Description: Complexity of a polygon. +* Values: +* {Invalid} invalid polygon +* {Convex} convex polygon +* {Concave} concave polygon +* {Complex} complex polygon (contains holes) +*/ JSM.Complexity = { Invalid : 0, Convex : 1, @@ -5,20 +14,42 @@ JSM.Complexity = { Complex : 3 }; -JSM.CoordPolygonPosition = { +/** +* Enum: CoordPolygonPosition2D +* Description: Position of a coordinate and a polygon. +* Values: +* {OnVertex} coordinate lies on a vertex of the polygon +* {OnEdge} coordinate lies on an edge of the polygon +* {Inside} coordinate lies inside the polygon +* {Outside} coordinate lies outside of the polygon +*/ +JSM.CoordPolygonPosition2D = { OnVertex : 0, OnEdge : 1, Inside : 2, Outside : 3 }; -JSM.SectorPolygonPosition = { +/** +* Enum: SectorPolygonPosition2D +* Description: Position of a sector and a polygon. +* Values: +* {IntersectionOnePoint} sector intersects polygon +* {IntersectionCoincident} sector lies on an edge of the polygon +* {IntersectionOnVertex} sector intersects polygon on a vertex +* {NoIntersection} sector does not intersect polygon +*/ +JSM.SectorPolygonPosition2D = { IntersectionOnePoint : 0, IntersectionCoincident : 1, IntersectionOnVertex : 2, NoIntersection : 3 }; +/** +* Class: Polygon2D +* Description: Represents a 2D polygon. +*/ JSM.Polygon2D = function () { this.vertices = null; @@ -26,27 +57,64 @@ JSM.Polygon2D = function () this.Clear (); }; +/** +* Function: Polygon2D.AddVertex +* Description: Adds a vertex to the polygon. +* Parameters: +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +*/ JSM.Polygon2D.prototype.AddVertex = function (x, y) { this.AddVertexCoord (new JSM.Coord2D (x, y)); }; +/** +* Function: Polygon2D.AddVertexCoord +* Description: Adds a vertex coordinate to the polygon. +* Parameters: +* coord {Coord} the coordinate +*/ JSM.Polygon2D.prototype.AddVertexCoord = function (coord) { this.vertices.push (coord); this.ClearCache (); }; +/** +* Function: Polygon2D.GetVertex +* Description: Returns the vertex with the given index. +* Parameters: +* index {integer} the index of the vertex +* Returns: +* {Coord2D} the vertex +*/ JSM.Polygon2D.prototype.GetVertex = function (index) { return this.vertices[index]; }; +/** +* Function: Polygon2D.VertexCount +* Description: Returns the vertex count of the polygon. +* Returns: +* {integer} vertex count +*/ JSM.Polygon2D.prototype.VertexCount = function () { return this.vertices.length; }; +/** +* Function: Polygon2D.EnumerateVertices +* Description: +* Enumerates the vertices of the polygon, and calls +* a function for each vertex. +* Parameters: +* from {integer} the start vertex index +* to {integer} the end vertex index +* callback {function} the callback function +*/ JSM.Polygon2D.prototype.EnumerateVertices = function (from, to, callback) { var count = this.vertices.length; @@ -58,24 +126,52 @@ JSM.Polygon2D.prototype.EnumerateVertices = function (from, to, callback) } }; +/** +* Function: Polygon2D.GetNextVertex +* Description: Returns the vertex index after the given one. +* Parameters: +* index {integer} the vertex index +* Returns: +* {integer} the result +*/ JSM.Polygon2D.prototype.GetNextVertex = function (index) { var count = this.vertices.length; return (index < count - 1 ? index + 1 : 0); }; +/** +* Function: Polygon2D.GetPrevVertex +* Description: Returns the vertex index before the given one. +* Parameters: +* index {integer} the vertex index +* Returns: +* {integer} the result +*/ JSM.Polygon2D.prototype.GetPrevVertex = function (index) { var count = this.vertices.length; return (index > 0 ? index - 1 : count - 1); }; +/** +* Function: Polygon2D.ShiftVertices +* Description: Shifts polygon vertices. +* Parameters: +* count {integer} the number of shifts +*/ JSM.Polygon2D.prototype.ShiftVertices = function (count) { JSM.ShiftArray (this.vertices, count); this.ClearCache (); }; +/** +* Function: Polygon2D.GetSignedArea +* Description: Calculates the signed area of the polygon. +* Returns: +* {number} the result +*/ JSM.Polygon2D.prototype.GetSignedArea = function () { if (this.cache.signedArea !== null) { @@ -98,12 +194,24 @@ JSM.Polygon2D.prototype.GetSignedArea = function () return result; }; +/** +* Function: Polygon2D.GetArea +* Description: Calculates the area of the polygon. +* Returns: +* {number} the result +*/ JSM.Polygon2D.prototype.GetArea = function () { var signedArea = this.GetSignedArea (); return Math.abs (signedArea); }; +/** +* Function: Polygon2D.GetOrientation +* Description: Calculates the orientation of the polygon. +* Returns: +* {Orientation} the result +*/ JSM.Polygon2D.prototype.GetOrientation = function () { if (this.cache.orientation !== null) { @@ -124,6 +232,49 @@ JSM.Polygon2D.prototype.GetOrientation = function () return result; }; + +/** +* Function: Polygon2D.GetComplexity +* Description: Calculates the complexity of the polygon. +* Returns: +* {Complexity} the result +*/ +JSM.Polygon2D.prototype.GetComplexity = function () +{ + if (this.cache.complexity !== null) { + return this.cache.complexity; + } + + var count = this.vertices.length; + if (count < 3) { + return JSM.Complexity.Invalid; + } + + var result = JSM.Complexity.Invalid; + var polygonOrientain = this.GetOrientation (); + if (polygonOrientain != JSM.Orientation.Invalid) { + result = JSM.Complexity.Convex; + var i; + for (i = 0; i < count; i++) { + if (this.IsConcaveVertex (i)) { + result = JSM.Complexity.Concave; + break; + } + } + } + + this.cache.complexity = result; + return result; +}; + +/** +* Function: Polygon2D.GetVertexOrientation +* Description: Calculates the orientation of the given vertex of the polygon. +* Parameters: +* index {integer} the vertex index +* Returns: +* {Orientation} the result +*/ JSM.Polygon2D.prototype.GetVertexOrientation = function (index) { if (this.cache.vertexOrientations[index] !== undefined) { @@ -139,6 +290,14 @@ JSM.Polygon2D.prototype.GetVertexOrientation = function (index) return result; }; +/** +* Function: Polygon2D.IsConvexVertex +* Description: Returns if the given vertex is convex. +* Parameters: +* index {integer} the vertex index +* Returns: +* {boolean} the result +*/ JSM.Polygon2D.prototype.IsConvexVertex = function (index) { var orientation = this.GetOrientation (); @@ -149,6 +308,14 @@ JSM.Polygon2D.prototype.IsConvexVertex = function (index) return vertexOrientation == orientation; }; +/** +* Function: Polygon2D.IsConcaveVertex +* Description: Returns if the given vertex is concave. +* Parameters: +* index {integer} the vertex index +* Returns: +* {boolean} the result +*/ JSM.Polygon2D.prototype.IsConcaveVertex = function (index) { var orientation = this.GetOrientation (); @@ -159,6 +326,14 @@ JSM.Polygon2D.prototype.IsConcaveVertex = function (index) return vertexOrientation != orientation; }; +/** +* Function: Polygon2D.CoordPosition +* Description: Calculates the position of a coordinate and the polygon. +* Parameters: +* coord {Coord2D} the coordinate +* Returns: +* {CoordPolygonPosition2D} the result +*/ JSM.Polygon2D.prototype.CoordPosition = function (coord) { function IntersectionCount (coord, beg, end) @@ -215,22 +390,34 @@ JSM.Polygon2D.prototype.CoordPosition = function (coord) sector = new JSM.Sector2D (edgeFrom, edgeTo); position = sector.CoordPosition (coord); if (position == JSM.CoordSectorPosition2D.CoordInsideOfSector) { - return JSM.CoordPolygonPosition.OnEdge; + return JSM.CoordPolygonPosition2D.OnEdge; } else if (position == JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - return JSM.CoordPolygonPosition.OnVertex; + return JSM.CoordPolygonPosition2D.OnVertex; } intersections += IntersectionCount (coord, edgeFrom, edgeTo); } if (intersections % 2 !== 0) { - return JSM.CoordPolygonPosition.Inside; - } - return JSM.CoordPolygonPosition.Outside; -}; - + return JSM.CoordPolygonPosition2D.Inside; + } + return JSM.CoordPolygonPosition2D.Outside; +}; + +/** +* Function: Polygon2D.SectorPosition +* Description: +* Calculates the position of a sector and the polygon. The given begin and end +* vertex indices are omitted form intersection checking. +* Parameters: +* sector {Sector3D} the sector +* begIndex {integer} begin vertex index +* endIndex {integer} end vertex index +* Returns: +* {CoordSectorPosition2D} the result +*/ JSM.Polygon2D.prototype.SectorPosition = function (sector, begIndex, endIndex) { - var result = JSM.SectorPolygonPosition.NoIntersection; + var result = JSM.SectorPolygonPosition2D.NoIntersection; var vertexCount = this.vertices.length; if (vertexCount < 3) { return result; @@ -249,17 +436,26 @@ JSM.Polygon2D.prototype.SectorPosition = function (sector, begIndex, endIndex) currentSector = new JSM.Sector2D (edgeBeg, edgeEnd); position = sector.SectorPosition (currentSector); if (position == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint) { - return JSM.SectorPolygonPosition.IntersectionOnePoint; + return JSM.SectorPolygonPosition2D.IntersectionOnePoint; } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectCoincident) { - return JSM.SectorPolygonPosition.IntersectionCoincident; + return JSM.SectorPolygonPosition2D.IntersectionCoincident; } else if (position == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint) { - result = JSM.SectorPolygonPosition.IntersectionOnVertex; + result = JSM.SectorPolygonPosition2D.IntersectionOnVertex; } } return result; }; +/** +* Function: Polygon2D.IsDiagonal +* Description: Returns if the sector between two vertices is diagonal. +* Parameters: +* from {integer} begin vertex index +* to {integer} end vertex index +* Returns: +* {boolean} the result +*/ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) { function DiagonalIntersectsAnyEdges (polygon, from, to) @@ -268,7 +464,7 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) var toVertex = polygon.GetVertex (to); var sector = new JSM.Sector2D (fromVertex, toVertex); var position = polygon.SectorPosition (sector, from, to); - if (position != JSM.SectorPolygonPosition.NoIntersection) { + if (position != JSM.SectorPolygonPosition2D.NoIntersection) { return true; } return false; @@ -283,7 +479,7 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) (fromVertex.y + toVertex.y) / 2.0 ); var position = polygon.CoordPosition (midCoord); - return position == JSM.CoordPolygonPosition.Inside; + return position == JSM.CoordPolygonPosition2D.Inside; } if (from == to) { @@ -311,34 +507,12 @@ JSM.Polygon2D.prototype.IsDiagonal = function (from, to) return true; }; -JSM.Polygon2D.prototype.GetComplexity = function () -{ - if (this.cache.complexity !== null) { - return this.cache.complexity; - } - - var count = this.vertices.length; - if (count < 3) { - return JSM.Complexity.Invalid; - } - - var result = JSM.Complexity.Invalid; - var polygonOrientain = this.GetOrientation (); - if (polygonOrientain != JSM.Orientation.Invalid) { - result = JSM.Complexity.Convex; - var i; - for (i = 0; i < count; i++) { - if (this.IsConcaveVertex (i)) { - result = JSM.Complexity.Concave; - break; - } - } - } - - this.cache.complexity = result; - return result; -}; - +/** +* Function: Polygon2D.ToArray +* Description: Creates an array of vertices from polygon. +* Returns: +* {Coord2D[*]} the result +*/ JSM.Polygon2D.prototype.ToArray = function () { var vertices = []; @@ -350,6 +524,12 @@ JSM.Polygon2D.prototype.ToArray = function () return vertices; }; +/** +* Function: Polygon2D.FromArray +* Description: Creates the polygon from an array of vertices. +* Parameters: +* vertices {Coord2D[*]} the array of vertices +*/ JSM.Polygon2D.prototype.FromArray = function (vertices) { this.Clear (); @@ -360,12 +540,36 @@ JSM.Polygon2D.prototype.FromArray = function (vertices) } }; +/** +* Function: Polygon2D.Clear +* Description: Makes the polygon empty. +*/ JSM.Polygon2D.prototype.Clear = function () { this.vertices = []; this.ClearCache (); }; +/** +* Function: Polygon2D.ClearCache +* Description: Clears stored values from the polygon. +*/ +JSM.Polygon2D.prototype.ClearCache = function () +{ + this.cache = { + signedArea : null, + orientation : null, + vertexOrientations : {}, + complexity : null + }; +}; + +/** +* Function: Polygon2D.Clone +* Description: Clones the polygon. +* Returns: +* {Polygon2D} a cloned instance +*/ JSM.Polygon2D.prototype.Clone = function () { var result = new JSM.Polygon2D (); @@ -377,42 +581,70 @@ JSM.Polygon2D.prototype.Clone = function () return result; }; -JSM.Polygon2D.prototype.ClearCache = function () -{ - this.cache = { - signedArea : null, - orientation : null, - vertexOrientations : {}, - complexity : null - }; -}; - +/** +* Class: ContourPolygon2D +* Description: Represents a 2D polygon with more contours. +*/ JSM.ContourPolygon2D = function () { this.contours = null; this.Clear (); }; +/** +* Function: ContourPolygon2D.AddVertex +* Description: Adds a vertex to the last contour of the polygon. +* Parameters: +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +*/ JSM.ContourPolygon2D.prototype.AddVertex = function (x, y) { this.lastContour.AddVertex (x, y); }; +/** +* Function: ContourPolygon2D.AddVertexCoord +* Description: Adds a vertex coordinate to the last contour of the polygon. +* Parameters: +* coord {Coord2D} the coordinate +*/ JSM.ContourPolygon2D.prototype.AddVertexCoord = function (coord) { this.lastContour.AddVertexCoord (coord); }; +/** +* Function: ContourPolygon2D.AddContourVertex +* Description: Adds a vertex to the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* x {number} the x coordinate of the vertex +* y {number} the y coordinate of the vertex +*/ JSM.ContourPolygon2D.prototype.AddContourVertex = function (contourIndex, x, y) { return this.contours[contourIndex].AddVertex (x, y); }; +/** +* Function: ContourPolygon2D.AddContourVertexCoord +* Description: Adds a vertex coordinate to the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* coord {Coord2D} the coordinate +*/ JSM.ContourPolygon2D.prototype.AddContourVertexCoord = function (contourIndex, coord) { return this.contours[contourIndex].AddVertexCoord (coord); }; +/** +* Function: ContourPolygon2D.VertexCount +* Description: Returns the vertex count of the polygon. +* Returns: +* {integer} vertex count +*/ JSM.ContourPolygon2D.prototype.VertexCount = function () { var vertexCount = 0; @@ -423,6 +655,27 @@ JSM.ContourPolygon2D.prototype.VertexCount = function () return vertexCount; }; +/** +* Function: ContourPolygon2D.ContourVertexCount +* Description: Returns the vertex count of the given contour of the polygon. +* Parameters: +* contourIndex {integer} the index of the contour +* Returns: +* {integer} vertex count +*/ +JSM.ContourPolygon2D.prototype.ContourVertexCount = function (contourIndex) +{ + return this.contours[contourIndex].VertexCount (); +}; + +/** +* Function: ContourPolygon2D.AddContour +* Description: +* Adds a contour to the polygon. If the given contour is null, +* an empty contour is added to the polygon. +* Parameters: +* contour {Polygon2D} the new contour +*/ JSM.ContourPolygon2D.prototype.AddContour = function (contour) { if (contour === undefined || contour === null) { @@ -433,21 +686,61 @@ JSM.ContourPolygon2D.prototype.AddContour = function (contour) this.contours.push (this.lastContour); }; +/** +* Function: ContourPolygon2D.GetLastContour +* Description: Returns the last contour of the polygon. +* Returns: +* {Polygon2D} the result +*/ +JSM.ContourPolygon2D.prototype.GetLastContour = function () +{ + return this.lastContour; +}; + +/** +* Function: ContourPolygon2D.GetContourVertex +* Description: Returns the vertex of the given contour with the given index. +* Parameters: +* contourIndex {integer} the index of the contour +* vertexIndex {integer} the index of the vertex +* Returns: +* {Coord2D} the vertex +*/ JSM.ContourPolygon2D.prototype.GetContourVertex = function (contourIndex, vertexIndex) { return this.contours[contourIndex].GetVertex (vertexIndex); }; +/** +* Function: ContourPolygon2D.GetContour +* Description: Returns the contour with the given index. +* Parameters: +* contourIndex {integer} the index of the contour +* Returns: +* {Polygon2D} the contour +*/ JSM.ContourPolygon2D.prototype.GetContour = function (index) { return this.contours[index]; }; +/** +* Function: ContourPolygon2D.ContourCount +* Description: Returns the contour count of the polygon. +* Returns: +* {integer} contour count +*/ JSM.ContourPolygon2D.prototype.ContourCount = function () { return this.contours.length; }; +/** +* Function: ContourPolygon2D.GetSignedArea +* Description: Calculates the signed area of the polygon. +* Returns: +* {number} the result +*/ JSM.ContourPolygon2D.prototype.GetSignedArea = function () { var area = 0.0; @@ -458,12 +751,24 @@ JSM.ContourPolygon2D.prototype.GetSignedArea = function () return area; }; +/** +* Function: ContourPolygon2D.GetArea +* Description: Calculates the area of the polygon. +* Returns: +* {number} the result +*/ JSM.ContourPolygon2D.prototype.GetArea = function () { var signedArea = this.GetSignedArea (); return Math.abs (signedArea); }; +/** +* Function: ContourPolygon2D.GetOrientation +* Description: Calculates the orientation of the polygon. +* Returns: +* {Orientation} the result +*/ JSM.ContourPolygon2D.prototype.GetOrientation = function () { if (this.lastContour === null) { @@ -489,6 +794,12 @@ JSM.ContourPolygon2D.prototype.GetOrientation = function () return orientation; }; +/** +* Function: ContourPolygon2D.GetComplexity +* Description: Calculates the complexity of the polygon. +* Returns: +* {Complexity} the result +*/ JSM.ContourPolygon2D.prototype.GetComplexity = function () { if (this.lastContour === null) { @@ -507,6 +818,14 @@ JSM.ContourPolygon2D.prototype.GetComplexity = function () return JSM.Complexity.Complex; }; +/** +* Function: ContourPolygon2D.ToArray +* Description: +* Creates an array of vertices from polygon. The result contains +* null values between contours. +* Returns: +* {Coord2D[*]} the result +*/ JSM.ContourPolygon2D.prototype.ToArray = function () { var vertices = []; @@ -524,6 +843,14 @@ JSM.ContourPolygon2D.prototype.ToArray = function () return vertices; }; +/** +* Function: ContourPolygon2D.FromArray +* Description: +* Creates the polygon from an array of vertices. The input should contain +* null values between contours. +* Parameters: +* vertices {Coord2D[*]} the array of vertices +*/ JSM.ContourPolygon2D.prototype.FromArray = function (vertices) { this.Clear (); @@ -539,12 +866,22 @@ JSM.ContourPolygon2D.prototype.FromArray = function (vertices) } }; +/** +* Function: ContourPolygon2D.Clear +* Description: Makes the polygon empty. +*/ JSM.ContourPolygon2D.prototype.Clear = function () { this.contours = []; this.lastContour = null; }; +/** +* Function: ContourPolygon2D.Clone +* Description: Clones the polygon. +* Returns: +* {ContourPolygon2D} a cloned instance +*/ JSM.ContourPolygon2D.prototype.Clone = function () { var result = new JSM.ContourPolygon2D (); @@ -554,5 +891,4 @@ JSM.ContourPolygon2D.prototype.Clone = function () result.AddContour (contour.Clone ()); } return result; - }; diff --git a/src/geometry/sector.js b/src/geometry/sector.js index 45720a5b..630cde07 100644 --- a/src/geometry/sector.js +++ b/src/geometry/sector.js @@ -12,22 +12,6 @@ JSM.CoordSectorPosition2D = { CoordOutsideOfSector : 2 }; -/** -* Enum: OldSectorSectorPosition2D -* Description: Position of two sectors. -* Values: -* {SectorsDontIntersect} sectors do not intersect -* {SectorsIntersectCoincident} sectors intersect coincident -* {SectorsIntersectEndPoint} sectors intersect at end point -* {SectorsIntersectOnePoint} sectors intersect one point -*/ -JSM.OldSectorSectorPosition2D = { - SectorsDontIntersect : 0, - SectorsIntersectCoincident : 1, - SectorsIntersectEndPoint : 2, - SectorsIntersectOnePoint : 3 -}; - /** * Enum: SectorSectorPosition2D * Description: Position of two sectors. @@ -139,81 +123,6 @@ JSM.Sector2D.prototype.CoordPosition = function (coord) return JSM.CoordSectorPosition2D.CoordInsideOfSector; }; -/** -* Function: Sector2D.OldSectorPosition -* Description: Calculates the position of the sector and the given sector. -* Parameters: -* sector {Sector2D} the sector -* intersection {Coord2D} (out) the intersection point if it exists -* Returns: -* {OldSectorSectorPosition2D} the result -*/ -JSM.Sector2D.prototype.OldSectorPosition = function (sector, intersection) -{ - var aSector = this; - var bSector = sector; - - var x1 = aSector.beg.x; - var y1 = aSector.beg.y; - var x2 = aSector.end.x; - var y2 = aSector.end.y; - var x3 = bSector.beg.x; - var y3 = bSector.beg.y; - var x4 = bSector.end.x; - var y4 = bSector.end.y; - var ux = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var uy = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - - if (JSM.IsZero (ux) && JSM.IsZero (uy)) { - var aBeg = bSector.CoordPosition (aSector.beg); - var aEnd = bSector.CoordPosition (aSector.end); - var bBeg = aSector.CoordPosition (bSector.beg); - var bEnd = aSector.CoordPosition (bSector.end); - if (aBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || aEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector || bBeg === JSM.CoordSectorPosition2D.CoordInsideOfSector || bEnd === JSM.CoordSectorPosition2D.CoordInsideOfSector) { - return JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident; - } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord && bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - return JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident; - } else if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord || bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - if (intersection !== undefined) { - if (aBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - intersection = aSector.beg.Clone (); - } else if (aEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - intersection = aSector.end.Clone (); - } else if (bBeg === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - intersection = bSector.beg.Clone (); - } else if (bEnd === JSM.CoordSectorPosition2D.CoordOnSectorEndCoord) { - intersection = bSector.end.Clone (); - } - } - return JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint; - } - - return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; - } - - var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - if (JSM.IsZero (denom)) { - return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; - } - - ux /= denom; - uy /= denom; - if (JSM.IsLower (ux, 0.0) || JSM.IsGreater (ux, 1.0) || JSM.IsLower (uy, 0.0) || JSM.IsGreater (uy, 1.0)) { - return JSM.OldSectorSectorPosition2D.SectorsDontIntersect; - } - - if (intersection !== undefined) { - intersection.x = x1 + ux * (x2 - x1); - intersection.y = y1 + ux * (y2 - y1); - } - - if (JSM.IsEqual (ux, 0.0) || JSM.IsEqual (ux, 1.0) || JSM.IsEqual (uy, 0.0) || JSM.IsEqual (uy, 1.0)) { - return JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint; - } - - return JSM.OldSectorSectorPosition2D.SectorsIntersectOnePoint; -}; - /** * Function: Sector2D.SectorPosition * Description: Calculates the position of the sector and the given sector. diff --git a/src/geometry/triangulation.js b/src/geometry/triangulation.js index ca9daff6..f81a5444 100644 --- a/src/geometry/triangulation.js +++ b/src/geometry/triangulation.js @@ -18,7 +18,7 @@ JSM.ConvertContourPolygonToPolygon2D = function (inputPolygon, vertexMap) { var sector = new JSM.Sector2D (segmentBeg, segmentEnd); var position = polygon.SectorPosition (sector, -1, -1); - if (position == JSM.SectorPolygonPosition.IntersectionOnePoint || position == JSM.SectorPolygonPosition.IntersectionCoincident) { + if (position == JSM.SectorPolygonPosition2D.IntersectionOnePoint || position == JSM.SectorPolygonPosition2D.IntersectionCoincident) { return true; } return false; diff --git a/test/unittest/jsmodelertest.js b/test/unittest/jsmodelertest.js index add9208b..6dec00a1 100644 --- a/test/unittest/jsmodelertest.js +++ b/test/unittest/jsmodelertest.js @@ -25,7 +25,6 @@ unitTest.AddSourceFile ('../../src/geometry/convexhull.js'); unitTest.AddSourceFile ('../../src/geometry/polygon2d.js'); unitTest.AddSourceFile ('../../src/geometry/polygon.js'); unitTest.AddSourceFile ('../../src/geometry/triangulation.js'); -unitTest.AddSourceFile ('../../src/geometry/oldpolygon.js'); unitTest.AddSourceFile ('../../src/geometry/octree.js'); unitTest.AddSourceFile ('../../src/geometry/bsptree.js'); unitTest.AddSourceFile ('../../src/geometry/utilities.js'); diff --git a/test/unittest/tests/geometry.js b/test/unittest/tests/geometry.js index dbf6ab3b..754d467a 100644 --- a/test/unittest/tests/geometry.js +++ b/test/unittest/tests/geometry.js @@ -808,7 +808,7 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector1 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (0.0, 2.0), new JSM.Coord2D (1.0, 2.0)); - test.Assert (sector1.OldSectorPosition (sector2) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector1.SectorPosition (sector2) == JSM.SectorSectorPosition2D.SectorsDontIntersect); var sector1 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (1.0, 2.0)); var sector2 = new JSM.Sector2D (new JSM.Coord2D (1.0, 2.0), new JSM.Coord2D (4.0, 3.0)); @@ -816,50 +816,50 @@ generalSuite.AddTest ('SectorSectorPositionTest', function (test) var sector4 = new JSM.Sector2D (new JSM.Coord2D (0.0, 1.0), new JSM.Coord2D (1.0, 1.0)); var intersection = new JSM.Coord2D (0.0, 0.0); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 0.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (1.0, 1.0))); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 3.0, 1.0), intersection) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); test.Assert (intersection.IsEqual (new JSM.Coord2D (3.0, 1.0))); - test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 1.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 1.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - - test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 1.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 0.0, 4.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - - test.Assert (sector3.OldSectorPosition (GetSector2D (-1.0, 1.0, 0.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 0.0, 2.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 0.0, 3.0, 0.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (1.0, 2.0, 3.0, 2.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 1.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (3.0, 1.0, 4.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (sector3.OldSectorPosition (GetSector2D (0.0, 1.0, 2.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 2.5, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.OldSectorPosition (GetSector2D (2.0, 1.0, 4.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 1.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 0.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 0.0, 4.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsIntersectOnePoint); + + test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, 0.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 0.0, 2.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 0.0, 3.0, 0.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (1.0, 2.0, 3.0, 2.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (3.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (sector3.SectorPosition (GetSector2D (0.0, 1.0, 2.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 2.5, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (sector3.SectorPosition (GetSector2D (2.0, 1.0, 4.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (sector3.OldSectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (sector3.OldSectorPosition (GetSector2D (-1.0, 1.0, -3.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (4.0, 1.0, 5.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (sector3.SectorPosition (GetSector2D (-1.0, 1.0, -3.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (-1.0, 1.0, 0.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (4.0, 1.0, 5.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (0.0, 0.0, 2.0, 0.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (1.0, 0.0, 3.0, 0.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (1.0, 2.0, 3.0, 2.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (0.0, 1.0, 1.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (GetSector2D (3.0, 1.0, 4.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectEndPoint); - test.Assert (GetSector2D (0.0, 1.0, 2.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 2.5, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 3.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (2.0, 1.0, 4.0, 1.0).OldSectorPosition (sector3) == JSM.OldSectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (-1.0, 1.0, 0.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (4.0, 1.0, 5.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 0.0, 2.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 0.0, 3.0, 0.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (1.0, 2.0, 3.0, 2.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 1.0, 1.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (3.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectEndPoint); + test.Assert (GetSector2D (0.0, 1.0, 2.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 2.5, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 3.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); + test.Assert (GetSector2D (2.0, 1.0, 4.0, 1.0).SectorPosition (sector3) == JSM.SectorSectorPosition2D.SectorsIntersectCoincident); - test.Assert (GetSector2D (0.0, 0.0, 1.0, 1.0).OldSectorPosition (GetSector2D (3.0, 0.0, 3.0, 3.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); - test.Assert (GetSector2D (3.0, 0.0, 3.0, 3.0).OldSectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0)) == JSM.OldSectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (0.0, 0.0, 1.0, 1.0).SectorPosition (GetSector2D (3.0, 0.0, 3.0, 3.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); + test.Assert (GetSector2D (3.0, 0.0, 3.0, 3.0).SectorPosition (GetSector2D (0.0, 0.0, 1.0, 1.0)) == JSM.SectorSectorPosition2D.SectorsDontIntersect); }); generalSuite.AddTest ('SectorSectorPositionTest2', function (test) @@ -1559,30 +1559,30 @@ polygonSuite.AddTest ('CoordPolygonPosition2DTest', function (test) polygon.AddVertex (3.0, 2.0); polygon.AddVertex (1.5, 3.0); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 5.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 3.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 4.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 0.5)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 2.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)) == JSM.CoordPolygonPosition.Outside); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.5)) == JSM.CoordPolygonPosition.OnEdge); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.0)) == JSM.CoordPolygonPosition.OnEdge); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.5)) == JSM.CoordPolygonPosition.OnEdge); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.0)) == JSM.CoordPolygonPosition.OnEdge); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.0)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 5.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 3.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 4.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 0.5)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 2.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)) == JSM.CoordPolygonPosition2D.Outside); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.5)) == JSM.CoordPolygonPosition2D.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.0)) == JSM.CoordPolygonPosition2D.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.5)) == JSM.CoordPolygonPosition2D.OnEdge); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.0)) == JSM.CoordPolygonPosition2D.OnEdge); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)) == JSM.CoordPolygonPosition2D.OnVertex); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.0)) == JSM.CoordPolygonPosition2D.Inside); }); polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) @@ -1625,24 +1625,24 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) test.Assert (GetVisibleVertices (polygon, 6).toString () == [0].toString ()); test.Assert (GetVisibleVertices (polygon, 7).toString () == [5].toString ()); - test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 5) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 0.8, 0.8), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1.5, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); - test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 0.8, 1.5), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); - test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnePoint); - test.Assert (polygon.SectorPosition (GetSector (1.1, 1.5, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), 6, -1) == JSM.SectorPolygonPosition.NoIntersection); - test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, 3) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 5) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 0.8, 0.8), -1, -1) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1, 1), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.3, 0.3, 1.5, 1.5), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 0.8, 1.5), -1, -1) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 1.5), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (0.5, 1.5, 1, 2.5), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.Assert (polygon.SectorPosition (GetSector (1.1, 1.5, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 1.9, 1.5), 6, -1) == JSM.SectorPolygonPosition2D.NoIntersection); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon.SectorPosition (GetSector (1, 2, 2, 2), 6, 3) == JSM.SectorPolygonPosition2D.NoIntersection); var polygon2 = new JSM.Polygon2D (); polygon2.AddVertex (118, 121); @@ -1689,8 +1689,8 @@ polygonSuite.AddTest ('PolygonVertexVisibility2DTest', function (test) polygon4.AddVertex (3, 3); polygon4.AddVertex (0, 3); - test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition.IntersectionOnVertex); - test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition.NoIntersection); + test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), -1, -1) == JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.Assert (polygon4.SectorPosition (GetSector (0, 0, 1, 1), 0, -1) == JSM.SectorPolygonPosition2D.NoIntersection); }); polygonSuite.AddTest ('PolygonTriangulationTest', function (test) diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index 14173036..44d398fa 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -449,6 +449,8 @@ simpleSuite.AddTest ('FromToArrayTest', function (test) test.AssertEqual (polygon.GetOrientation (), polygon2.GetOrientation ()); test.AssertEqual (polygon.GetComplexity (), polygon2.GetComplexity ()); + test.AssertEqual (polygon.GetLastContour ().VertexCount (), polygon.GetContour (1).VertexCount ()); + var polygon = new JSM.Polygon (); polygon.AddVertex (0, 0, 1); polygon.AddVertex (1, 0, 1); @@ -478,6 +480,8 @@ simpleSuite.AddTest ('FromToArrayTest', function (test) var polygon2 = new JSM.ContourPolygon (); polygon2.FromArray (polygon.ToArray ()); test.Assert (IsEqualContourPolygons (polygon, polygon2)); + + test.AssertEqual (polygon.GetLastContour ().VertexCount (), polygon.GetContour (1).VertexCount ()); }); var pointInPolygonSuite = unitTest.AddTestSuite ('PointInPolygonTest'); @@ -490,26 +494,26 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon.AddVertex (2.0, 2.0); polygon.AddVertex (0.0, 2.0); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)), JSM.CoordPolygonPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 0.0)), JSM.CoordPolygonPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)), JSM.CoordPolygonPosition.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)), JSM.CoordPolygonPosition.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)), JSM.CoordPolygonPosition2D.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 0.0)), JSM.CoordPolygonPosition2D.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)), JSM.CoordPolygonPosition2D.OnVertex); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 2.0)), JSM.CoordPolygonPosition2D.OnVertex); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.0)), JSM.CoordPolygonPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 2.0)), JSM.CoordPolygonPosition.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 0.0)), JSM.CoordPolygonPosition2D.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition2D.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 2.0)), JSM.CoordPolygonPosition2D.OnEdge); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition2D.OnEdge); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)), JSM.CoordPolygonPosition.Inside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 1.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)), JSM.CoordPolygonPosition2D.Inside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 1.0)), JSM.CoordPolygonPosition2D.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 0.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 2.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 0.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 2.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (-1.0, 3.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)), JSM.CoordPolygonPosition2D.Outside); var polygon2 = new JSM.Polygon2D (); polygon2.AddVertex (0.0, 0.0); @@ -517,13 +521,13 @@ pointInPolygonSuite.AddTest ('PointInPolygonConvexTest', function (test) polygon2.AddVertex (0.0, 2.0); polygon2.AddVertex (-1.0, 1.0); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition.Inside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 0.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.CoordPolygonPosition.Outside); - test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 2.0)), JSM.CoordPolygonPosition.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.0, 1.0)), JSM.CoordPolygonPosition2D.Inside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-2.0, 1.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (2.0, 1.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 0.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 0.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (-0.5, 2.0)), JSM.CoordPolygonPosition2D.Outside); + test.AssertEqual (polygon2.CoordPosition (new JSM.Coord2D (0.5, 2.0)), JSM.CoordPolygonPosition2D.Outside); }); var diagonalSuite = unitTest.AddTestSuite ('IsDiagonalSuite'); @@ -1036,24 +1040,24 @@ polygonSectorTest.AddTest ('PolygonSectorPositionTest01', function (test) polygon.AddVertex (1.0, 1.0); polygon.AddVertex (0.0, 1.0); - test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 3, 0), -1, -1), JSM.SectorPolygonPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 2, 1), -1, -1), JSM.SectorPolygonPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 3, 0), -1, -1), JSM.SectorPolygonPosition2D.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 2, 1), -1, -1), JSM.SectorPolygonPosition2D.NoIntersection); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 2, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 2, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionCoincident); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0, 0, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionCoincident); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 2, 2), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (2, 2, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 2, 2), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 2, 1, 1), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 2, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (GetSector (2, 0.5, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 2, 0.5), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (2, 0.5, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (-1.0, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1), new JSM.Coord2D (-1.0, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (-1.0, 0.5, 1, 1), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnePoint); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1), new JSM.Coord2D (-1.0, 0.5), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnePoint); }); polygonSectorTest.AddTest ('PolygonSectorPositionTest02', function (test) @@ -1072,19 +1076,19 @@ polygonSectorTest.AddTest ('PolygonSectorPositionTest02', function (test) polygon.AddVertex (1.0, 1.0); polygon.AddVertex (0.0, 1.0); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1), JSM.SectorPolygonPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), 0, -1), JSM.SectorPolygonPosition.NoIntersection); - - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), -1, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, -1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 1), JSM.SectorPolygonPosition.IntersectionOnVertex); - test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 2), JSM.SectorPolygonPosition.NoIntersection); - test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 2), JSM.SectorPolygonPosition.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 0.5, 0.5), 0, -1), JSM.SectorPolygonPosition2D.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (0.5, 0.5, 0, 0), 0, -1), JSM.SectorPolygonPosition2D.NoIntersection); + + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), -1, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, -1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 1), JSM.SectorPolygonPosition2D.IntersectionOnVertex); + test.AssertEqual (polygon.SectorPosition (GetSector (0, 0, 1, 1), 0, 2), JSM.SectorPolygonPosition2D.NoIntersection); + test.AssertEqual (polygon.SectorPosition (GetSector (1, 1, 0, 0), 0, 2), JSM.SectorPolygonPosition2D.NoIntersection); }); var polygonSuite = unitTest.AddTestSuite ('ContourPolygonTest'); diff --git a/test/unittest/tests/triangulation.js b/test/unittest/tests/triangulation.js index 6d925539..cae20ac7 100644 --- a/test/unittest/tests/triangulation.js +++ b/test/unittest/tests/triangulation.js @@ -253,21 +253,21 @@ simplePolygonSuite.AddTest ('OldTriangulationTest02', function (test) test.Assert (JSM.IsEqual (polygon.GetSignedArea (), 8.0)); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordPolygonPosition.OnVertex); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordPolygonPosition.OnVertex); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, -1.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 4.0)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.5)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 1.5)) == JSM.CoordPolygonPosition.Outside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition.Outside); - - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 2.5)) == JSM.CoordPolygonPosition.Inside); - test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.0, 0.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.0, 1.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.0, 2.0)) == JSM.CoordPolygonPosition2D.OnVertex); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (3.0, 3.0)) == JSM.CoordPolygonPosition2D.OnVertex); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, -1.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 4.0)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (-1.0, 1.5)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (4.0, 1.5)) == JSM.CoordPolygonPosition2D.Outside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 1.5)) == JSM.CoordPolygonPosition2D.Outside); + + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 0.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (2.5, 1.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (1.5, 2.5)) == JSM.CoordPolygonPosition2D.Inside); + test.Assert (polygon.CoordPosition (new JSM.Coord2D (0.5, 1.5)) == JSM.CoordPolygonPosition2D.Inside); var triangles = JSM.TriangulatePolygon2D (polygon); test.Assert (CheckCalculatedTriangulation (polygon, triangles)); diff --git a/test/viewertest/cameratest.html b/test/viewertest/cameratest.html index 946d2881..b219988b 100644 --- a/test/viewertest/cameratest.html +++ b/test/viewertest/cameratest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/csgtest.html b/test/viewertest/csgtest.html index dac179c3..cbd61b2c 100644 --- a/test/viewertest/csgtest.html +++ b/test/viewertest/csgtest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/importtest.html b/test/viewertest/importtest.html index 17ff4cb5..97543931 100644 --- a/test/viewertest/importtest.html +++ b/test/viewertest/importtest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/svgtomodeltest.html b/test/viewertest/svgtomodeltest.html index d7300178..c96b1348 100644 --- a/test/viewertest/svgtomodeltest.html +++ b/test/viewertest/svgtomodeltest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/texturetest.html b/test/viewertest/texturetest.html index bda5d422..08024e19 100644 --- a/test/viewertest/texturetest.html +++ b/test/viewertest/texturetest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/viewertest.html b/test/viewertest/viewertest.html index 696e4f5d..72d4693a 100644 --- a/test/viewertest/viewertest.html +++ b/test/viewertest/viewertest.html @@ -33,7 +33,6 @@ - diff --git a/test/viewertest/viewertypes.html b/test/viewertest/viewertypes.html index d37bf330..88751dd3 100644 --- a/test/viewertest/viewertypes.html +++ b/test/viewertest/viewertypes.html @@ -33,7 +33,6 @@ - diff --git a/tools/files.txt b/tools/files.txt index ebc0334a..37b0066b 100644 --- a/tools/files.txt +++ b/tools/files.txt @@ -21,7 +21,6 @@ ../src/geometry/polygon2d.js ../src/geometry/polygon.js ../src/geometry/triangulation.js -../src/geometry/oldpolygon.js ../src/geometry/octree.js ../src/geometry/bsptree.js ../src/geometry/utilities.js From f19cb82dafe91aace44b84d21939bb1e0682e489 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 3 Aug 2015 18:51:34 +0200 Subject: [PATCH 24/27] Remove svg to 3d examples which not work because of a firefox error. --- documentation/examples/svgto3d.html | 94 +++-------------------------- 1 file changed, 10 insertions(+), 84 deletions(-) diff --git a/documentation/examples/svgto3d.html b/documentation/examples/svgto3d.html index ae48a7f8..884bb070 100644 --- a/documentation/examples/svgto3d.html +++ b/documentation/examples/svgto3d.html @@ -161,26 +161,6 @@ -
-
- - From d52944c5bd22843052121807d64ce0605ce969dd Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 6 Aug 2015 20:10:59 +0200 Subject: [PATCH 25/27] Remove old generator reference. --- documentation/reference/generator.html | 1128 ----------------- documentation/reference/images/circle.png | Bin 3853 -> 0 bytes documentation/reference/images/cone.png | Bin 8931 -> 0 bytes documentation/reference/images/cuboid.png | Bin 4459 -> 0 bytes .../reference/images/cuboidsides.png | Bin 2326 -> 0 bytes documentation/reference/images/cylinder.png | Bin 7818 -> 0 bytes .../reference/images/cylindershell.png | Bin 9498 -> 0 bytes .../reference/images/functionsurface.png | Bin 8161 -> 0 bytes .../reference/images/functionsurfacesolid.png | Bin 7319 -> 0 bytes documentation/reference/images/lineshell.png | Bin 4750 -> 0 bytes documentation/reference/images/pie.png | Bin 5721 -> 0 bytes documentation/reference/images/polytorus.png | Bin 9334 -> 0 bytes documentation/reference/images/prism.png | Bin 4408 -> 0 bytes documentation/reference/images/prismshell.png | Bin 4679 -> 0 bytes .../reference/images/prismwithhole.png | Bin 4747 -> 0 bytes documentation/reference/images/rectangle.png | Bin 3721 -> 0 bytes documentation/reference/images/revolved.png | Bin 9772 -> 0 bytes .../reference/images/ruledfromcoords.png | Bin 7585 -> 0 bytes .../reference/images/ruledfromsectors.png | Bin 7014 -> 0 bytes .../images/ruledfromsectorswithheight.png | Bin 6902 -> 0 bytes .../reference/images/segmentedcuboid.png | Bin 4456 -> 0 bytes .../reference/images/segmentedrectangle.png | Bin 3721 -> 0 bytes documentation/reference/images/sphere.png | Bin 13769 -> 0 bytes documentation/reference/images/torus.png | Bin 14209 -> 0 bytes .../reference/images/triangulatedsphere.png | Bin 13494 -> 0 bytes documentation/reference/include/generator.css | 80 -- sandbox/docimages.html | 305 ----- 27 files changed, 1513 deletions(-) delete mode 100644 documentation/reference/generator.html delete mode 100644 documentation/reference/images/circle.png delete mode 100644 documentation/reference/images/cone.png delete mode 100644 documentation/reference/images/cuboid.png delete mode 100644 documentation/reference/images/cuboidsides.png delete mode 100644 documentation/reference/images/cylinder.png delete mode 100644 documentation/reference/images/cylindershell.png delete mode 100644 documentation/reference/images/functionsurface.png delete mode 100644 documentation/reference/images/functionsurfacesolid.png delete mode 100644 documentation/reference/images/lineshell.png delete mode 100644 documentation/reference/images/pie.png delete mode 100644 documentation/reference/images/polytorus.png delete mode 100644 documentation/reference/images/prism.png delete mode 100644 documentation/reference/images/prismshell.png delete mode 100644 documentation/reference/images/prismwithhole.png delete mode 100644 documentation/reference/images/rectangle.png delete mode 100644 documentation/reference/images/revolved.png delete mode 100644 documentation/reference/images/ruledfromcoords.png delete mode 100644 documentation/reference/images/ruledfromsectors.png delete mode 100644 documentation/reference/images/ruledfromsectorswithheight.png delete mode 100644 documentation/reference/images/segmentedcuboid.png delete mode 100644 documentation/reference/images/segmentedrectangle.png delete mode 100644 documentation/reference/images/sphere.png delete mode 100644 documentation/reference/images/torus.png delete mode 100644 documentation/reference/images/triangulatedsphere.png delete mode 100644 documentation/reference/include/generator.css delete mode 100644 sandbox/docimages.html diff --git a/documentation/reference/generator.html b/documentation/reference/generator.html deleted file mode 100644 index af666463..00000000 --- a/documentation/reference/generator.html +++ /dev/null @@ -1,1128 +0,0 @@ - - - - - - - - - JSModeler Generator Documentation - - - - -
-
JSModeler Generator Documentation
- -
JSM.GenerateRectangle
-
-
Description
-
- Generates a rectangle. The center of the rectangle will be the origo. -
-
Parameters
-
- - - - - - - - - - - -
xSizenumberX size of the rectangle.
ySizenumberY size of the rectangle.
-
-
Example
-
-
-var body = JSM.GenerateRectangle (1.0, 1.0);
-
- -
-
- -
JSM.GenerateCuboid
-
-
Description
-
- Generates a cuboid. The center of the cuboid will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - -
xSizenumberX size of the cuboid.
ySizenumberY size of the cuboid.
zSizenumberZ size of the cuboid.
-
-
Example
-
-
-var body = JSM.GenerateCuboid (1.0, 1.0, 1.0);
-
- -
-
- -
JSM.GenerateCuboidSides
-
-
Description
-
- Generates cuboid sides. The center of the cuboid will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
xSizenumberX size of the cuboid.
ySizenumberY size of the cuboid.
zSizenumberZ size of the cuboid.
sides[boolean]Generate value for each side.
-
-
Example
-
-
-var body = JSM.GenerateCuboidSides (1.0, 1.0, 1.0, [1, 1, 1, 0, 1, 0]);
-
- -
-
- -
JSM.GenerateSegmentedRectangle
-
-
Description
-
- Generates a rectangle with segmented sides. The center of the rectangle will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
xSizenumberX size of the rectangle.
ySizenumberY size of the rectangle.
xSegmentationintegerSegmentation number along the x axis.
ySegmentationintegerSegmentation number along the y axis.
-
-
Example
-
-
-var body = JSM.GenerateSegmentedRectangle (1, 1, 4, 4);
-
- -
-
- -
JSM.GenerateSegmentedCuboid
-
-
Description
-
- Generates a cuboid with segmented sides. The center of the cuboid will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
xSizenumberX size of the cuboid.
ySizenumberY size of the cuboid.
zSizenumberZ size of the cuboid.
segmentationintegerSegmentation number.
-
-
Example
-
-
-var body = JSM.GenerateSegmentedCuboid (1, 1, 1, 4);
-
- -
-
- -
JSM.GenerateCircle
-
-
Description
-
- Generates a circle. The center of the circle will be the origo. -
-
Parameters
-
- - - - - - - - - - - -
radiusnumberRadius of the circle.
segmentationintegerSegmentation number.
-
-
Example
-
-
-var body = JSM.GenerateCircle (1.0, 50);
-
- -
-
- -
JSM.GenerateSphere
-
-
Description
-
- Generates a sphere. The center of the sphere will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - -
radiusnumberRadius of the sphere.
segmentationintegerSegmentation number.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateSphere (1, 50, true);
-
- -
-
- -
JSM.GenerateTriangulatedSphere
-
-
Description
-
- Generates a sphere from triangles. The center of the sphere will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - -
radiusnumberRadius of the sphere.
segmentationintegerSegmentation number.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateTriangulatedSphere (1, 3, true);
-
- -
-
- -
JSM.GenerateCylinder
-
-
Description
-
- Generates a cylinder. The center of the cylinder will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
radiusnumberRadius of the cylinder.
heightnumberHeight of the cylinder.
segmentationintegerSegmentation number.
withTopAndBottombooleanTop and bottom surfaces.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateCylinder (0.5, 1.0, 50, true, true);
-
- -
-
- -
JSM.GeneratePie
-
-
Description
-
- Generates a pie. The center of the pie will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
radiusnumberRadius of the pie.
heightnumberHeight of the pie.
anglenumberAngle of the pie.
segmentationintegerSegmentation number.
withTopAndBottombooleanTop and bottom surfaces.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GeneratePie (1.0, 0.2, 270 * JSM.DegRad, 50, true, true);
-
- -
-
- -
JSM.GenerateCone
-
-
Description
-
- Generates a cone. The center of the cone will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
topRadiusnumberTop radius of the cone (can be 0.0).
bottomRadiusnumberBottom radius of the cone (can be 0.0).
heightnumberHeight of the the cone.
segmentationintegerSegmentation number.
withTopAndBottombooleanTop and bottom surfaces.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateCone (0.2, 0.6, 1.0, 50, true, true);
-
- -
-
- -
JSM.GeneratePrism
-
-
Description
-
- Generates a prism. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
basePolygon[coordinate]The base polygon of the prism defined by its coordinates.
directionvectorBase polygon offset direction.
heightnumberHeight of the prism.
withTopAndBottombooleanTop and bottom surfaces.
-
-
Example
-
-
-var basePolygon = [
-	new JSM.Coord (-1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 0.0, 0.0),
-	new JSM.Coord (-1.0, 0.0, 0.0)
-];
-var direction = new JSM.Vector (0.0, 0.0, 1.0);
-var body = JSM.GeneratePrism (basePolygon, direction, 1.0, true);
-
- -
-
- -
JSM.GeneratePrismWithHole
-
-
Description
-
- Generates a prism. The base polygon can contain holes. The top and bottom polygons are triangulated. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
basePolygon[coordinate]The base polygon of the prism defined by its coordinates. Hole definitions must be started with a null element, and must be in reversed orientation.
directionvectorBase polygon offset direction.
heightnumberHeight of the prism.
withTopAndBottombooleanTop and bottom surfaces.
-
-
Example
-
-
-var basePolygon = [
-	new JSM.Coord (-1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, 1.0, 0.0),
-	new JSM.Coord (-1.0, 1.0, 0.0),
-	null,
-	new JSM.Coord (-0.5, 0.5, 0.0),
-	new JSM.Coord (0.5, 0.5, 0.0),
-	new JSM.Coord (0.5, -0.5, 0.0),
-	new JSM.Coord (-0.5, -0.5, 0.0)
-];
-var direction = new JSM.Vector (0.0, 0.0, 1.0);
-var body = JSM.GeneratePrismWithHole (basePolygon, direction, 1.0, true);
-
- -
-
- -
JSM.GeneratePrismShell
-
-
Description
-
- Generates a prism shell. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
basePolygon[coordinate]The base polygon of the prism defined by its coordinates.
directionvectorBase polygon offset direction.
heightnumberHeight of the prism.
widthnumberWidth of the shell.
withTopAndBottombooleanTop and bottom surfaces.
-
-
Example
-
-
-var basePolygon = [
-	new JSM.Coord (-1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 0.0, 0.0),
-	new JSM.Coord (-1.0, 0.0, 0.0)
-];
-var direction = new JSM.Vector (0.0, 0.0, 1.0);
-var body = JSM.GeneratePrismShell (basePolygon, direction, 1.0, 0.2, true);
-
- -
-
- -
JSM.GenerateCylinderShell
-
-
Description
-
- Generates a cylinder shell. The center of the cylinder will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
radiusnumberRadius of the cylinder.
heightnumberHeight of the cylinder.
widthnumberWidth of the shell.
segmentationintegerSegmentation number.
withTopAndBottombooleanTop and bottom surfaces.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateCylinderShell (0.5, 1.0, 0.1, 50, true, true);
-
- -
-
- -
JSM.GenerateLineShell
-
-
Description
-
- Generates a polyline shell. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
basePolyLine[coordinate]The base polyline of the prism defined by its coordinates.
directionvectorBase polyline offset direction.
heightnumberHeight of the prism.
widthnumberWidth of the shell.
withStartAndEndbooleanStart and end surfaces.
withTopAndBottombooleanTop and bottom surfaces.
-
-
Example
-
-
-var basePolyLine = [
-	new JSM.Coord (-1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 0.0, 0.0),
-	new JSM.Coord (-1.0, 0.0, 0.0)
-];
-var direction = new JSM.Vector (0.0, 0.0, 1.0);
-var body = JSM.GenerateLineShell (basePolyLine, direction, 1.0, 0.2, true, true);
-
- -
-
- -
JSM.GenerateTorus
-
-
Description
-
- Generates a torus. The center of the torus will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
outerRadiusnumberOuter radius of the torus.
innerRadiusnumberInner (cross section) radius of the torus.
outerSegmentationintegerOuter segmentation number.
innerSegmentationintegerInner (cross section) segmentation number.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var body = JSM.GenerateTorus (1.0, 0.5, 50, 50, true);
-
- -
-
- -
JSM.GeneratePolyTorus
-
-
Description
-
- Generates a torus with a polygon cross section. The center of the torus will be the origo. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
basePolygon[coordinate]The base polygon of the torus cross section.
outerRadiusnumberOuter radius of the torus.
outerSegmentationintegerOuter segmentation number.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var basePolygon = [
-	new JSM.Coord (-1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, -1.0, 0.0),
-	new JSM.Coord (1.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 1.0, 0.0),
-	new JSM.Coord (0.0, 0.0, 0.0),
-	new JSM.Coord (-1.0, 0.0, 0.0)
-];
-var direction = new JSM.Vector (0.0, 0.0, 1.0);
-var body = JSM.GeneratePolyTorus (basePolygon, 2.0, 50, true);
-
- -
-
- -
JSM.GenerateRuledFromSectors
-
-
Description
-
- Generates ruled surface between two sectors. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
aSectorsectorThe first sector.
bSectorsectorThe second sector.
lineSegmentationintegerSegmentation along sectors.
meshSegmentationintegerSegmentation along surface.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var aSector = new JSM.Sector (new JSM.Coord (-1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0));
-var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -1.0), new JSM.Coord (0.0, 1.0, 1.0));
-var body = JSM.GenerateRuledFromSectors (aSector, bSector, 50, 50, true);
-
- -
-
- -
JSM.GenerateRuledFromSectorsWithHeight
-
-
Description
-
- Generates ruled surface between two sectors, and generates a height for it. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aSectorsectorThe first sector.
bSectorsectorThe second sector.
lineSegmentationintegerSegmentation along sectors.
meshSegmentationintegerSegmentation along surface.
isCurvedbooleanSmooth surface.
isCurvedbooleanSmooth surface.
heightnumberHeight.
-
-
Example
-
-
-var aSector = new JSM.Sector (new JSM.Coord (-1.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0));
-var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -1.0), new JSM.Coord (0.0, 1.0, 1.0));
-var body = JSM.GenerateRuledFromSectorsWithHeight (aSector, bSector, 50, 50, true, 0.2);
-
- -
-
- -
JSM.GenerateRuledFromCoords
-
-
Description
-
- Generates ruled surface between two coordinate array. The arrays have to contain the same number of coordinates. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - -
aCoords[coordinate]The first array of coords.
bCoords[coordinate]The second array of coords.
meshSegmentationintegerSegmentation along surface.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var aCoords = [
-	new JSM.Coord (0.0, 0.0, 0.0),
-	new JSM.Coord (0.0, 1.0, 1.0),
-	new JSM.Coord (0.0, 2.0, 0.0),
-	new JSM.Coord (0.0, 3.0, 1.0),
-	new JSM.Coord (0.0, 4.0, 0.0)
-];
-var bCoords = [
-	new JSM.Coord (2.0, 0.0, 1.0),
-	new JSM.Coord (2.0, 1.0, 0.0),
-	new JSM.Coord (2.0, 2.0, 1.0),
-	new JSM.Coord (2.0, 3.0, 0.0),
-	new JSM.Coord (2.0, 4.0, 1.0)
-];
-var body = JSM.GenerateRuledFromCoords (aCoords, bCoords, 50, true);
-
- -
-
- -
JSM.GenerateRevolved
-
-
Description
-
- Generates revolved surface of a polyline around an axis. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
polyLine[coordinate]The polyline to revolve.
axissectorThe axis of the revolve.
anglenumberThe angle of the revolve. Top and bottom surfaces generated only if this angle is 360 degree.
segmentationintegerSegmentation number.
withTopAndBottombooleanTop and bottom surfaces.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-var polyLine = [
-	new JSM.Coord (0.0, -1.0, -1.0),
-	new JSM.Coord (0.0, -0.5, 0.0),
-	new JSM.Coord (0.0, -1.0, 1.0)
-];
-var axis = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));
-var body = JSM.GenerateRevolved (polyLine, axis, 360.0 * JSM.DegRad, 50, true, 'CurveSegments');
-
- -
-
- -
JSM.GenerateFunctionSurface
-
-
Description
-
- Generates the surface of a 3D function. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
function3DfunctionThe function.
intervalMincoordinateThe interval minimum of the surface.
intervalMaxcoordinateThe interval maximum of the surface.
segmentationintegerSegmentation number.
isCurvedbooleanSmooth surface.
-
-
Example
-
-
-function TheFunction (x, y) {
-	return x * x - y * y;
-}
-var min = new JSM.Coord2D (-0.5, -0.5);
-var max = new JSM.Coord2D (0.5, 0.5);
-var body = JSM.GenerateFunctionSurface (TheFunction, min, max, 50, true);
-
- -
-
- -
JSM.GenerateFunctionSurfaceSolid
-
-
Description
-
- Generates a cuboid with the surface of a 3D function on the top. -
-
Parameters
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function3DfunctionThe function.
intervalMincoordinateThe interval minimum of the surface.
intervalMaxcoordinateThe interval maximum of the surface.
segmentationintegerSegmentation number.
isCurvedbooleanSmooth surface.
bottomZnumberThe bottom coordinate of the surface.
-
-
Example
-
-
-function TheFunction (x, y) {
-	return x * x - y * y;
-}
-var min = new JSM.Coord2D (-0.5, -0.5);
-var max = new JSM.Coord2D (0.5, 0.5);
-var body = JSM.GenerateFunctionSurfaceSolid (TheFunction, min, max, 50, true, 0.5);
-
- -
-
- -
- - - diff --git a/documentation/reference/images/circle.png b/documentation/reference/images/circle.png deleted file mode 100644 index 70bb2ecd68ab0bd15232258cae9f685579922c17..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3853 zcmchZ=Qo^<7R4VSdW$Z|tC!KDCVCmY1~ZK4b%=->HOlBML>(m~NXFg zjZygOSqA_B7304m0t#QV0RW|`Cm8(bk%v#9Pk@JyFSkAz%#?4FE#sQ5JBB z#SV)Ke)&YxFey66(8rvaoZDP8HJT|?5X3`4Z;-@O`kmRV>yEZI3CBQ55^;KZbQ-gn z7S$gc-q?DnH)$q4oGi~^-(W{TMs@pZksK#-!PIBrzJsC5(XzEJMdv|`s z_V@O!Zb+yjDEWN>dh$kBo&W+L5pWi%tSrjgN%k2a3YnrJ2Re<5I`4BPUeoPr7T6L+ z#}Rb~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ode 100644 index 79f856597545cf62e714fa742217893d5c85b8a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8931 zcmaKxRZyKx)2<)ff(CaFPH=a(5Pae89vp&ea0%`NX8{Wj?hXrg3l=oE2K)0>z58@m zT|GTVJvH}q^-T4A`}|1`9hDdr0049ad1>{3e&m0K4Et}S78Dr$=TKbab=?2}?fw4@ z2FS`G1OQZ3TPdl}pKYAoo!xAlT__c#q$pj!I9u5|SOS3eYOaR0rp6Jz$o=Mxq*7GS zcO_?aJY-6B$(SJABzh()6fDIks=^gKwO(u)8F-SBf+)E7_@G!kHI{eLsLM!uR7LTj zKcb??p0@pd*e`b6|DJqpS`s|~U*|SVA@v}?OOxkP;|Y3KAxVz?D|C2ZXnT)MJQ$VM z1;9dXu%L2#p@9J&0)&N`se6#R02uE%G-RMhCA;S%Y2+K`v1FzJOi&n1k9!io5^@kO zAnqG4Sqg~D!UW}J&}#q%@PNsI70>CmW@KHg>N*;i;06kDFw0Z#f9q>^tDx493_XA8uXlT5F zuuK3~_DVfT697<($i0Jhx&W?os?8;FC1 z5Q7|Fi|EeaZH&+gJnmzx>M_NefP$k{ooko>X(LmZ*t)W^zqhxnI3THSI;P|QYTakt zqx0hM7$E$7fBUOzhc=kgFjx-$;aA_pjdBU;R5D7K+4}DUx#t$Nw`a0B>H!6_RuB{J zt{RSOymVIVHD?L+H_2qiLAu#Di=8c&Cpgh99spt|3gef=T5f0#cc=6L3*_Fja}NMl z?asaP49IXnHlf>7UT^1OFLDKRK#-L}vMT@>Nz<}vjx~r4BLjeRK`;|Ug5;)`kfjHa zv=?E$7wy@EH%yXtpidG@64fGz^ot22I7E^mViH2eWWqi#PR8A%W)qR(g2C3O^%FzH z1@o^da$YY(M=%P!#0c_xQ>xV{7_(>)O*}F|X7~eDuRJ_X3@zno6s{VzQWB3mhkCRo zrItL|mB<%Zfk*?{wj`kufHUMdqC<}3dvLv)$o#t|sn&8n;xO4Fv}p@>j;sXyg6!!p zjl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id.png deleted file mode 100644 index 979303beaf85d12854ef9c0f061519ffbd2d1e76..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4459 zcmZuzc|26#`@hye))86BS@HgILO$R^v&uYijR?ByDYX%`i8u|=T`8j0?Z`=C(*}0z5$WBhuPs| zfc*;r7+HQQz|ZQQpbdE51j+}kpXvbMHGs{-s6z>ukOZz7*m&pzgnEEDz(iLK(9i?d zED~bH0m^W|sar@W1c=E7*mQSnRQ^a*GOfZ%mCCMGX}GGS6J<{$=?}57k>V2@FyN42 zQ*b7C#%V~kg=TZgM#(dN-~9pr`Kd5cw!5bx1D7fX1{9L(E;&lBw@{x8y0|Qztqhjk z(*S^lz=)wUgmev8zvUTBqm6Ny`H`Y` zQcrh&!uw6I!@#8hgtIMKu=poyh9c54dSNj5d|UlgFJBml^e{;C2LK1{t5T@m8ucz3 z0MO2lf)g~k_gXI_h}1l-R5Pt~Cr%16T30*Tw3xJ@Zjn3zPU7WHw8Y~23A}J8=@AWH zd7_19T>8CBQf=rDmsIaD{&S|uYZYsXqNUXAreSp!m`WgXc?t?8({Ncm=WD=wF4boWuUEg8c`{C=s3E(q5r1BW$aUPkCe_)lRdoYFo9^0I zC0I^h*2zV%E~jWr+;<(U3Z`U<(jn3+PzG!9JM(GkgT|oggnkJ>&sBNmDOyEZiWrMF zQNi>QqxT{onU6XyyU5DKgZc=eF_sioX{PW5WQXEamPDkiXv1@IgQ`N*Fw3y+u&<@i z8lp5uUY|=Sy=ThJyBebO0>LlQ9lM;n+`cTg%)KnIV-L-B(eN)kv|1Fi?7d^ixx%y} zze4SvC98>kgR`71d5vPeo?@p}@w(3Poke^JtNa6;QhzkNfzjKF0_-;~PY%xmuXjHK zKQhl^`Ajpv+6?!t>HW<7NwF79&kzTT?n=OjapqixT*hz)Uw)TmT*Ub;iL(oJO;Khe zYc-oO+Yb%G>);Pzsl8CFAyx#-4VOlh;*0Qecslehx(}67>R|P#QWq^}wNy$wl2L}n z=bCR=aa&1!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b*S=Y^79iyaV{u~cZ*R1_iSvb7x`)P$vThJ!I->|sT0+7U-^g7(t2WX}uu&F? zHO?e>5&?R@aIxOlRJqEN=V5M@yb*$=2_Oad*0FvRrIP?fa6uH83>!LJT$nj92s}b` z$d@Fw<186jfP`b!#M>;n;GA{AoM zog`;+;A}|`!Wewg%EARfRY75{?}7$Pp!>gUZMQ&yH<=b8 z;_b4Pz3k;HKhuD><2_Y#!4H0wRntgxdyK?fKi*0_S+%9^> zwaqT!g#EGKK4{i*B)jfIM}%h#QK>Vqf!d-cG3bJ{$J9XSgYNYaMe9$buNh#VW2#-L I<@DtL0N&e3P5=M^ diff --git a/documentation/reference/images/cuboidsides.png b/documentation/reference/images/cuboidsides.png deleted file mode 100644 index a6eaba68636ef442f3fc6ab1f15b0b004168a7df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2326 zcmcIm`Bzid77lX^1cZMq{v{e9YC~6@j>utG)uN!1jh1@8Ea@ zLbGjM6#k5^Jc2+V1wQVsRA%_(>z$miuCnQ-7K~)Ee<+3|2ilvY;OF`m#L;tD-N*-9?ZQet+unirPiroK|HDh z?)(kODRu`QZI&F~qK&i3f{J`t9sB-|q1}$c@q%n$c| zX?fJNy!vT5&2;q6_8gUoYfs9{I-JD!@5lfAVHUve68c}BJ(bbmT&u1aWm|vsM`tt; zq!%7u2%%iEZL3kjITgmB0`Z{dqERcHlVr0eXf|2=bR~-}GGW~QbS+GvCE`M%*4=|H z!nx;QkQRON_v0NL&57>t2TjY9s|k-akEjR?Jr_G!bK}GBOV?CldMcWjW-7q`v>Vvy zZ2+^*^oQOkCBggL8##u`^wAS0r>7F?wCc6Ejp;=kw0dcHb3ydt;`C7L50Y-2j#QN* zH)usIzyFkcg&`goF-q2f`C@Cp|wemQW7G8Y>K{6KNDVvghO)sLw396?cg}FDAcA~U9Sm`C2u$Gm90U9;-gZ|F~YaT!M6f~`*gW}6nTh*EQ`F+tB4D)ldYpP?`#Ak2G}FZmcIKYgbD?% zsMLI(x}T`=6DbqBA`Z~THQ(gueQ}c1zHWso429ZYgdvtIvoyzFz^=4kfOg|Au-i#& z1Mq}9Fa-C?IeQRG>~JGek%ZZ-wn|9XbOW4XNz6fk9;w!wi8)BZt4gTipgcoSO$FJT?e$5JFn8 z>l<@7$aabiV6h8zc1$G>_&?`BwK-~jt5-G_w2@^?>6fA17Q&M(-V<|RC&j2UgO_@V zttrl4WZ0V!=e)@7fFH&=+Y5-$mKJE!gW+1NTv?)G)cxyx<8*erm1^2<0%5rnr{8D@dD630#8_FU+ft>6E# zEM^4+LM9CVFOSV6AqJrFel>bM=HgDq&~=iTG4RAhW5YxYt6?`5nEL10Uam8?v>zzN^L&7oKqjb$Y9BtIN?npM?rl;_<)5(A$j22#y5l$2-j!`&DO; zo+p4$MD*n6Z(=R3am*?%0^VruM7gl!=4i?aPozPyaf;d-33n+$Z_gU~0h7fmX#6}M zHS0>sh3exHWc^%fNi;CvWJ53_YTbN_^b>SyWu|)b95N$Pr02=4kqhXQ2o{fa6{8ky zN|hV6)jGG6o!a93@Hvn!Cb~7U&xe;4HNShJPW73g@Oy7w7U4_%8biO-KEWODAKG%u z|4h%W2w;m==0fe$>-c>lb;{K#Zp0Kg=Z*IlY1;{6r00#=#tW$>%sr>2R>bR=i*H~? zyOE=Al5AHPLb4M~dtb^2&1Y=yRu4pfBw(WZ|HK>RR3x{eJW=OnLYlqQ1Qn>UwwGt} zvANU|7a*}Yq!%`q7@G>HB{o0-tqcbp{>@jeENI44_2{DLkA6Skml2oG z$D>e!d$37Jl+S6+{(kP-JEc8Me=1LVfscnj&iq|9ryxZEnKhRdDY9+NjukcQfL*%GuncTC)110iF>r;| z22@g5Cg~F19SFiNb}<#C_WX_DsYufrE5NOa%xWmVEvj`P*_6P5rl!6L2O+bC@kR&4 z-tC;wkQTvMHHJOqAANEBs`Tzg` diff --git a/documentation/reference/images/cylinder.png b/documentation/reference/images/cylinder.png deleted file mode 100644 index 63c1008d9121f3f06faff844e7378109156450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DrKnOaVp zm;d>6tuO1Q>6bp|!76o#FJ8;)cc3gVv}4Ly<5>3VE|w+bXCQDL?Kk%S z@;A{Tl3=$|1IC%1)KKwODiF<5V-`zzU9`F;yJwnUw8D!U(X(F(AG1j_S_T%ATzCGp z`}*f& ziywz4tc-GP1&iVJ=6{&!s@Ct_f|XbC70Nx_p6osUC3}a)Zm<|zxBj?lU}z#(;l)Yx z%v0f-)x%;xSPZYf{df1)t2TgDk!y&)_sn$TBMyv+BVf((`rqy!IJ~R^E4uOYbmPO$ zjD=HRF}&{nZ}$(cSp-(NHHn`2LO6126dVML;q}(LySH9jGWlK;tmV?~;nqg<^piy7 z7*dXdHOK2c3TXG%YXVPQgB4z!L|2}4lBd3al@j*%_lbzPNcHJLtzd;0C()Hl;jj<= z-5an3!h+!SyYKA(9~=g)*^KF|}M`U@7{_G8+A=fUf5Eg;ha)*Pmj;h?u& z+i$S)oDtFfKOQDOzJB+e{X2I{-XCsFh-hbWhKRz`j}uX!N%CO%)<*M>m~S2|-#l2p c^}PLm00?(^bS}YnWdHyG07*qoM6N<$f>Fd282|tP diff --git a/documentation/reference/images/cylindershell.png b/documentation/reference/images/cylindershell.png deleted file mode 100644 index 9a7f856023214e13b4df5d92529718baa55f1f10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9498 zcmV+#CFRKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$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=~Xn7K#^~9BG574ak=dG>Fs_1BB$dvJ}cUB9+dg7y* z_zJm%f&p{&>%xMyefhjpS|_{=GUgs_zO72-_(r7Qrnnrr)O4e@v{>tFLU%y3HioGu zd>X9xBP3>mV5$4BZENk3g$4_@4ciXZ0*zYl5bcCFS}|pta}ZrZVHwt$`xhE4>(ofj zKSS-Pmya-F#qi7}v$TpTkb2bG+Nk_qF{{5_y&Ct_qW?XvU?!rQLxg8?9rowl-9y9J8*tYD2AY#>jaxFqyOS#m76a zLPqQQANtjcBOF6E2%NNrHX&P~%>g8cn#lIrfo0wAWuehKhVvVw9CGKCXu#BdjN&#M zzj%G;cYdP-OWkh%`Iq&BAX7;A_BHBULieuQ`NE^MI$pDG9eDF^za#I`(N#{XKVZ!7 zuNpHuGw9EpJsK#Wn0=36q=O{kAo#`zUUr_RSjM z=6Ao{ys$#%v56MTUo{l8Ro0dDn>W7Ll#A6Q zumJ45@xku*e;|W}(DN38HU86QcQzhq(3LXLsJ655!1x=_HhW3&=jEM?AB$x1=UP77;uef;bftYPzRokoJ?TCack zNFEkNl0slfJQ=~UuZCceH~;2a)}X02xxrw$c-{JF_vKerCdz0ASYGx3;ia{?e)Ia1 zjlM382g}9lryomrg;jig!IHvP*5;-0SD&!@jlUu-0Smy+Tc7NH|J6vaG}fzVu%z5f z)VYM#mG$vgpRjuExEd`2YlhdS0Crz~HF3nDOt93k2J6cD_?fNNAk|K=e8S$o9U2_V z1S_y3QVrJl#xvI1O3RRHIao8i?!dtA%Rh_(3%SHd6MIdu~?nF zh+v6rkJx+X9)Q<=`p(`@Zp{gnwYd&reC-l|MI)&LD-Jba?;UlSzt?WP<2>1RbMnGk sb7xzuuH!nex>iCnyDsQj5$*p606{*Z2eNu+VE_OC07*qoM6N<$g0dh>L;wH) diff --git a/documentation/reference/images/functionsurface.png b/documentation/reference/images/functionsurface.png deleted file mode 100644 index e164a4366bc3d1de8d77662dc55636070a6ae5bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc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Z)X diff --git a/documentation/reference/images/polytorus.png b/documentation/reference/images/polytorus.png deleted file mode 100644 index 61d111141cf552e167305d2d8f4eada1b4a90687..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9334 zcmb7pWmBC^6XuP(1ef6M4#DN%?i^f#6Wk%VTW}BVPO#t{+&#Djcaq@F^3=Zj1Geg# z=?`NySM{_^N2w~ypdk|>0|0;~Co8G`E=T@rh|upnr2zlvyFhZ1)pZ2`6zu;R6p;0u z0059xY(OAYRcl8#M^|e{CvrIuh}_A=(bDFN1ps)h=4e=HY8>MU-)&w?C`1OPC^)L) zB9g01#026b(lSyYVai8R6s+K?^?s0&f+ZfwkA(U5Eie{WjTto>c^P4kqVQWtQDpSk z)3$Gs-D2n6!Q^Z6lE`88RZinH0t68?O_ocIClIwlg7m}hkl}%$?LAhpAY^JM028s% zoWk{m3JSRQ7ZPHkgdlVSP+s#WhyX+>8^ZoE;tk_OBGUjWFcb>nmiS2lF%Sn3^Z6!G z3W!NV1?FVXY5@7LfXVo0vt2-y1u&rtIG6_lbM7;Jp#c393S6lCM1UOIB2p5t76huN zwWFl~Fgt)_sW89~EVBUYaypi>K>beuGKGoK03f0Q>}ru=3;?VzU@}5QNa&l6>G-``^%+BSUcNl| z3q9Z6{O;bN4&pQnl7YSd-8XTqSn_c?2`SWU{UBcE`6tTTGs!&VfSg$ym=R}J4a@nP zWLE4IX9;DLL=wXw&D@*$&KC0%jK~%bP;V;&<(tS-ZulAIR)G!^>;~Dn1Axm8$KGG` zh%kZHA=}fQZ+}EzWb$c%KuftKX8}li zxxMtAK}fLTBZ%0h6swU?X3=1(Z;1GrVfPfhvanb&)a0X)IBJv%i9E6#>d~6yTCyaU z!Y}RyTuze|Q)mFyrKi0LwB{ zEn>xEvtjy1f(H1gv7$hnbZrUHazBbS=dk9a=N#0jj+ra6xn+r{l1Ep~?HUmHQ<%w_ zM#A=T_WJj@_K5c=F7=Uf%*33F?=^Pl)yHh*3HLGgx%c5MGC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-hY2Xgth-Gi^VT^fq1Z}>|f&zEHO%JuiS@$|4;`*$h}0dqPFVCVSqNv$V- zjr}`({m>*2tpB*4h-IGl5NAwRB{q;2u_SXhfHs6m6wZuG%}Zi3%Ha8wihrtdo)wBB zz+m#=wPEagY8Vy1T}~LW0w@%(pNoE-^)a*B{$?xD`+oeZ$$KUsv-D>TmHEGQGMX#$BmB7@W{^~n&%datct}j( zLj5{_+%CqKvFx&ofD32~+|6eFO$RwkfBPt*fkljz*u6rPn7|;qAJzL(Phr?VDRe~z z?09o{$WWY;a?m6#cri-qDSKQ4cK%lg?xm^d8f^cnzNlQPZdf2sq03KYA&a-(rb})? z6F7(1nbsfP536Vazm`&hEONk2J>KhPjm|ulh}8+iPu?hy_l${1r&fs>ym-0uoQX*@^NMz${y=3DL4Y0q_Z|HlrTI3 diff --git a/documentation/reference/images/prism.png b/documentation/reference/images/prism.png deleted file mode 100644 index c4189c610f940d0fcfee3b8217f4b223e27cb7f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4408 zcmbW3c|6qL_s8EN`<8vrzKpSl?914fgc(N2z9*EjMPuK}lEyxwFpQx=$iD9(Bs<9# zLRp%`@a6OW@1Nfv=RO~gbI$8L?mdskJ@+Qwy`xV<$w3JK0F9x6j>RPhu8jQJ<;t(D zGGx06@ifWkf)3J{tf~nt4GWckg=o1^PYq^z-L6gg|)xANjd^J#Yhn;5n3~ z2h?(lMGe1nq-~slcx~)w!A#C;p`DCiN*4z4QP3MD@DSYxCUr z7Tw>|x3VUw8A&PV573j>y7E0H2oM2(BUDwz`8&wk0HWYYDsrI1G_OONEB=CRTRX>& z2oXcn5tx44m>j_bXojX}mjar4L+c}=Npp%0`)g1j0muO z&Bshsm=5qVx+UlUo+EYSZD{Ro0N@&cj!}B58i1S{kTy?< z6$41Z0LK9VfnXpe2Vl}WuvYyoUPZqNy6jX=jcTKyl5V6exkLb&wY4OV=%^v9IFo|Y zHK$xn$*zzbcG<{Vbl(m?0YG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H< z@&r0@(3Q4g8riM&;7V=%K5YMRzPkKcX3%}v+cR_Uq+jja@HL^f;FtgR7-xEVK?4NR XL>|h@rTx2nngB!HJ33X`j#2*u(aT1Q diff --git a/documentation/reference/images/prismshell.png b/documentation/reference/images/prismshell.png deleted file mode 100644 index c4a8bce56c6e1b501a74b6ad7c87b0115944be81..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4679 zcmbW3XEfYh)VKelj7~6WBsv+Rw-9~w8e@h*lo2I}D3M!BM2VhYh;D>L9c}bXw9z|3 z^cFoLxPyd5d*WW}eLp@Qo^`E#_J_UCZ?Ci0S!bWvdnUSc)ST1+0MO~{X~F;czAK}= z_IKq|QtbchsJ!*8o&W$1^OcbRSvl+gKyB&$$J^J-#qE(Z z00hio&0P`Z+pH?bOGlc9F`;h^z2IO<9=K+FC<{gi!b`;_`q=uxF-fU2*22z079`R znZYE0%^O}YNgf8^VRnwu0v_H4%115Yv;mYPz~W-qr3lQ30h0QbE_wjI5g?8*($oNy zw1A{pOyq5VEEsU;w&!OIm<)utKMkmClO|6 zH`do@47xOJ&;ypwFI+q9iI(S&eupTZ9sm5&x+)MRZ5yUbcJifT=*Xz>#%MCtOUH%H zMBTGSn#(ip3BE3UM*<4MvS!BQlc1IL>QK6nFIF@8cDLa8rPJy%^psR}Sq{LvtC9p` z#7b-*kp40hW<>cBSC0YUpvkNKvj`<==);JWQUA+*wR7D(K_JvcKiLNW?6d^L5d*bq zy_5i;l@|uVYj7R4vqOm#H`>V;+G)-ltEbaiMlYEnCe-tcv}T^_C}5;ctHhB!!k zR_B%_nmvq4@unB=Kz^WC@n-mgrp#>@X%3?z)99mQM)S_akT}Mn_!B7EG9yoT+x5tp z;stp6V_3}i3^8(gQt&tg4^of&K*jf(V)T8TkC?lCfOPm-RI{$so3I))mCv;GFhYp} z=S!V;G@qROq_PrO^Rhqr)^V!5lF#4zRQ8ZzE>RWMD@pvy4wC75Bq`q0sabsoN|o|p zu$r%&wycK}Z&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L8JU;<0g0wh5SwIr@L*b zl=k~n74v)&<$w8Gc1=;W^G2P2XA9}($8o2=f$AeAJa)61PK@Y|4g~@fA=IuwDCOo% zhZv5>;_2n62!1YH&Wz}P_GQo$<%WLL3V%+wHT8S!ZP24~$?j7r?D#}XS}2@7_2e)E zVs`+p@j&Uqx5>X9M-U!O*5az~SPHPk(1a(gP7b-02WIL&S&UVQ&V! zetC!}k`h@}B*_IOhZf?DNrP;ZNLoY+sVRUSUu?Iph7Tuh5=BUfzdRe!k1Faj<|=u? zK>OzA>C{gf1ee|61?>b}>51D)7bQ{<(dB~Rc9y;Z)T7eE(6vv&PhPujNcu9MwyTDu zdzFz%^#HR<+6qG|4N&cLJ$*v=v;G$UX#bMHUrO3`fWgK(jlIw`Erjn(YR0JGNBkFl Cli5%J diff --git a/documentation/reference/images/revolved.png b/documentation/reference/images/revolved.png deleted file mode 100644 index e0628789a5d58fb8140ca6ff9b6cb9c01273f657..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9772 zcmb_hV{;`;us+F&Z6_PswvCOg6Kgl#aAVur*tTukcCxX#;mv#N{)GEsrmMQAYUX*S zr)Q=+OzFE6A{-tZ002Ogkrr3^k|X~$81S#2l$U4pOTgMoYdZk|@aX?FFu7ahF*?4c!BSkSxun%;AerDoTX96EHk5w0poP><33~4?uybHzjd; zCj$dKd-LZH!hu$(vmF}hi(IKYw*P%*6$ zE&Z$?7#yHAH5rMhr)03{FgT6Cjs6HT_PM9wvih+j@7zrQ z06B4(Uuf^%-KLPLrlvTfn~)3{PP?H#NsW#7KMtqM?S%n=U1#sv4|=A0JYPO2-=80O z6qgW|2Jkt*o+8ZakcAroIVWqHclQ5rBas{1y1IIJaIhjfAgXILrs?%z(P!AB`Tpad zH~-ty!%o*8xgV>(pA^LNPT$16d?CSfJZzxx#@`sJw`TayH^O<+0U6^~En19yWi*Fq z@jsDwtc9duqVY6?6my@Zd)xG{K*4PeK#jE^m}eYAiM|Q&QH}~l%eiOo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EGPkim73KwzAn0XQ%!jlnfN zc9G2WbPWYBC?VrKTzwY{njTg6t{$yW?jufP%eG~#09UJNqg|a*0_+mLG50t67#PFn zPK61*jDHZ>-->#bEk>UBAu#+TBJ3y#$w9U@#D;=vTR%>6NELFfMzm0(^h}2y*0n2B z(JWavDMN{+w!0I{vwhN|Bd|r5NcL z#y*+GLvTo}?AI{Zli9(*-B%Iz{a;>e7w7{FgQ*{OxPT*Fp*4tu+i^OIf2U}%Tot1Q+SsDvJU}jfLUeU zHx2}0)zs1wEb;}Hz$}^KWa^Y6Hm+5CC2`8TYV><<`&+2kCs?EE8 zQl{l0nz1cpuW$cpUk5ACXz-p_BF`s|koTN_G98=Y?o|$RqBvIiIyW_Pzh`%R)n#=O zV7eUp4iJ(HUQv|Et|WV>PSfA|H^Q&6NgU zcX?+%DH8+1?a|{{yPTzT-q>xC!*1amMm2l4bY)arwXaa~)m$HmO-i-V9U&2cCxrL~ z9hYo9x0-e9`st-Z>e&9M+9y)y$7c4X)5(EI`D&UIQv2aew`aT8Vekfu`5GC7u|Prw zs!GTxUVtQ=?mY#+=a_P=tIYMA=0A})s#PZsly7(U0;4f=enNasCj%XaEWPwV*uC2`0y)zXOJ_ZHhiYPQI_N7XD0E zcQy%qWtcT+ZtugHh46MGEB?4f`(VkV6J-Dm*bZa0i`M%?fd`$Um#>WHS?6J)<~B7& zB_>#eMg`+5bTS0ZND0~rTuSoy=aTFNG%eVUkNR{~%|3Y z8fnz$i{4L90tm$1ZR5jhDZjwzVNJh*_2_a5T7DjHq5{UZoAGyg<6gm@&rW!&`9NWF zP;1{PhV43Ejo=!Sfd83$OxmyRgrXjT$)PJ~8#W;>MPK(%U0m9%&xE* s+#sI+D^!I6lmD+!^`ElT@9h(i`axWH{;gF0s~iWAk@zlNB?|KYAMgBf=>Px# diff --git a/documentation/reference/images/ruledfromcoords.png b/documentation/reference/images/ruledfromcoords.png deleted file mode 100644 index 49de6adcf17f24944701334b7f12602a71d5e67e..0000000000000000000000000000000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geweBks=17SbsiOyOQ5Mm#TnT3Fx=Q zUECS#d#4EUT5iRg_4Y1pWv>*l*@qu_eLKj8hnOyQbNf?R;`XuGg%{UIFOswS>2|K` zk->r>lI@h)R_cC^Z2EN$#`hM%DCp2L+!HI#1r|xD*$2qA&mahyRrVt5i2Wcg`uFx2 znNbh~(O;T3HYF3xTvl_D&2I4AO`~61- z-^&?KxTfD#ww@#|bp#_?8iX`rG*Dd3jbb5N2?>5m6KLs_i${pL@iYl8d5WMD#WY`g zD(sh9J$Wz6%lMc*!U+v=N!Zxd42 z9gp!IKLQa(DHYQdYVnSklj%Q+SB)Wb8MM`P(-t7yWn$-R%m}=gnKgg3C$}RV98dju z!o)gJsx^NhAr9Ra=@!VR?yB$TU`Pcj|Hjv#{f$5I|5wre{}uKD#*eQ6aUE1B*@cze Q(?$xKYuDQQ2+n{ diff --git a/documentation/reference/images/ruledfromsectorswithheight.png b/documentation/reference/images/ruledfromsectorswithheight.png deleted file mode 100644 index 6899d2ae7617b9ffd0a569df41cef833a1947f16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6902 zcmZ8lWmJ@1+r5#IMv$Qqq+{q1q@_bbU|@z&hVB?dK}x!%8$m#+p_`$kQ$V`mA%+xC zLK;4v_x;xT*7|;&eb&16zW2G#b<{fR#R2fy`TI49e5A!ky%1~ z;C{k)RW*DI0EFOw2Nsa=nHm5HwCxlWUcIt)ad&xZ>*C6&rl7#+>gHl?=V%20p7U9H zHc-7CO6jxZ6Zx0n{z)%gbSdx{b>*Y{$>Z4}O!%bg;Y_)66gnM`m6Skq{W;;-F){wp z6goUakp#228%%jIL0`io2d`GWzdB5}oNW%@*3HOll^$o+jN-QA5v8aK>pb%(Dwbz> z{7+C{ckk*3--`eOR#$)&uf~$;?F|bSaPB81#m(G~+Xi5HP7vY&?V6eG0#Cy3NOtAZ zO|blfvD)3^pTETOCkI}5#mE-`FO;$Tv(ni0fE*Bj7_u;52VU_42#$}N6M%o#dAc_i zV4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3y` zy=@K?=Ko3z{?+!oJW_9$Pk!CpDk`cb2z5{+uU5{9oEEpUo?jdMCD3s|OW~y$`p{Py z{EZd7sL=ek9h3`q(;rxL9i=8A2tGaOx_1o(t9t~4MX4dOW5?6~FzoIJ;Xf!9skZ!9 z%jmM`nD!1PmxgEvv}y^+A0s#|qoh1Tf%KPXmrYGIT4)}nD{|k?*GV1^+6i2+JB;)Oj8l;H1DkTa1 z%W4niHBqQsIgk<^W2VY^C|27TDq8daF7n|>zj%mo$ynb(gxpK0q7wjv;MLB^KkuD- zi*2iO3EUo5s)AA9{!%cXTBTJRTIl(Pd7h34 zfcRS#!#gdemu~(&Z&Bz#vjL&>PK}s=9A}D>Cx2bi-@KnuE}LGw zg7YdUD*nio$708;qc*Awu1yAj^l9xk%ln}(H-|kIqWQENpW8$ zV{OA|t3iqp!S?F10dzY%Q-1`x-huiB4IyXe1 yJ}HL`K^H%PaVuX{%K!hq`TtsPXwc~$767&#@>yl7esuq^0H`TxDVED40{;i%T?5?! diff --git a/documentation/reference/images/segmentedcuboid.png b/documentation/reference/images/segmentedcuboid.png deleted file mode 100644 index c2d3507535218347fbe07d62a98f250b2f7d99c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4456 zcmZuzc{tQx)c;CZ#=Zo^^LD@YzzqO` zri-l5)>i8r>Id_CFyr`$=f>WaU>ZJ4SW*Ogx(I}ymf0wtzjO+0(axf)dy%`ZB%U%Q zB_bJY0i{m_O;WG$zf6fLi%;x7S_~=k7;igR9XxHC&{)Im7Bvo26KLqO4dg5oBIv7O zye!|Mdb@fSSEO!6f`ohkW|~G<{)Z=m6u{pwH8lwV0`&)gB4~_`1|XOg5UyX1J7f9* z%X6fNh^8R;r{6H9iC_nAK2CvE05|n0B8qZFtbme>0CM1t%QA3F5s|w(TZ4z|>#C3q(-MC8`n3M#r8``=X0QffmVThTo0idA= zu3N;%hyxcx0A!z_U=R?U2e9ky*sA@OsAXP*kd?}7P-_uV){S(ak@T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vfJhol*bv1jIllU*P`K35ajx=cU(5Yn27Su4JyQb)rD-vIydjx zTUq4DYu2+Ucma8nTzl4$c);L}1TQ_hWK;CtWp&(rIE8WCgsaf+koa*VN{@p7f2&gQI;#jkeD0oIPyYvNTSuY* diff --git a/documentation/reference/images/segmentedrectangle.png b/documentation/reference/images/segmentedrectangle.png deleted file mode 100644 index 829c1a126211c04d44f3aaa6726009347cb26d83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3721 zcmchZ_dgWyAICq3?3EcJd!9YY9%s*R$4LpriDaa#=#FfWWIK_pGr9M>-+#0eTIe;=O!_`}T05z=UO~jx3{w%P>C=rBt(DRAWqN!UzeV;mnfwS1t?_&UsJ;(}$0LNDX?2!Bv zz|ZOys}DTXLB+6Lya7PU0XBEDPE{}^4dhJh-Hidh9uS6@>8b%WJ&?1GjgkNqp}@IU zNGJ$A%K~hMyY?EtrK*_MCC`(}s@7-_RyDvlQcL?$+1tzTi4U1@O0lW9khx^*$g~G% zaVcPwn7$D|1CXD>ets?SBxs1SYG_C$sgCis^yVkZGeK9^mD9E1a$g+)mIA^@PNA|j z+-P-5wD;*7ksS&TC%XJcqy+bBCY@T4zcFJ^^!=BOLBWfL>FKrA)hW|XJx7;*`><0~ z`)z{#$^FA{jbqaOx7KB0jKVF95yio`_Ro9fMVE(P(mZpW`<`rcTu*m)%sVF7Y2w;| zlw@16X7NkX&rT#N6bZ)Zy_Dz@89lqZya+ua*IHBtcuy@zXo_^{tvlp@%*2?H0fc1| z0J}{-ZC}Ny$OT&R@zqC(`@j^ub8U3T&MMFJgge{ynDuDyqA&Y9OH@SYiAN9Oc_p1?zv}QR5v)C;Q+*j_+7TZa zHGP@>x=`n}i8o_tD0F+NSzQEXVj-^aNTDQZ&a9{dfi`0bmIPt`zF0PEL9-NPV|kl+ zI6uOecURM&Of}}FVPlGVFHnd$j&3%Re}$>G*8ECe3u`F7%Kgmn4c(W!0rJ_&9Qiq4 z{6BDOCaM&ye<}B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;f)+-bnm&_BttL8JU;<0g0wh5SwIr@L*b zl=k~n74v)&<$w8Gc1=;W^G2P2XA9}($8o2=f$AeAJa)61PK@Y|4g~@fA=IuwDCOo% zhZv5>;_2n62!1YH&Wz}P_GQo$<%WLL3V%+wHT8S!ZP24~$?j7r?D#}XS}2@7_2e)E zVs`+p@j&Uqx5>X9M-U!O*5az~SPHPk(1a(gP7b-02WIL&S&UVQ&V! zetC!}k`h@}B*_IOhZf?DNrP;ZNLoY+sVRUSUu?Iph7Tuh5=BUfzdRe!k1Faj<|=u? zK>OzA>C{gf1ee|61?>b}>51D)7bQ{<(dB~Rc9y;Z)T7eE(6vv&PhPujNcu9MwyTDu zdzFz%^#HR<+6qG|4N&cLJ$*v=v;G$UX#bMHUrO3`fWgK(jlIw`Erjn(YR0JGNBkFl Cli5%J diff --git a/documentation/reference/images/sphere.png b/documentation/reference/images/sphere.png deleted file mode 100644 index 06ec1bf0342c89870bbb7665dde6d5b9bcc70d04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13769 zcmV;)H8#qLP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znC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_BQp-sh(dBt6cK(TdX}h zn~2=5!ROIt>rA5qx;u7(~PljWe zEp9BYW%kMFNe1NX>3WHa$H`I5+gc6=hUe{Iw4ujtIPE*FZ-#{vzI?_&U%jBV>DHS#464gbwt8Hw(u=85e_+B|Km>nvRPhlVR^D*7IZO_8eW?Z=Cmuh1jQT)w!`qLBjSO0P zXBAEDMhk@{Uy@!vU-^g1qW`Z-T+W~OpD+MdiKE>wO62#K#u*?hsVGq|W*qW=0A~P9 AjQ{`u diff --git a/documentation/reference/images/triangulatedsphere.png b/documentation/reference/images/triangulatedsphere.png deleted file mode 100644 index 5a6c9f3e5eab54b7f7877651f653efcd15f2483e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13494 zcmV;nG)c>eP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?J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Qkxf%=g043TA7N1=kScsRE64cf3OP?PVd$;q2+wNdZ@p}D=FTA2LRO_$}$c^e= zWLC}`pD5MY;m>L5H+5f{atm4I`@fLeE5N%s| zzT3c>SB|iD-T2w>0!}>D=IjlqWut68V85wQUT&J`B~PuX;^6+_KZKOR2%_jdhhh-;MPvR^>+E@`KW%h*bqvb z;?|dX-53C(;?RDm>){t4hMJ07aMz#ns{*W$vk#%XcnQ#*KL2+4!}HM;A!v(T`5G|v zrHVuM0@R21?=9}x0|Yy?vbzRWkF+5mo__1cKs3pc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example - - - - - - - -
- prev - next - image - - - From bea30e6f0b57c2adc8128c8bf893186baa695350 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 6 Aug 2015 20:11:22 +0200 Subject: [PATCH 26/27] Add curve angle to GeneratePrism. --- build/jsmodeler.js | 380 +++++++++--------- documentation/demo/include/shapegenerators.js | 6 +- documentation/examples/svgto3d.html | 2 +- documentation/jsmdoc/include/jsmdoc.json | 83 ++-- documentation/olddemo/include/demo.js | 4 +- documentation/tutorial/svgto3d.html | 4 +- sandbox/csg.html | 2 +- sandbox/curvedprism.html | 83 +--- sandbox/hiddenline.html | 2 +- sandbox/svgonthefly.html | 2 +- sandbox/svgtomodel.html | 2 +- sandbox/svgtomodel2.html | 135 ------- sandbox/svgtomodeltexture.html | 2 +- src/extras/extgenerator.js | 2 +- src/extras/svgtomodel.js | 15 +- src/geometry/polygon.js | 86 +++- src/modeler/bodyutils.js | 39 ++ src/modeler/generator.js | 116 ++---- test/unittest/tests/modeler.js | 4 +- test/unittest/tests/polygon.js | 23 ++ test/unittest/tests/visual.js | 6 +- test/viewertest/include/teststeps.js | 47 +-- 22 files changed, 455 insertions(+), 590 deletions(-) delete mode 100644 sandbox/svgtomodel2.html diff --git a/build/jsmodeler.js b/build/jsmodeler.js index af320803..c8e5faac 100644 --- a/build/jsmodeler.js +++ b/build/jsmodeler.js @@ -13,25 +13,25 @@ JSM.Coord2D.prototype.Clone=function(){return new JSM.Coord2D(this.x,this.y)};JS JSM.Coord.prototype.IsEqual=function(a){return JSM.IsEqual(this.x,a.x)&&JSM.IsEqual(this.y,a.y)&&JSM.IsEqual(this.z,a.z)};JSM.Coord.prototype.IsEqualWithEps=function(a,b){return JSM.IsEqualWithEps(this.x,a.x,b)&&JSM.IsEqualWithEps(this.y,a.y,b)&&JSM.IsEqualWithEps(this.z,a.z,b)};JSM.Coord.prototype.DistanceTo=function(a){return Math.sqrt((a.x-this.x)*(a.x-this.x)+(a.y-this.y)*(a.y-this.y)+(a.z-this.z)*(a.z-this.z))}; JSM.Coord.prototype.AngleTo=function(a){var b=this.Clone().Normalize();a=a.Clone().Normalize();if(b.IsEqual(a))return 0;b=JSM.VectorDot(b,a);return JSM.ArcCos(b)};JSM.Coord.prototype.IsCollinearWith=function(a){a=this.AngleTo(a);return JSM.IsEqual(a,0)||JSM.IsEqual(a,Math.PI)};JSM.Coord.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};JSM.Coord.prototype.MultiplyScalar=function(a){this.x*=a;this.y*=a;this.z*=a;return this}; JSM.Coord.prototype.Normalize=function(){var a=this.Length();JSM.IsPositive(a)&&this.MultiplyScalar(1/a);return this};JSM.Coord.prototype.SetLength=function(a){var b=this.Length();JSM.IsPositive(b)&&this.MultiplyScalar(a/b);return this};JSM.Coord.prototype.Offset=function(a,b){var c=a.Clone().Normalize();this.x+=c.x*b;this.y+=c.y*b;this.z+=c.z*b;return this}; -JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,k=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*k;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*k;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*k;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this}; +JSM.Coord.prototype.Rotate=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=this.x-c.x,h=this.y-c.y,g=this.z-c.z,l=Math.sin(b);b=Math.cos(b);this.x=-a*(-a*f-e*h-d*g)*(1-b)+f*b+(-d*h+e*g)*l;this.y=-e*(-a*f-e*h-d*g)*(1-b)+h*b+(d*f-a*g)*l;this.z=-d*(-a*f-e*h-d*g)*(1-b)+g*b+(-e*f+a*h)*l;this.x+=c.x;this.y+=c.y;this.z+=c.z;return this}; JSM.Coord.prototype.ToCoord2D=function(a){var b=new JSM.Coord(0,0,0),c=new JSM.Vector(0,0,1),d=JSM.VectorCross(a,c);a=a.AngleTo(c);b=this.Clone().Rotate(d,a,b);return new JSM.Coord2D(b.x,b.y)};JSM.Coord.prototype.ToString=function(){return"("+this.x+", "+this.y+", "+this.z+")"};JSM.Coord.prototype.Clone=function(){return new JSM.Coord(this.x,this.y,this.z)};JSM.Vector=JSM.Coord;JSM.CoordFromArray=function(a){return new JSM.Coord(a[0],a[1],a[2])};JSM.CoordToArray=function(a){return[a.x,a.y,a.z]}; JSM.CoordAdd=function(a,b){return new JSM.Coord(a.x+b.x,a.y+b.y,a.z+b.z)};JSM.CoordSub=function(a,b){return new JSM.Coord(a.x-b.x,a.y-b.y,a.z-b.z)};JSM.VectorDot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};JSM.VectorCross=function(a,b){var c=new JSM.Vector(0,0,0);c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};JSM.MatrixDeterminant2x2=function(a,b,c,d){return a*d-b*c}; -JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,k){var l=JSM.MatrixDeterminant2x2(e,f,g,k);f=JSM.MatrixDeterminant2x2(d,f,h,k);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*l-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,k,l,m,n,p,q,t,r){var u=JSM.MatrixDeterminant3x3(f,h,g,l,m,n,q,t,r),v=JSM.MatrixDeterminant3x3(e,h,g,k,m,n,p,t,r);g=JSM.MatrixDeterminant3x3(e,f,g,k,l,n,p,q,r);e=JSM.MatrixDeterminant3x3(e,f,h,k,l,m,p,q,t);return u*a-v*b+g*c-e*d}; +JSM.MatrixDeterminant3x3=function(a,b,c,d,e,f,h,g,l){var k=JSM.MatrixDeterminant2x2(e,f,g,l);f=JSM.MatrixDeterminant2x2(d,f,h,l);d=JSM.MatrixDeterminant2x2(d,e,h,g);return a*k-b*f+c*d};JSM.MatrixDeterminant4x4=function(a,b,c,d,e,f,h,g,l,k,m,n,p,q,t,s){var w=JSM.MatrixDeterminant3x3(f,h,g,k,m,n,q,t,s),u=JSM.MatrixDeterminant3x3(e,h,g,l,m,n,p,t,s);g=JSM.MatrixDeterminant3x3(e,f,g,l,k,n,p,q,s);e=JSM.MatrixDeterminant3x3(e,f,h,l,k,m,p,q,t);return w*a-u*b+g*c-e*d}; JSM.Orientation={Invalid:0,CounterClockwise:1,Clockwise:2};JSM.MidCoord2D=function(a,b){return new JSM.Coord2D((a.x+b.x)/2,(a.y+b.y)/2)};JSM.CoordOrientation2D=function(a,b,c){var d=a.x;a=a.y;var e=b.x;b=b.y;var f=c.x;c=c.y;d=d*b+a*f+e*c-b*f-a*e-d*c;return JSM.IsPositive(d)?JSM.Orientation.CounterClockwise:JSM.IsNegative(d)?JSM.Orientation.Clockwise:JSM.Orientation.Invalid};JSM.PolarToCartesian=function(a,b){var c=new JSM.Coord2D(0,0);c.x=a*Math.cos(b);c.y=a*Math.sin(b);return c}; JSM.GetArcLengthFromAngle=function(a,b){return b*a};JSM.GetAngleFromArcLength=function(a,b){return JSM.IsEqual(a,0)?0:b/a};JSM.MidCoord=function(a,b){return new JSM.Coord((a.x+b.x)/2,(a.y+b.y)/2,(a.z+b.z)/2)};JSM.CoordSignedDistance=function(a,b,c){var d=JSM.CoordSub(b,a);a=a.DistanceTo(b);c=d.AngleTo(c);JSM.IsPositive(c)&&(a=-a);return a};JSM.GetVectorsFullAngle=function(a,b,c){var d=a.AngleTo(b),e=new JSM.Coord(0,0,0);JSM.CoordOrientation(a,e,b,c)==JSM.Orientation.Clockwise&&(d=2*Math.PI-d);return d}; JSM.CoordOrientation=function(a,b,c,d){a=a.ToCoord2D(d);b=b.ToCoord2D(d);c=c.ToCoord2D(d);c=JSM.CoordOrientation2D(a,b,c);a=new JSM.Vector(0,0,1);d=d.AngleTo(a);JSM.IsEqual(d,Math.PI)&&(c==JSM.Orientation.CounterClockwise?c=JSM.Orientation.Clockwise:c==JSM.Orientation.Clockwise&&(c=JSM.Orientation.CounterClockwise));return c};JSM.SphericalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.sin(b)*Math.cos(c);d.y=a*Math.sin(b)*Math.sin(c);d.z=a*Math.cos(b);return d}; JSM.CylindricalToCartesian=function(a,b,c){var d=new JSM.Coord(0,0,0);d.x=a*Math.cos(c);d.y=a*Math.sin(c);d.z=b;return d};JSM.GetArcLength=function(a,b,c){return a.AngleTo(b)*c};JSM.GetFullArcLength=function(a,b,c,d){return JSM.GetVectorsFullAngle(a,b,d)*c};JSM.CalculateCentroid=function(a){var b=a.length,c=new JSM.Coord(0,0,0);if(1<=b){var d;for(d=0;da?0:Math.sqrt(a)}var k=a.DistanceTo(b),l=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(k,l,m);if(JSM.IsZero(c))return d;k=g(k,a,b);l=g(l,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(l);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(k);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; +JSM.BarycentricInterpolation=function(a,b,c,d,e,f,h){function g(a,b,c){var d=(a+b+c)/2;a=d*(d-a)*(d-b)*(d-c);return 0>a?0:Math.sqrt(a)}var l=a.DistanceTo(b),k=b.DistanceTo(c),m=c.DistanceTo(a);a=a.DistanceTo(h);b=b.DistanceTo(h);h=c.DistanceTo(h);c=g(l,k,m);if(JSM.IsZero(c))return d;l=g(l,a,b);k=g(k,b,h);m=g(m,a,h);d=d.Clone().MultiplyScalar(k);e=e.Clone().MultiplyScalar(m);f=f.Clone().MultiplyScalar(l);f=JSM.CoordAdd(JSM.CoordAdd(d,e),f);f.MultiplyScalar(1/c);return f}; JSM.MatrixIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};JSM.MatrixClone=function(a){var b=[];b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b}; -JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],k=a[3],l=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],r=a[13],u=a[14],v=a[15],s=[];s[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];s[1]=c*h+d*l+e*p+f*r;s[2]=c*g+d*m+e*q+f*u;s[3]=c*k+d*n+e*t+f*v;return s}; -JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],k=a[6],l=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],r=a[13],u=a[14],v=a[15],s=b[0],w=b[1],y=b[2],z=b[3],x=b[4],D=b[5],H=b[6],K=b[7],L=b[8],G=b[9],A=b[10],C=b[11],N=b[12],O=b[13],J=b[14],I=b[15],E=[];E[0]=c*s+d*x+e*L+f*N;E[1]=c*w+d*D+e*G+f*O;E[2]=c*y+d*H+e*A+f*J;E[3]=c*z+d*K+e*C+f*I;E[4]=h*s+g*x+k*L+l*N;E[5]=h*w+g*D+k*G+l*O;E[6]=h*y+g*H+k*A+l*J;E[7]=h*z+g*K+k*C+l*I;E[8]=m*s+n*x+p*L+q*N;E[9]=m*w+n*D+p*G+q*O;E[10]=m*y+n*H+ -p*A+q*J;E[11]=m*z+n*K+p*C+q*I;E[12]=t*s+r*x+u*L+v*N;E[13]=t*w+r*D+u*G+v*O;E[14]=t*y+r*H+u*A+v*J;E[15]=t*z+r*K+u*C+v*I;return E};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],k=a[7],l=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];return(b*h-c*f)*(n*a-p*r)-(b*g-d*f)*(m*a-p*t)+(b*k-e*f)*(m*r-n*t)+(c*g-d*h)*(l*a-p*q)-(c*k-e*h)*(l*r-n*q)+(d*k-e*g)*(l*t-m*q)}; -JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],k=a[7],l=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],r=a[14];a=a[15];var u=b*h-c*f,v=b*g-d*f,s=b*k-e*f,w=c*g-d*h,y=c*k-e*h,z=d*k-e*g,x=l*t-m*q,D=l*r-n*q,H=l*a-p*q,K=m*r-n*t,L=m*a-p*t,G=n*a-p*r,A=u*G-v*L+s*K+w*H-y*D+z*x;if(JSM.IsZero(A))return null;var C=[];C[0]=(h*G-g*L+k*K)/A;C[1]=(d*L-c*G-e*K)/A;C[2]=(t*z-r*y+a*w)/A;C[3]=(n*y-m*z-p*w)/A;C[4]=(g*H-f*G-k*D)/A;C[5]=(b*G-d*H+e*D)/A;C[6]=(r*s-q*z-a*v)/A;C[7]=(l*z-n*s+p* -v)/A;C[8]=(f*L-h*H+k*x)/A;C[9]=(c*H-b*L-e*x)/A;C[10]=(q*y-t*s+a*u)/A;C[11]=(m*s-l*y-p*u)/A;C[12]=(h*D-f*K-g*x)/A;C[13]=(b*K-c*D+d*x)/A;C[14]=(t*v-q*w-r*u)/A;C[15]=(l*w-m*v+n*u)/A;return C};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; -JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,k=Math.sin(b);b=Math.cos(b);var l=[];if(void 0===c||null===c)l[0]=f+(h+g)*b,l[1]=a*e*(1-b)+d*k,l[2]=a*d*(1-b)-e*k,l[3]=0,l[4]=a*e*(1-b)-d*k,l[5]=h+(f+g)*b,l[6]=e*d*(1-b)+a*k,l[7]=0,l[8]=a*d*(1-b)+e*k,l[9]=e*d*(1-b)-a*k,l[10]=g+(f+h)*b,l[11]=0,l[12]=0,l[13]=0,l[14]=0;else{var m=c.x,n=c.y;c=c.z;l[0]=f+(h+g)*b;l[1]=a*e*(1-b)+d*k;l[2]=a*d*(1-b)-e*k;l[3]=0;l[4]=a*e*(1-b)-d*k;l[5]=h+(f+g)*b;l[6]=e*d*(1- -b)+a*k;l[7]=0;l[8]=a*d*(1-b)+e*k;l[9]=e*d*(1-b)-a*k;l[10]=g+(f+h)*b;l[11]=0;l[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*k;l[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*k;l[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*k}l[15]=1;return l}; -JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var k=b*h,b=b*g,l=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(l+d);g[1]=k+e;g[2]=b-h;g[3]=0;g[4]=k-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+l);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; +JSM.MatrixTranspose=function(a){var b=[];b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};JSM.MatrixVectorMultiply=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],h=a[1],g=a[2],l=a[3],k=a[5],m=a[6],n=a[7],p=a[9],q=a[10],t=a[11],s=a[13],w=a[14],u=a[15],r=[];r[0]=c*a[0]+d*a[4]+e*a[8]+f*a[12];r[1]=c*h+d*k+e*p+f*s;r[2]=c*g+d*m+e*q+f*w;r[3]=c*l+d*n+e*t+f*u;return r}; +JSM.MatrixMultiply=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],h=a[4],g=a[5],l=a[6],k=a[7],m=a[8],n=a[9],p=a[10],q=a[11],t=a[12],s=a[13],w=a[14],u=a[15],r=b[0],v=b[1],C=b[2],D=b[3],y=b[4],x=b[5],F=b[6],K=b[7],L=b[8],H=b[9],z=b[10],B=b[11],N=b[12],O=b[13],J=b[14],I=b[15],E=[];E[0]=c*r+d*y+e*L+f*N;E[1]=c*v+d*x+e*H+f*O;E[2]=c*C+d*F+e*z+f*J;E[3]=c*D+d*K+e*B+f*I;E[4]=h*r+g*y+l*L+k*N;E[5]=h*v+g*x+l*H+k*O;E[6]=h*C+g*F+l*z+k*J;E[7]=h*D+g*K+l*B+k*I;E[8]=m*r+n*y+p*L+q*N;E[9]=m*v+n*x+p*H+q*O;E[10]=m*C+n*F+ +p*z+q*J;E[11]=m*D+n*K+p*B+q*I;E[12]=t*r+s*y+w*L+u*N;E[13]=t*v+s*x+w*H+u*O;E[14]=t*C+s*F+w*z+u*J;E[15]=t*D+s*K+w*B+u*I;return E};JSM.MatrixDeterminant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];return(b*h-c*f)*(n*a-p*s)-(b*g-d*f)*(m*a-p*t)+(b*l-e*f)*(m*s-n*t)+(c*g-d*h)*(k*a-p*q)-(c*l-e*h)*(k*s-n*q)+(d*l-e*g)*(k*t-m*q)}; +JSM.MatrixInvert=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],h=a[5],g=a[6],l=a[7],k=a[8],m=a[9],n=a[10],p=a[11],q=a[12],t=a[13],s=a[14];a=a[15];var w=b*h-c*f,u=b*g-d*f,r=b*l-e*f,v=c*g-d*h,C=c*l-e*h,D=d*l-e*g,y=k*t-m*q,x=k*s-n*q,F=k*a-p*q,K=m*s-n*t,L=m*a-p*t,H=n*a-p*s,z=w*H-u*L+r*K+v*F-C*x+D*y;if(JSM.IsZero(z))return null;var B=[];B[0]=(h*H-g*L+l*K)/z;B[1]=(d*L-c*H-e*K)/z;B[2]=(t*D-s*C+a*v)/z;B[3]=(n*C-m*D-p*v)/z;B[4]=(g*F-f*H-l*x)/z;B[5]=(b*H-d*F+e*x)/z;B[6]=(s*r-q*D-a*u)/z;B[7]=(k*D-n*r+p* +u)/z;B[8]=(f*L-h*F+l*y)/z;B[9]=(c*F-b*L-e*y)/z;B[10]=(q*C-t*r+a*w)/z;B[11]=(m*r-k*C-p*w)/z;B[12]=(h*x-f*K-g*y)/z;B[13]=(b*K-c*x+d*y)/z;B[14]=(t*u-q*v-s*w)/z;B[15]=(k*v-m*u+n*w)/z;return B};JSM.MatrixTranslation=function(a,b,c){var d=[1,0,0,0,0,1,0,0,0,0,1,0];d[12]=a;d[13]=b;d[14]=c;d[15]=1;return d}; +JSM.MatrixRotation=function(a,b,c){var d=a.Clone().Normalize();a=d.x;var e=d.y,d=d.z,f=a*a,h=e*e,g=d*d,l=Math.sin(b);b=Math.cos(b);var k=[];if(void 0===c||null===c)k[0]=f+(h+g)*b,k[1]=a*e*(1-b)+d*l,k[2]=a*d*(1-b)-e*l,k[3]=0,k[4]=a*e*(1-b)-d*l,k[5]=h+(f+g)*b,k[6]=e*d*(1-b)+a*l,k[7]=0,k[8]=a*d*(1-b)+e*l,k[9]=e*d*(1-b)-a*l,k[10]=g+(f+h)*b,k[11]=0,k[12]=0,k[13]=0,k[14]=0;else{var m=c.x,n=c.y;c=c.z;k[0]=f+(h+g)*b;k[1]=a*e*(1-b)+d*l;k[2]=a*d*(1-b)-e*l;k[3]=0;k[4]=a*e*(1-b)-d*l;k[5]=h+(f+g)*b;k[6]=e*d*(1- +b)+a*l;k[7]=0;k[8]=a*d*(1-b)+e*l;k[9]=e*d*(1-b)-a*l;k[10]=g+(f+h)*b;k[11]=0;k[12]=(m*(h+g)-a*(n*e+c*d))*(1-b)+(n*d-c*e)*l;k[13]=(n*(f+g)-e*(m*a+c*d))*(1-b)+(c*a-m*d)*l;k[14]=(c*(f+h)-d*(m*a+n*e))*(1-b)+(m*e-n*a)*l}k[15]=1;return k}; +JSM.MatrixRotationQuaternion=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=b+b,h=c+c,g=d+d;a=b*f;var l=b*h,b=b*g,k=c*h,c=c*g,d=d*g,f=e*f,h=e*h,e=e*g,g=[];g[0]=1-(k+d);g[1]=l+e;g[2]=b-h;g[3]=0;g[4]=l-e;g[5]=1-(a+d);g[6]=c+f;g[7]=0;g[8]=b+h;g[9]=c-f;g[10]=1-(a+k);g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return g};JSM.MatrixRotationX=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[1,0,0,0,0];c[5]=a;c[6]=b;c[7]=0;c[8]=0;c[9]=-b;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixRotationY=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=0;c[2]=-b;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=b;c[9]=0;c[10]=a;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};JSM.MatrixRotationZ=function(a){var b=Math.sin(a);a=Math.cos(a);var c=[];c[0]=a;c[1]=b;c[2]=0;c[3]=0;c[4]=-b;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c}; JSM.MatrixView=function(a,b,c){if(a.IsEqual(b))return JSM.MatrixIdentity();var d=[];b=JSM.CoordSub(a,b).Normalize();c=JSM.VectorCross(c,b).Normalize();var e=JSM.VectorCross(b,c).Normalize();d[0]=c.x;d[1]=e.x;d[2]=b.x;d[3]=0;d[4]=c.y;d[5]=e.y;d[6]=b.y;d[7]=0;d[8]=c.z;d[9]=e.z;d[10]=b.z;d[11]=0;d[12]=-JSM.VectorDot(c,a);d[13]=-JSM.VectorDot(e,a);d[14]=-JSM.VectorDot(b,a);d[15]=1;return d}; JSM.MatrixPerspective=function(a,b,c,d){var e=[];a=1/Math.tan(a/2);var f=1/(c-d);e[0]=a/b;e[1]=0;e[2]=0;e[3]=0;e[4]=0;e[5]=a;e[6]=0;e[7]=0;e[8]=0;e[9]=0;e[10]=(d+c)*f;e[11]=-1;e[12]=0;e[13]=0;e[14]=2*d*c*f;e[15]=0;return e};JSM.ApplyTransformation=function(a,b){var c=[];c[0]=b.x;c[1]=b.y;c[2]=b.z;c[3]=1;c=JSM.MatrixVectorMultiply(a,c);return new JSM.Coord(c[0],c[1],c[2])};JSM.CoordSystem=function(a,b,c,d){this.origo=a;this.e1=b;this.e2=c;this.e3=d}; @@ -40,18 +40,18 @@ JSM.CoordSystem.prototype.Clone=function(){return new JSM.CoordSystem(this.origo JSM.Sector2D=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector2D.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; JSM.Sector2D.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=this.beg.x,e=this.beg.y,f=this.end.x,h=this.end.y,g=this.GetLength();if(JSM.IsZero(g))return a.IsEqual(this.beg)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordOutsideOfSector;a=((b-d)*(f-d)+(c-e)*(h-e))/(g*g);if(JSM.IsLower(a,0)||JSM.IsGreater(a,1))return JSM.CoordSectorPosition2D.CoordOutsideOfSector;e+=a*(h-e);return!JSM.IsEqual(d+a*(f-d),b)||!JSM.IsEqual(e,c)?JSM.CoordSectorPosition2D.CoordOutsideOfSector: JSM.IsEqual(a,0)||JSM.IsEqual(a,1)?JSM.CoordSectorPosition2D.CoordOnSectorEndCoord:JSM.CoordSectorPosition2D.CoordInsideOfSector}; -JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,k=e.IsEqual(h)||e.IsEqual(g),l=f.IsEqual(h)||f.IsEqual(g);if(k&&l)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, -q=f.y,t=h.x,r=h.y,u=g.x,v=g.y,s=(u-t)*(n-r)-(v-r)*(m-t),w=(p-m)*(n-r)-(q-n)*(m-t),t=(v-r)*(p-m)-(u-t)*(q-n);if(JSM.IsZero(t)){if(JSM.IsZero(s)&&JSM.IsZero(w)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(k)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(l)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=s/t;w/=t;if(JSM.IsLower(h, -0)||JSM.IsGreater(h,1)||JSM.IsLower(w,0)||JSM.IsGreater(w,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(k)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(l)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; -JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,k=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(k))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/k;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; +JSM.Sector2D.prototype.SectorPosition=function(a,b){function c(a,b,c){return!c.IsEqual(a)&&!c.IsEqual(b)&&JSM.IsLowerOrEqual(c.x,Math.max(a.x,b.x))&&JSM.IsLowerOrEqual(c.y,Math.max(a.y,b.y))&&JSM.IsGreaterOrEqual(c.x,Math.min(a.x,b.x))&&JSM.IsGreaterOrEqual(c.y,Math.min(a.y,b.y))?!0:!1}var d=void 0!==b&&null!==b,e=this.beg,f=this.end,h=a.beg,g=a.end,l=e.IsEqual(h)||e.IsEqual(g),k=f.IsEqual(h)||f.IsEqual(g);if(l&&k)return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;var m=e.x,n=e.y,p=f.x, +q=f.y,t=h.x,s=h.y,w=g.x,u=g.y,r=(w-t)*(n-s)-(u-s)*(m-t),v=(p-m)*(n-s)-(q-n)*(m-t),t=(u-s)*(p-m)-(w-t)*(q-n);if(JSM.IsZero(t)){if(JSM.IsZero(r)&&JSM.IsZero(v)){if(c(e,f,h)||c(e,f,g)||c(h,g,e)||c(h,g,f))return JSM.SectorSectorPosition2D.SectorsIntersectCoincident;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint}return JSM.SectorSectorPosition2D.SectorsDontIntersect}h=r/t;v/=t;if(JSM.IsLower(h, +0)||JSM.IsGreater(h,1)||JSM.IsLower(v,0)||JSM.IsGreater(v,1))return JSM.SectorSectorPosition2D.SectorsDontIntersect;if(l)return d&&(b.x=e.x,b.y=e.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;if(k)return d&&(b.x=f.x,b.y=f.y),JSM.SectorSectorPosition2D.SectorsIntersectEndPoint;d&&(b.x=m+h*(p-m),b.y=n+h*(q-n));return JSM.SectorSectorPosition2D.SectorsIntersectOnePoint}; +JSM.Sector2D.prototype.ProjectCoord=function(a){var b=a.x,c=a.y;a=this.beg;var d=this.end,e=a.x,f=a.y,h=d.x,g=d.y,l=(h-e)*(h-e)+(g-f)*(g-f);if(JSM.IsZero(l))return a.Clone();b=((h-e)*(b-e)+(g-f)*(c-f))/l;if(JSM.IsLower(b,0))return a.Clone();if(JSM.IsGreater(b,1))return d.Clone();b=JSM.CoordSub2D(d,a).MultiplyScalar(b);return JSM.CoordAdd2D(a,b)};JSM.Sector2D.prototype.Clone=function(){return new JSM.Sector2D(this.beg.Clone(),this.end.Clone())};JSM.Sector=function(a,b){this.beg=a;this.end=b}; JSM.Sector.prototype.Set=function(a,b){this.beg=a;this.end=b};JSM.Sector.prototype.GetLength=function(){return this.beg.DistanceTo(this.end)}; -JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,k=e.z,l=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(l-h)*(l-h)+(m-g)*(m-g)+(n-k)*(n-k);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((l-h)*(b-h)+(m-g)*(c-g)+(n-k)*(d-k))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: +JSM.Sector.prototype.CoordPosition=function(a){var b=a.x,c=a.y,d=a.z,e=this.beg,f=JSM.CoordSub(this.end,this.beg),h=e.x,g=e.y,l=e.z,k=e.x+f.x,m=e.y+f.y,n=e.z+f.z,p=(k-h)*(k-h)+(m-g)*(m-g)+(n-l)*(n-l);if(JSM.IsZero(p))return e.IsEqual(a)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordOutsideOfSector;b=((k-h)*(b-h)+(m-g)*(c-g)+(n-l)*(d-l))/p;f=f.Clone().MultiplyScalar(b);e=JSM.CoordAdd(e,f);a=a.DistanceTo(e);return JSM.IsZero(a)?JSM.IsLower(b,0)||JSM.IsGreater(b,1)?JSM.CoordSectorPosition.CoordOutsideOfSector: JSM.IsEqual(b,0)||JSM.IsEqual(b,1)?JSM.CoordSectorPosition.CoordOnSectorEndCoord:JSM.CoordSectorPosition.CoordInsideOfSector:JSM.CoordSectorPosition.CoordOutsideOfSector};JSM.Sector.prototype.Clone=function(){return new JSM.Sector(this.beg.Clone(),this.end.Clone())};JSM.GetSectorSegmentation=function(a,b,c){var d=JSM.CoordSub(a.end,a.beg),e=a.beg.DistanceTo(a.end)/b,f=0,h,g;for(h=0;h<=b;h++)g=a.beg.Clone().Offset(d,f),c.push(g),f+=e};JSM.CoordLinePosition2D={CoordOnLine:0,CoordAtLineLeft:1,CoordAtLineRight:2}; JSM.CoordLinePosition={CoordOnLine:0,CoordOutsideOfLine:1};JSM.LineLinePosition={LinesDontIntersect:0,LinesIntersectsOnePoint:1,LinesIntersectsCoincident:2};JSM.Line2D=function(a,b){this.start=a;this.direction=b};JSM.Line2D.prototype.Set=function(a,b){this.start=a;this.direction=b}; JSM.Line2D.prototype.CoordPosition=function(a){var b=this.start,c=this.direction;a=c.x*(a.y-b.y)-c.y*(a.x-b.x);return JSM.IsPositive(a)?JSM.CoordLinePosition2D.CoordAtLineLeft:JSM.IsNegative(a)?JSM.CoordLinePosition2D.CoordAtLineRight:JSM.CoordLinePosition2D.CoordOnLine};JSM.Line2D.prototype.Clone=function(){return new JSM.Line2D(this.start.Clone(),this.direction.Clone())};JSM.Line=function(a,b){this.start=a;this.direction=b};JSM.Line.prototype.Set=function(a,b){this.start=a;this.direction=b}; -JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,k=f.y,l=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-k)*(n-k)+(p-l)*(p-l);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-k)*(d-k)+(p-l)*(e-l))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: -JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,k=a.x+e.x,l=a.y+e.y,m=a.z+e.z,n=(k-f)*(k-f)+(l-h)*(l-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((k-f)*(b-f)+(l-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; -JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var k=JSM.CoordAdd(a,g),l=[f,h,a,k],m=d(l,1,0,1,0),n=d(l,0,2,1,0),h=d(l,0,2,3,2),k=d(l,3,2,1,0),l=d(l,3,2,3,2),m=m*l-k*k;if(JSM.IsEqual(m,0))return!1;n=(h*k-n*l)/m;h=(h+n*k)/l;void 0!==b&&(e.MultiplyScalar(n),e= +JSM.Line.prototype.CoordPosition=function(a,b){var c=a.x,d=a.y,e=a.z,f=this.start,h=this.direction,g=f.x,l=f.y,k=f.z,m=f.x+h.x,n=f.y+h.y,p=f.z+h.z,q=(m-g)*(m-g)+(n-l)*(n-l)+(p-k)*(p-k);if(JSM.IsZero(q))return void 0!==b&&b.Set(f.x,f.y,f.z),f.IsEqual(a)?JSM.CoordLinePosition.CoordOnLine:JSM.CoordLinePosition.CoordOutsideOfLine;c=h.Clone().MultiplyScalar(((m-g)*(c-g)+(n-l)*(d-l)+(p-k)*(e-k))/q);f=JSM.CoordAdd(f,c);void 0!==b&&b.Set(f.x,f.y,f.z);f=a.DistanceTo(f);return JSM.IsZero(f)?JSM.CoordLinePosition.CoordOnLine: +JSM.CoordLinePosition.CoordOutsideOfLine};JSM.Line.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z;a=this.start;var e=this.direction,f=a.x,h=a.y,g=a.z,l=a.x+e.x,k=a.y+e.y,m=a.z+e.z,n=(l-f)*(l-f)+(k-h)*(k-h)+(m-g)*(m-g);if(JSM.IsZero(n))return a.Clone();b=e.Clone().MultiplyScalar(((l-f)*(b-f)+(k-h)*(c-h)+(m-g)*(d-g))/n);return JSM.CoordAdd(a,b)}; +JSM.Line.prototype.ClosestPoint=function(a,b,c){function d(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var e=this.direction.Clone().Normalize(),f=this.start,h=JSM.CoordAdd(f,e),g=a.direction.Clone().Normalize();a=a.start;var l=JSM.CoordAdd(a,g),k=[f,h,a,l],m=d(k,1,0,1,0),n=d(k,0,2,1,0),h=d(k,0,2,3,2),l=d(k,3,2,1,0),k=d(k,3,2,3,2),m=m*k-l*l;if(JSM.IsEqual(m,0))return!1;n=(h*l-n*k)/m;h=(h+n*l)/k;void 0!==b&&(e.MultiplyScalar(n),e= JSM.CoordAdd(f,e),b.Set(e.x,e.y,e.z));void 0!==c&&(g.MultiplyScalar(h),b=JSM.CoordAdd(a,g),c.Set(b.x,b.y,b.z));return!0};JSM.Line.prototype.LinePosition=function(a,b){var c=new JSM.Coord(0,0,0),d=new JSM.Coord(0,0,0);return!this.ClosestPoint(a,c,d)?JSM.LineLinePosition.LinesIntersectsCoincident:c.IsEqual(d)?(void 0!==b&&b.Set(c.x,c.y,c.z),JSM.LineLinePosition.LinesIntersectsOnePoint):JSM.LineLinePosition.LinesDontIntersect}; JSM.Line.prototype.Clone=function(){return new JSM.Line(this.start.Clone(),this.direction.Clone())};JSM.Box2D=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b}; JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.GetSize=function(){return JSM.CoordSub(this.max,this.min)};JSM.Box.prototype.IsCoordInside=function(a){return JSM.IsLower(a.x,this.min.x)||JSM.IsLower(a.y,this.min.y)||JSM.IsLower(a.z,this.min.z)||JSM.IsGreater(a.x,this.max.x)||JSM.IsGreater(a.y,this.max.y)||JSM.IsGreater(a.z,this.max.z)?!1:!0};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())}; @@ -63,18 +63,18 @@ JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0=== JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c}; JSM.RotationXYZTransformation=function(a,b,c,d){var e=new JSM.Transformation;e.Append(JSM.RotationXTransformation(a,d));e.Append(JSM.RotationYTransformation(b,d));e.Append(JSM.RotationZTransformation(c,d));return e};JSM.CoordPlanePosition={CoordOnPlane:0,CoordInFrontOfPlane:1,CoordAtBackOfPlane:2};JSM.LinePlanePosition={LineParallelToPlane:0,LineIntersectsPlane:1};JSM.Plane=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d}; JSM.Plane.prototype.Set=function(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d};JSM.Plane.prototype.GetNormal=function(){return new JSM.Vector(this.a,this.b,this.c)};JSM.Plane.prototype.CoordSignedDistance=function(a){var b=this.a,c=this.b,d=this.c;return(b*a.x+c*a.y+d*a.z+this.d)/Math.sqrt(b*b+c*c+d*d)};JSM.Plane.prototype.CoordDistance=function(a){a=this.CoordSignedDistance(a);return Math.abs(a)}; -JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,k=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(k=-k);b=this.GetNormal().Normalize();return a.Clone().Offset(b,k)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; -JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,k=this.c,l=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+k*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+k*f+l)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; -JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,k=this.d,l=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(l))return null;b.MultiplyScalar((f*c+h*d+g*e+k)/l);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; +JSM.Plane.prototype.ProjectCoord=function(a){var b=a.x,c=a.y,d=a.z,e=this.a,f=this.b,h=this.c,g=this.d,l=this.CoordDistance(a);JSM.IsGreater(e*b+f*c+h*d+g,0)&&(l=-l);b=this.GetNormal().Normalize();return a.Clone().Offset(b,l)};JSM.Plane.prototype.CoordPosition=function(a){a=this.a*a.x+this.b*a.y+this.c*a.z+this.d;return JSM.IsPositive(a)?JSM.CoordPlanePosition.CoordInFrontOfPlane:JSM.IsNegative(a)?JSM.CoordPlanePosition.CoordAtBackOfPlane:JSM.CoordPlanePosition.CoordOnPlane}; +JSM.Plane.prototype.LinePosition=function(a,b){var c=a.direction.Clone().Normalize(),d=a.start.x,e=a.start.y,f=a.start.z,h=this.a,g=this.b,l=this.c,k=this.d,m=h*(d-(a.start.x+c.x))+g*(e-(a.start.y+c.y))+l*(f-(a.start.z+c.z));if(JSM.IsZero(m))return JSM.LinePlanePosition.LineParallelToPlane;void 0!==b&&(c.MultiplyScalar((h*d+g*e+l*f+k)/m),c=JSM.CoordAdd(a.start,c),b.Set(c.x,c.y,c.z));return JSM.LinePlanePosition.LineIntersectsPlane}; +JSM.Plane.prototype.LineIntersection=function(a){var b=a.direction.Clone().Normalize(),c=a.start.x,d=a.start.y,e=a.start.z,f=this.a,h=this.b,g=this.c,l=this.d,k=f*(c-(a.start.x+b.x))+h*(d-(a.start.y+b.y))+g*(e-(a.start.z+b.z));if(JSM.IsZero(k))return null;b.MultiplyScalar((f*c+h*d+g*e+l)/k);return JSM.CoordAdd(a.start,b)};JSM.Plane.prototype.Clone=function(){return new JSM.Plane(this.a,this.b,this.c,this.d)}; JSM.GetPlaneFromCoordAndDirection=function(a,b){var c=new JSM.Plane,d=b.Clone().Normalize(),e=d.x,f=d.y,d=d.z;c.Set(e,f,d,-(e*a.x+f*a.y+d*a.z));return c};JSM.GetPlaneFromThreeCoords=function(a,b,c){var d=new JSM.Plane,e=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z),f=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);b=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);d.Set(e,f,b,-(e*a.x+f*a.y+b*a.z));return d}; -JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,k=c.c;c=c.d;var l=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+k*(f-(a.z+d.z));if(JSM.IsZero(l))return 0;d.MultiplyScalar((h*b+g*e+k*f+c)/l);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+k*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; -JSM.Project=function(a,b,c,d,e,f,h,g,k){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?k=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*k[2]+k[0],f[1]=f[1]*k[3]+k[1],e.x=f[0],e.y=f[1],e.z=f[2],k=e);return k}; +JSM.CoordPlaneSignedDirectionalDistance=function(a,b,c){var d=b.Clone().Normalize();b=a.x;var e=a.y,f=a.z,h=c.a,g=c.b,l=c.c;c=c.d;var k=h*(b-(a.x+d.x))+g*(e-(a.y+d.y))+l*(f-(a.z+d.z));if(JSM.IsZero(k))return 0;d.MultiplyScalar((h*b+g*e+l*f+c)/k);d=JSM.CoordAdd(a,d);a=a.DistanceTo(d);JSM.IsNegative(h*b+g*e+l*f+c)&&(a=-a);return a};JSM.CoordPlaneDirectionalDistance=function(a,b,c){return Math.abs(JSM.CoordPlaneSignedDirectionalDistance(a,b,c))}; +JSM.Project=function(a,b,c,d,e,f,h,g,l){b=JSM.MatrixView(b,c,d);h=JSM.MatrixPerspective(e,f,h,g);e=new JSM.Coord(0,0,0);g=[];f=[];g[0]=a.x;g[1]=a.y;g[2]=a.z;g[3]=1;f=JSM.MatrixVectorMultiply(h,JSM.MatrixVectorMultiply(b,g));a=f[3];JSM.IsZero(a)?l=null:(f[0]=0.5*(f[0]/a)+0.5,f[1]=0.5*(f[1]/a)+0.5,f[2]=0.5*(f[2]/a)+0.5,f[0]=f[0]*l[2]+l[0],f[1]=f[1]*l[3]+l[1],e.x=f[0],e.y=f[1],e.z=f[2],l=e);return l}; JSM.ConvexHull2D=function(a){function b(a,b){var c=a.length,d=0,e;for(e=1;ea.length)return c;var d=function(a){var b=a.length,c=JSM.Inf,d=-1,e,f;for(e=0;en)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qn)return m;var p=new function(){this.vertices=[];this.edges=[];this.triangles=[]},q;for(q=0;qe)return d;var f,h,g,k,l;for(f=0;fe)return d;var f,h,g,l,k;for(f=0;fb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cf))if(3==f)a.push(e.map);else{f=b(e.polygon);if(null===f)return null;e=c(e,f);d.push(e.resultData1);d.push(e.resultData2)}return a}; JSM.TriangulatePolygon2D=function(a){if(null===a)return null;var b=a.VertexCount();if(3>b)return null;if(3==b)return[[0,1,2]];b=a.GetComplexity();return b===JSM.Complexity.Invalid?null:b==JSM.Complexity.Convex?JSM.TriangulateConvexPolygon(a):JSM.TriangulateConcavePolygon2D(a)};JSM.TriangulatePolygon=function(a){a=a.ToPolygon2D();return JSM.TriangulatePolygon2D(a)}; JSM.TraverseOctreeNodes=function(a,b){function c(a,b){if(b(a)&&null!==a.children){var f,h;for(f=0;f=this.maxCoordNumInNodes&&this.SplitNode(c))return this.AddCoordToNode(a,c);d=this.coords.length;this.coords.push(a);c.coords.push(d);return d}; JSM.Octree.prototype.FindNodeForCoord=function(a,b){if(null===b.children)return b;var c=b.box.GetCenter(),d=a.x>c.x,e=a.y>c.y,c=a.z>c.z;return!d&&!e&&!c?this.FindNodeForCoord(a,b.children[0]):d&&!e&&!c?this.FindNodeForCoord(a,b.children[1]):d&&e&&!c?this.FindNodeForCoord(a,b.children[2]):!d&&e&&!c?this.FindNodeForCoord(a,b.children[3]):!d&&!e&&c?this.FindNodeForCoord(a,b.children[4]):d&&!e&&c?this.FindNodeForCoord(a,b.children[5]):d&&e&&c?this.FindNodeForCoord(a,b.children[6]):!d&&e&&c?this.FindNodeForCoord(a, @@ -129,10 +130,10 @@ JSM.BSPTree.prototype.GetNodes=function(){var a=[];this.Traverse(function(b){a.p JSM.BSPTree.prototype.AddPolygonToNode=function(a,b,c){if(3>b.VertexCount())return!1;var d;if(null===a.polygon){d=b.GetNormal();var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0b?c[e]=f:c[e]=f+1;f=c[0];d=c[d-1];if(0===f&&f!=d)for(e=0;c[e]==f;e++)c[e]=d;return c}; +JSM.MakeBodyInsideOut=function(a){var b,c,d,e,f;for(b=0;bl;l++)0===l?m=e:1===l?m=f:2===l&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,k)&&(g=l,k=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== +JSM.CalculateCubicTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e1.Clone().Normalize(),f=c.e2.Clone().Normalize(),h=c.e3.Clone().Normalize(),g=-1,l=0,k,m,n;for(k=0;3>k;k++)0===k?m=e:1===k?m=f:2===k&&(m=h),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,l)&&(g=k,l=n);if(-1===g)return d;b=null;0===g?b=new JSM.CoordSystem(c.origo,f,h,new JSM.Coord(0,0,0)):1===g?b=new JSM.CoordSystem(c.origo,e,h,new JSM.Coord(0,0,0)):2===g&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=c.e3.Clone().Normalize();if(e.IsCollinearWith(b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];var f=(new JSM.Line(c.origo,e)).ProjectCoord(a);b=JSM.CoordSignedDistance(c.origo,f,e);var h=c.e1.Clone().Normalize();a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,h,e);c=c.e1.Length();d.x=e*c;d.y=b;return[d,e]}; JSM.CalculatePolygonPlanarTextureCoords=function(a,b){var c=[],d=a.GetPolygon(b),e=a.GetTextureProjectionCoords(),f,h;for(f=0;fg;g++)r=c[h[g]],u.AddVertexIndex(2*b[r[0]]+2*r[1]+1),r=c[h[2-g]],v.AddVertexIndex(2*b[r[0]]+2*r[1]);f.AddPolygon(u);f.AddPolygon(v)}}}var f=new JSM.Body,h=[],g=new JSM.ContourPolygon;g.FromArray(a);(function(a, -b,c,d){var e,f,g,h,u;for(e=0;ef;f++)l=c[g[f]],u.AddVertexIndex(2*b[l[0]]+2*l[1]+1),l=c[g[2-f]],r.AddVertexIndex(2*b[l[0]]+2*l[1]);h.AddPolygon(u);h.AddPolygon(r)}}}var h=new JSM.Body,g=[],l=new JSM.ContourPolygon;l.FromArray(a); +(function(a,b,c,d){var e,f,g,h,l;for(e=0;ew)){var G=void 0,A=void 0,C=void 0,N=void 0,O=void 0,J=void 0,I=void 0,E=void 0,Q=void 0,F=void 0;if(3==w||l)for(F=0;Fv)){var H=void 0,z=void 0,B=void 0,N=void 0,O=void 0,J=void 0,I=void 0,E=void 0,Q=void 0,G=void 0;if(3==v||k)for(G=0;Gf)){var h,n,p,q=null;if(3===f)q=JSM.CalculateBodyPolygonNormal(a,b),h=a.GetVertex(d.GetVertexIndex(0)).position,n=a.GetVertex(d.GetVertexIndex(1)).position, p=a.GetVertex(d.GetVertexIndex(2)).position,e(q,h,n,p);else if(h=!0,void 0!==c&&c&&(h=!1),q=JSM.CalculateBodyPolygonNormal(a,b),h){h=new JSM.Polygon;for(b=0;bp.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, +JSM.TriangleBody.prototype.Finalize=function(a){function b(b,c,d,f){function h(a,b,c,d,e){var f=new JSM.Vector(0,0,0),g=0;c=a.GetTriangle(c);b=e[b];var l,k;for(e=0;ep.mat)p.mat=a.GetDefaultMaterialIndex();if(void 0===p.n0||void 0===p.n1||void 0===p.n2)void 0===p.curve||0>p.curve?(c=d[e],c=b.AddNormal(c.x, c.y,c.z),p.n0=c,p.n1=c,p.n2=c,p.curve=-1):(p.n0=h(b,p.v0,c,d,f),p.n1=h(b,p.v1,c,d,f),p.n2=h(b,p.v2,c,d,f));if(void 0===p.u0||void 0===p.u1||void 0===p.u2)p.u0=b.AddDefaultUV(),p.u1=b.AddDefaultUV(),p.u2=b.AddDefaultUV()}var c=[],d={},e;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),l=h.GetVertexIndex(2),b(c,h,f,g,l);else{k= -new JSM.Polygon;for(e=0;eg))if(3==g)f=h.GetVertexIndex(0),g=h.GetVertexIndex(1),k=h.GetVertexIndex(2),b(c,h,f,g,k);else{l= +new JSM.Polygon;for(e=0;ef.mat||f.mat>=e)||d[f.mat].push(a);var p,q;for(a=0;al;l++)JSM.IsLower(f[l],b[l])?(h[l]=-1,g[l]=b[l],k=!1):JSM.IsGreater(f[l],c[l])?(h[l]=1,g[l]=c[l],k=!1):h[l]=0;l=null;if(k)return l={position:d,distance:0};k=[0,0,0];for(l=0;3>l;l++)0!==h[l]&&!JSM.IsZero(e[l])?k[l]=(g[l]-f[l])/e[l]:k[l]=-1;h=0;for(l=1;3>l;l++)JSM.IsLower(k[h],k[l])&&(h=l);if(JSM.IsNegative(k[h]))return null; -var m=[0,0,0];for(l=0;3>l;l++)if(h!=l){if(m[l]=f[l]+k[h]*e[l],JSM.IsLower(m[l],b[l])||JSM.IsGreater(m[l],c[l]))return null}else m[l]=g[l];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:l={position:f,distance:d}}; -JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;ck;k++)JSM.IsLower(f[k],b[k])?(h[k]=-1,g[k]=b[k],l=!1):JSM.IsGreater(f[k],c[k])?(h[k]=1,g[k]=c[k],l=!1):h[k]=0;k=null;if(l)return k={position:d,distance:0};l=[0,0,0];for(k=0;3>k;k++)0!==h[k]&&!JSM.IsZero(e[k])?l[k]=(g[k]-f[k])/e[k]:l[k]=-1;h=0;for(k=1;3>k;k++)JSM.IsLower(l[h],l[k])&&(h=k);if(JSM.IsNegative(l[h]))return null; +var m=[0,0,0];for(k=0;3>k;k++)if(h!=k){if(m[k]=f[k]+l[h]*e[k],JSM.IsLower(m[k],b[k])||JSM.IsGreater(m[k],c[k]))return null}else m[k]=g[k];f=JSM.CoordFromArray(m);d=d.DistanceTo(f);return a.IsLengthReached(d)?null:k={position:f,distance:d}}; +JSM.RayOctreeIntersection=function(a,b,c){var d=null,e=!1,f=null!==c&&void 0!==c;JSM.TraverseOctreeNodes(b,function(b){if(!f&&e||!JSM.RayBoxIntersection(a,b.box.min,b.box.max))return!1;var c;for(c=0;c=this.arrayBuffer.byteLength}; JSM.BinaryReader.prototype.ReadBoolean=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a?!0:!1};JSM.BinaryReader.prototype.ReadCharacter=function(){var a=this.dataView.getInt8(this.position);this.position+=1;return a};JSM.BinaryReader.prototype.ReadUnsignedCharacter=function(){var a=this.dataView.getUint8(this.position);this.position+=1;return a}; JSM.BinaryReader.prototype.ReadInteger16=function(){var a=this.dataView.getInt16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadUnsignedInteger16=function(){var a=this.dataView.getUint16(this.position,this.isLittleEndian);this.position+=2;return a};JSM.BinaryReader.prototype.ReadInteger32=function(){var a=this.dataView.getInt32(this.position,this.isLittleEndian);this.position+=4;return a}; @@ -284,39 +286,39 @@ JSM.BinaryReader.prototype.ReadUnsignedInteger32=function(){var a=this.dataView. JSM.GetArrayBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)};JSM.GetArrayBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsArrayBuffer(a)};JSM.GetStringBufferFromURL=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="text";c.onload=function(){var a=c.response;a&&b(a)};c.send(null)}; JSM.GetStringBufferFromFile=function(a,b){var c=new FileReader;c.onloadend=function(a){a.target.readyState==FileReader.DONE&&b(a.target.result)};c.readAsText(a)};JSM.LoadMultipleBuffersInternal=function(a,b,c,d){if(b>=a.length)d(c);else{var e=a[b],f=null,f=e.isFile?e.isArrayBuffer?JSM.GetArrayBufferFromFile:JSM.GetStringBufferFromFile:e.isArrayBuffer?JSM.GetArrayBufferFromURL:JSM.GetStringBufferFromURL;f(e.originalObject,function(e){c.push(e);JSM.LoadMultipleBuffersInternal(a,b+1,c,d)})}}; JSM.LoadMultipleBuffers=function(a,b){JSM.LoadMultipleBuffersInternal(a,0,[],function(a){b(a)})}; -JSM.Read3dsFile=function(a,b){var c,d,e,f,h,g,k,l,m,n,p,q,t,r,u,v,s,w,y,z,x,D,H,K,L,G,A,C,N,O,J,I,E,Q,F,M,T,S,U,Y;function B(a,c){if(void 0!==b.onLog&&null!==b.onLog)b.onLog(a,c)}function R(a){for(var b="",c=0,d=0;64>d;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== -b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;k=41024;l=41025;m=41040;n=16;p=17;q=18;t=19;r=41472;u=41728;v=41816;s=41818;w=41812;y=41814;z=41820;x=48;D=49;H=16384;K=16640;L=17920;G=18176;A=16656;C=16704;N=16672;O=16736;J=16688;I=16720;E=45056;Q=45058;F=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ -255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==x?d=a.ReadUnsignedInteger16()/100:b==D?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= -[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==u?d.texture=R(a):b==v?d.offset[0]=a.ReadFloat32():b==s?d.offset[1]=a.ReadFloat32():b==w?d.scale[0]=a.ReadFloat32():b==y?d.scale[1]=a.ReadFloat32():b==z?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){B("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(B("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(B("Read material ambient chunk ("+c.toString(16)+ -", "+d+")",3),n.ambient=V(a,b,p)):b==h?(B("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(B("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==k?(B("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==l?(B("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(B("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= -W(a,b,p)):b==r?(B("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(B("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){B("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,k;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else B("Skip chunk ("+c.toString(16)+", "+d+")",4), -a.Skip(d-6)})}function ca(a,b,c){B("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?B("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==G?B("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):B("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){B("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==H?ca(a,b,c):(B("Skip chunk ("+ -b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dd;){c=a.ReadCharacter();if(0===c)break;b+=String.fromCharCode(c);d+=1}return b}function X(a){var b=[],c;for(c=0;3>c;c++)b[c]=a.ReadFloat32();return b}function P(a,b,c){for(;a.GetPosition()<=b-6;){var d=a,e=c,f=d.ReadUnsignedInteger16(),d=d.ReadUnsignedInteger32();e(f,d)}}if(void 0=== +b||null===b)b={};c=15677;d=45055;e=40960;f=40976;h=40992;g=41008;l=41024;k=41025;m=41040;n=16;p=17;q=18;t=19;s=41472;w=41728;u=41816;r=41818;v=41812;C=41814;D=41820;y=48;x=49;F=16384;K=16640;L=17920;H=18176;z=16656;B=16704;N=16672;O=16736;J=16688;I=16720;E=45056;Q=45058;G=45072;M=45075;T=45088;S=45089;U=45090;Y=45104;(function(a){function V(a,b,c){var d=[0,0,0];b=a.GetPosition()+c-6;var e=!1;P(a,b,function(b,c){b==p?e||(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/ +255):b==q?(d[0]=a.ReadUnsignedCharacter()/255,d[1]=a.ReadUnsignedCharacter()/255,d[2]=a.ReadUnsignedCharacter()/255,e=!0):b==n?e||(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32()):b==t?(d[0]=a.ReadFloat32(),d[1]=a.ReadFloat32(),d[2]=a.ReadFloat32(),e=!0):a.Skip(c-6)});return d}function W(a,b,c){var d=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==y?d=a.ReadUnsignedInteger16()/100:b==x?d=a.ReadFloat32():a.Skip(c-6)});return d}function Z(a,b,c,d){d.texture=null;d.offset=[0,0];d.scale= +[1,1];d.rotation=0;b=a.GetPosition()+c-6;P(a,b,function(b,c){b==w?d.texture=R(a):b==u?d.offset[0]=a.ReadFloat32():b==r?d.offset[1]=a.ReadFloat32():b==v?d.scale[0]=a.ReadFloat32():b==C?d.scale[1]=a.ReadFloat32():b==D?d.rotation=a.ReadFloat32():a.Skip(c-6)})}function $(a,c,d){A("Read material chunk ("+c.toString(16)+", "+d+")",2);var n={},p=a.GetPosition()+d-6;P(a,p,function(b,p){b==e?(A("Read material name chunk ("+c.toString(16)+", "+d+")",3),n.name=R(a)):b==f?(A("Read material ambient chunk ("+c.toString(16)+ +", "+d+")",3),n.ambient=V(a,b,p)):b==h?(A("Read material diffuse chunk ("+c.toString(16)+", "+d+")",3),n.diffuse=V(a,b,p)):b==g?(A("Read material specular chunk ("+c.toString(16)+", "+d+")",3),n.specular=V(a,b,p)):b==l?(A("Read material shininess chunk ("+c.toString(16)+", "+d+")",3),n.shininess=W(a,b,p)):b==k?(A("Read material shininess strength chunk ("+c.toString(16)+", "+d+")",3),n.shininessStrength=W(a,b,p)):b==m?(A("Read material transparency chunk ("+c.toString(16)+", "+d+")",3),n.transparency= +W(a,b,p)):b==s?(A("Read material texture map chunk ("+c.toString(16)+", "+d+")",3),Z(a,b,p,n)):(A("Skip chunk ("+b.toString(16)+", "+p+")",3),a.Skip(p-6))});if(void 0!==b.onMaterial&&null!==b.onMaterial)b.onMaterial(n)}function aa(a,c,d){A("Read faces chunk ("+c.toString(16)+", "+d+")",4);c=a.GetPosition()+d-6;var e=a.ReadUnsignedInteger16(),f,g,h,l;for(d=0;df;f++){for(g=0;3>g;g++)e.push(a.ReadFloat32());3>f?e.push(0):e.push(1)}if(void 0!==b.onTransformation&&null!==b.onTransformation)b.onTransformation(e)}else A("Skip chunk ("+c.toString(16)+", "+d+")",4), +a.Skip(d-6)})}function ca(a,b,c){A("Read object chunk ("+b.toString(16)+", "+c+")",2);b=a.GetPosition()+c-6;var d=R(a);P(a,b,function(b,c){b==K?ba(a,d,b,c):(b==L?A("Skip light chunk ("+d+", "+b.toString(16)+", "+c+")",3):b==H?A("Skip camera chunk ("+d+", "+b.toString(16)+", "+c+")",3):A("Skip chunk ("+b.toString(16)+", "+c+")",3),a.Skip(c-6))})}function da(a,b,c){A("Read editor chunk ("+b.toString(16)+", "+c+")",1);b=a.GetPosition()+c-6;P(a,b,function(b,c){b==d?$(a,b,c):b==F?ca(a,b,c):(A("Skip chunk ("+ +b.toString(16)+", "+c+")",2),a.Skip(c-6))})}function ea(a,c,d){function e(a,b){var c=[];a.Skip(10);var d,f,g,h=a.ReadInteger32();for(d=0;dg;g++)a[0+g]*=c,a[4+g]*=d,a[8+g]*=f;return a}function f(a,b){var c=b[0],d=b[1],e=b[2],g;for(g=0;3>g;g++)a[12+g]+=a[0+g]*c+a[4+g]*d+a[8+g]*e;return a}function g(a,b){var c,d;for(c=0;cn.length)){var p="";for(a=1;an.length||d(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vn"==n[0])4>n.length||e(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("vt"==n[0])3>n.length||f(parseFloat(n[1]), -parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],r;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== -n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&k(n))}}function k(a){a=a.split("\n"); -var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,k,l,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,k,l;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],l,m;for(l=c+1;le.length;l++)if(m=a[l].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);l+=1;if(3!=e.length)return-1; -if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return l}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; +parseFloat(n[2]));else if("f"==n[0]){if(!(4>n.length)){var p=[],q=[],t=[],s;for(a=1;an.length)&&void 0!==b.onUseMaterial&&null!==b.onUseMaterial)b.onUseMaterial(n[1])}else if("newmtl"==n[0]){if(!(2>n.length)&&void 0!==b.onNewMaterial&&null!==b.onNewMaterial)b.onNewMaterial(n[1])}else if("Ka"== +n[0]||"Kd"==n[0]||"Ks"==n[0])4>n.length||c(n[0],parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));else if("Ns"==n[0]||"Tr"==n[0]||"d"==n[0]){if(!(2>n.length)&&void 0!==b.onMaterialParameter&&null!==b.onMaterialParameter)b.onMaterialParameter(n[0],n[1])}else if("map_Kd"==n[0]){if(!(2>n.length)&&(n=g(a,"map_Kd"),void 0!==b.onMaterialTexture&&null!==b.onMaterialTexture))b.onMaterialTexture(n)}else"mtllib"==n[0]&&!(2>n.length)&&(n=g(a,"mtllib"),n=h(n.trim()),null!==n&&l(n))}}function l(a){a=a.split("\n"); +var b,c;for(b=0;bc||c>=b.length))return b=b[c],0===f?g=a.AddVertex(b.x,b.y,b.z):1===f?g=a.AddNormal(b.x,b.y,b.z):2===f&&(g=a.AddUV(b.x,b.y)),e[c]=g}}var e,f,g,h,l,k,m;for(e=0;ec;c++)b[c]=a.ReadFloat32();return b}if(void 0===b||null===b)b={};var d=new JSM.BinaryReader(a,!0);d.Skip(80);var e=d.ReadUnsignedInteger32(),f,h,g,l,k;for(f=0;fd.length)return-1;var d=[parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4])],e=[],k,m;for(k=c+1;ke.length;k++)if(m=a[k].trim(),0!==m.length&&(m=m.split(/\s+/),0!==m.length&&"vertex"==m[0]))if(4>m.length)break;else m=[parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])],e.push(m);k+=1;if(3!=e.length)return-1; +if(void 0!==b.onFace&&null!==b.onFace)b.onFace(e[0],e[1],e[2],d);return k}return c+1}if(void 0===b||null===b)b={};for(var d=0,e=a.split("\n");db)return!1;a=new JSM.BinaryReader(a,!0);a.Skip(80);a=a.ReadUnsignedInteger32();return b!=50*a+84?!1:!0}; JSM.ConvertStlToJsonData=function(a,b){var c=new JSM.TriangleModel,d=c.AddBody(new JSM.TriangleBody("Default")),e=c.GetBody(d);null!==a?JSM.ReadBinaryStlFile(a,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c=e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}}):null!==b&&JSM.ReadAsciiStlFile(b,{onFace:function(a,b,c,d){a=e.AddVertex(a[0],a[1],a[2]);b=e.AddVertex(b[0],b[1],b[2]);c= e.AddVertex(c[0],c[1],c[2]);d=(new JSM.Vector(d[0],d[1],d[2])).Normalize();d=e.AddNormal(d.x,d.y,d.z);e.AddTriangle(a,b,c,d,d,d)}});c.Finalize();return JSM.ConvertTriangleModelToJsonData(c)};JSM.ImportFileList=function(){this.isFile=this.descriptors=this.originalList=null}; JSM.ImportFileList.prototype.InitFromFiles=function(a){this.originalList=a;this.descriptors=[];var b,c;for(b=0;bs;s++)v[s].z=n-c;s=JSM.GeneratePrism(v,l,c,!0);k.Merge(s);if(d)for(s=0;sb&&(e=a,p=!1);for(s=0;sr;r++)u[r].z=n-c;r=JSM.GeneratePrism(u,k,c,!0,null);l.Merge(r);if(d)for(r=0;rb&&(e=a,p=!1);for(r=0;rh;h++)l=0===h?g.pgon1:g.pgon2,-1===l&&(l=0===h?g.pgon2:g.pgon1),l=b.GetVertex(d[l]).position.Clone(),k=JSM.CoordAdd(k,l.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(k)))}})();(function(){var e=[],h,g,k,l;for(k=0;kg&&(g=3);e=k/g;for(k=1;k<=g;k++)f=l.getPointAtLength(k*e),f=c(a,h,b,f.x,f.y);return f}function e(a){a=a.GetLastContour();var b=a.VertexCount();if(0!==b){var c=a.GetVertex(0),b=a.GetVertex(b-1);c.IsEqualWithEps(b,0.1)&&a.vertices.pop()}}function f(a){0h;h++)k=0===h?g.pgon1:g.pgon2,-1===k&&(k=0===h?g.pgon2:g.pgon1),k=b.GetVertex(d[k]).position.Clone(),l=JSM.CoordAdd(l,k.MultiplyScalar(0.25));e.push(b.AddVertex(new JSM.BodyVertex(l)))}})();(function(){var e=[],h,g,l,k;for(l=0;lg&&(g=3);e=k/g;for(k=1;k<=g;k++)f=l.getPointAtLength(k*e),f=c(a,h,b,f.x,f.y);return f}function e(a){a=a.GetLastContour();var b=a.VertexCount();if(0!==b){var c=a.GetVertex(0),b=a.GetVertex(b-1);c.IsEqualWithEps(b,0.1)&&a.vertices.pop()}}function f(a){0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example - - - - - - - - - - - -

- - - - - diff --git a/sandbox/svgtomodeltexture.html b/sandbox/svgtomodeltexture.html index 44de00e9..9f9f4b8d 100644 --- a/sandbox/svgtomodeltexture.html +++ b/sandbox/svgtomodeltexture.html @@ -105,7 +105,7 @@ var svgObject = document.getElementById ('exampleSvg'); var height = 10; var segmentLength = 2; - var modelAndMaterials = JSM.SvgToModel (svgObject, height, segmentLength); + var modelAndMaterials = JSM.SvgToModel (svgObject, height, segmentLength, null); var model = modelAndMaterials[0]; var materials = modelAndMaterials[1]; diff --git a/src/extras/extgenerator.js b/src/extras/extgenerator.js index 9cf4e2db..9fcf9ae8 100644 --- a/src/extras/extgenerator.js +++ b/src/extras/extgenerator.js @@ -71,7 +71,7 @@ JSM.GenerateLegoBrick = function (rows, columns, isLarge, hasTopCylinders, hasBo basePolygon[i].z = unitHeight - wallWidth; } - var top = JSM.GeneratePrism (basePolygon, normal, wallWidth, true); + var top = JSM.GeneratePrism (basePolygon, normal, wallWidth, true, null); result.Merge (top); var cylinderCenter, cylinder; diff --git a/src/extras/svgtomodel.js b/src/extras/svgtomodel.js index d4c0940f..d2712789 100644 --- a/src/extras/svgtomodel.js +++ b/src/extras/svgtomodel.js @@ -5,10 +5,11 @@ * svgObject {html svg element} the svg element * height {number} the height of the result body * segmentLength {number} the maximum length of curved segments +* curveAngle {number} if not null, defines the curve angle of the model * Returns: * {Body} the result */ -JSM.SvgToModel = function (svgObject, height, segmentLength) +JSM.SvgToModel = function (svgObject, height, segmentLength, curveAngle) { function SegmentElem (elem, segmentLength) { @@ -291,7 +292,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) return result; } - function ContourPolygonToPrisms (polygon, height) + function ContourPolygonToPrisms (polygon, height, curveAngle) { function CreateBasePolygon (polygon, orientation) { @@ -346,7 +347,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) if (contourCount == 1) { baseOrientation = polygon.GetContour (0).GetOrientation (); basePolygon = CreateBasePolygon (polygon.GetContour (0), baseOrientation); - prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true); + prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true, curveAngle); prisms.push (prism); } else if (contourCount > 1) { baseOrientation = polygon.GetContour (0).GetOrientation (); @@ -358,7 +359,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) orientation = polygon.GetContour (i).GetOrientation (); if (orientation == baseOrientation) { basePolygon = CreateBasePolygon (polygon.GetContour (i), baseOrientation); - prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true); + prism = JSM.GeneratePrism (basePolygon, direction, currentHeight, true, curveAngle); prisms.push (prism); } else { AddHoleToBasePolygon (holeBasePolygon, polygon.GetContour (i), orientation); @@ -367,10 +368,10 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) } if (!hasHoles) { - prism = JSM.GeneratePrism (holeBasePolygon, direction, currentHeight, true); + prism = JSM.GeneratePrism (holeBasePolygon, direction, currentHeight, true, curveAngle); prisms.push (prism); } else { - prism = JSM.GeneratePrismWithHole (holeBasePolygon, direction, currentHeight, true); + prism = JSM.GeneratePrismWithHole (holeBasePolygon, direction, currentHeight, true, curveAngle); prisms.push (prism); } } @@ -390,7 +391,7 @@ JSM.SvgToModel = function (svgObject, height, segmentLength) var i, j, prismsAndMaterial, currentPrisms, currentPrism, currentMaterial; for (i = 0; i < polygons.length; i++) { - prismsAndMaterial = ContourPolygonToPrisms (polygons[i], currentHeight); + prismsAndMaterial = ContourPolygonToPrisms (polygons[i], currentHeight, curveAngle); currentPrisms = prismsAndMaterial[0]; currentMaterial = prismsAndMaterial[1]; materials.AddMaterial (currentMaterial); diff --git a/src/geometry/polygon.js b/src/geometry/polygon.js index 12158f7e..22298906 100644 --- a/src/geometry/polygon.js +++ b/src/geometry/polygon.js @@ -4,7 +4,9 @@ */ JSM.Polygon = function () { - this.vertices = []; + this.vertices = null; + this.cache = null; + this.Clear (); }; /** @@ -29,6 +31,7 @@ JSM.Polygon.prototype.AddVertex = function (x, y, z) JSM.Polygon.prototype.AddVertexCoord = function (coord) { this.vertices.push (coord); + this.ClearCache (); }; /** @@ -45,28 +48,60 @@ JSM.Polygon.prototype.GetVertex = function (index) }; /** -* Function: Polygon.SetVertex -* Description: Modifies the coordinates of an existing vertex. +* Function: Polygon.VertexCount +* Description: Returns the vertex count of the polygon. +* Returns: +* {integer} vertex count +*/ +JSM.Polygon.prototype.VertexCount = function () +{ + return this.vertices.length; +}; + +/** +* Function: Polygon.GetNextVertex +* Description: Returns the vertex index after the given one. * Parameters: -* index {integer} the index of the vertex -* x {number} the x coordinate of the vertex -* y {number} the y coordinate of the vertex -* z {number} the z coordinate of the vertex +* index {integer} the vertex index +* Returns: +* {integer} the result */ -JSM.Polygon.prototype.SetVertex = function (index, x, y, z) +JSM.Polygon.prototype.GetNextVertex = function (index) { - this.vertices[index].Set (x, y, z); + var count = this.vertices.length; + return (index < count - 1 ? index + 1 : 0); }; /** -* Function: Polygon.VertexCount -* Description: Returns the vertex count of the polygon. +* Function: Polygon.GetVertexAngle +* Description: Returns the angle of the given vertex. +* Parameters: +* index {integer} the vertex index * Returns: -* {integer} vertex count +* {number} the result */ -JSM.Polygon.prototype.VertexCount = function () +JSM.Polygon.prototype.GetVertexAngle = function (index) { - return this.vertices.length; + var prev = this.vertices[this.GetPrevVertex (index)]; + var curr = this.vertices[index]; + var next = this.vertices[this.GetNextVertex (index)]; + var prevDir = JSM.CoordSub (prev, curr); + var nextDir = JSM.CoordSub (next, curr); + return prevDir.AngleTo (nextDir); +}; + +/** +* Function: Polygon.GetPrevVertex +* Description: Returns the vertex index before the given one. +* Parameters: +* index {integer} the vertex index +* Returns: +* {integer} the result +*/ +JSM.Polygon.prototype.GetPrevVertex = function (index) +{ + var count = this.vertices.length; + return (index > 0 ? index - 1 : count - 1); }; /** @@ -77,7 +112,12 @@ JSM.Polygon.prototype.VertexCount = function () */ JSM.Polygon.prototype.GetNormal = function () { - return JSM.CalculateNormal (this.vertices); + if (this.cache.normal !== null) { + return this.cache.normal; + } + var result = JSM.CalculateNormal (this.vertices); + this.cache.normal = result; + return result; }; /** @@ -138,6 +178,18 @@ JSM.Polygon.prototype.FromArray = function (vertices) JSM.Polygon.prototype.Clear = function () { this.vertices = []; + this.ClearCache (); +}; + +/** +* Function: Polygon.ClearCache +* Description: Clears stored values from the polygon. +*/ +JSM.Polygon.prototype.ClearCache = function () +{ + this.cache = { + normal : null + }; }; /** @@ -434,9 +486,9 @@ JSM.OffsetPolygonContour = function (polygon, width) var i, angle; for (i = 0; i < count; i++) { - prev = (i === 0 ? count - 1 : i - 1); + prev = polygon.GetPrevVertex (i); curr = i; - next = (i === count - 1 ? 0 : i + 1); + next = polygon.GetNextVertex (i); prevVertex = polygon.GetVertex (prev); currVertex = polygon.GetVertex (curr); diff --git a/src/modeler/bodyutils.js b/src/modeler/bodyutils.js index 47e17ffe..c50aa30b 100644 --- a/src/modeler/bodyutils.js +++ b/src/modeler/bodyutils.js @@ -132,6 +132,45 @@ JSM.CalculateBodyVertexNormals = function (body) return result; }; +/** +* Function: CalculatePolygonCurveGroups +* Description: Calculates the curve groups for a given polygon. +* Parameters: +* polygon {Polygon} the polygon +* curveAngle {number} the curve angle +* Returns: +* {integer[*]} the curve groups +*/ +JSM.CalculatePolygonCurveGroups = function (polygon, curveAngle) +{ + var curveGroups = []; + var count = polygon.VertexCount (); + + var i, prev; + for (i = 0; i < count; i++) { + curveGroups.push (0); + } + + for (i = 0; i < count; i++) { + prev = curveGroups[polygon.GetPrevVertex (i)]; + if (polygon.GetVertexAngle (i) > curveAngle) { + curveGroups[i] = prev; + } else { + curveGroups[i] = prev + 1; + } + } + + var firstGroup = curveGroups[0]; + var lastGroup = curveGroups[count - 1]; + if (firstGroup === 0 && firstGroup != lastGroup) { + for (i = 0; curveGroups[i] == firstGroup; i++) { + curveGroups[i] = lastGroup; + } + } + + return curveGroups; +}; + /** * Function: MakeBodyInsideOut * Description: Reverses all polygons orientation in the body. diff --git a/src/modeler/generator.js b/src/modeler/generator.js index 49a05f4c..c45cc222 100644 --- a/src/modeler/generator.js +++ b/src/modeler/generator.js @@ -784,28 +784,41 @@ JSM.GenerateCone = function (topRadius, bottomRadius, height, segmentation, with * direction {Vector} the vector of the offset * height {number} the height of the prism * withTopAndBottom {boolean} generate top and bottom polygons +* curveAngle {number} if not null, defines the curve angle of the prism * Returns: * {Body} the result */ -JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom) +JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom, curveAngle) { var result = new JSM.Body (); - var count = basePolygon.length; + + var polygon = new JSM.Polygon (); + polygon.FromArray (basePolygon); + var count = polygon.VertexCount (); + + var curveGroups = null; + if (curveAngle !== undefined && curveAngle !== null) { + curveGroups = JSM.CalculatePolygonCurveGroups (polygon, curveAngle); + } var i; for (i = 0; i < count; i++) { - result.AddVertex (new JSM.BodyVertex (basePolygon[i])); - result.AddVertex (new JSM.BodyVertex (basePolygon[i].Clone ().Offset (direction, height))); + result.AddVertex (new JSM.BodyVertex (polygon.GetVertex (i).Clone ())); + result.AddVertex (new JSM.BodyVertex (polygon.GetVertex (i).Clone ().Clone ().Offset (direction, height))); } - var current, next; + var current, next, bodyPolygon; for (i = 0; i < count; i++) { current = 2 * i; next = current + 2; if (i === count - 1) { next = 0; } - result.AddPolygon (new JSM.BodyPolygon ([current, next, next + 1, current + 1])); + bodyPolygon = new JSM.BodyPolygon ([current, next, next + 1, current + 1]); + if (curveGroups !== null) { + bodyPolygon.SetCurveGroup (curveGroups[i]); + } + result.AddPolygon (bodyPolygon); } if (withTopAndBottom) { @@ -819,8 +832,9 @@ JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom) result.AddPolygon (bottomPolygon); } - var firstDirection = JSM.CoordSub (basePolygon[1], basePolygon[0]).Normalize (); - var origo = new JSM.Coord (basePolygon[0].x, basePolygon[0].y, basePolygon[0].z); + var origo = polygon.GetVertex (0).Clone (); + var firtVertex = polygon.GetVertex (1).Clone (); + var firstDirection = JSM.CoordSub (firtVertex, origo).Normalize (); var e3 = direction.Clone ().Normalize (); var e2 = JSM.VectorCross (e3, firstDirection); var e1 = JSM.VectorCross (e2, e3); @@ -829,37 +843,6 @@ JSM.GeneratePrism = function (basePolygon, direction, height, withTopAndBottom) return result; }; -/** -* Function: GenerateCurvedPrism -* Description: Same as GeneratePrism, but curve groups can be defined for all sides. -* Parameters: -* basePolygon {Coord[*]} the base polygon -* curveGroups {integer[*]} the curve groups -* direction {Vector} the vector of the offset -* height {number} the height of the prism -* withTopAndBottom {boolean} generate top and bottom polygons -* Returns: -* {Body} the result -*/ -JSM.GenerateCurvedPrism = function (basePolygon, curveGroups, direction, height, withTopAndBottom) -{ - var result = JSM.GeneratePrism (basePolygon, direction, height, withTopAndBottom); - if (curveGroups === undefined || curveGroups === null) { - return result; - } - - if (basePolygon.length != curveGroups.length) { - return result; - } - - var i, current; - for (i = 0; i < basePolygon.length; i++) { - current = curveGroups[i]; - result.GetPolygon (i).SetCurveGroup (current); - } - return result; -}; - /** * Function: GeneratePrismWithHole * Description: @@ -871,10 +854,11 @@ JSM.GenerateCurvedPrism = function (basePolygon, curveGroups, direction, height, * direction {Vector} the vector of the offset * height {number} the height of the prism * withTopAndBottom {boolean} generate top and bottom polygons +* curveAngle {number} if not null, defines the curve angle of the prism * Returns: * {Body} the result */ -JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAndBottom) +JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAndBottom, curveAngle) { function AddVertices (contourPolygon, direction, height, result) { @@ -890,12 +874,17 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd } } - function AddContours (contourPolygon, contourOffsets, result) + function AddContours (contourPolygon, contourOffsets, curveAngle, result) { var offset = 0; - var i, j, contour, vertexCount, current, next; + + var i, j, contour, vertexCount, current, next, bodyPolygon, curveGroups; for (i = 0; i < contourPolygon.ContourCount (); i++) { contour = contourPolygon.GetContour (i); + curveGroups = null; + if (curveAngle !== undefined && curveAngle !== null) { + curveGroups = JSM.CalculatePolygonCurveGroups (contour, curveAngle); + } vertexCount = contour.VertexCount (); contourOffsets.push (offset); for (j = 0; j < vertexCount; j++) { @@ -904,7 +893,11 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd if (j == vertexCount - 1) { next = 2 * offset; } - result.AddPolygon (new JSM.BodyPolygon ([current, next, next + 1, current + 1])); + bodyPolygon = new JSM.BodyPolygon ([current, next, next + 1, current + 1]); + if (curveGroups !== null) { + bodyPolygon.SetCurveGroup (curveGroups[j]); + } + result.AddPolygon (bodyPolygon); } offset += vertexCount; } @@ -946,7 +939,7 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd var contourPolygon = new JSM.ContourPolygon (); contourPolygon.FromArray (basePolygon); AddVertices (contourPolygon, direction, height, result); - AddContours (contourPolygon, contourOffsets, result); + AddContours (contourPolygon, contourOffsets, curveAngle, result); if (withTopAndBottom) { AddTopBottomPolygons (contourPolygon, contourOffsets); @@ -962,41 +955,6 @@ JSM.GeneratePrismWithHole = function (basePolygon, direction, height, withTopAnd return result; }; -/** -* Function: GenerateCurvedPrismWithHole -* Description: Same as GeneratePrismWithHole, but curve groups can be defined for all sides. -* Parameters: -* basePolygon {Coord[*]} the base polygon which can contain null values -* direction {Vector} the vector of the offset -* height {number} the height of the prism -* withTopAndBottom {boolean} generate top and bottom polygons -* Returns: -* {Body} the result -*/ -JSM.GenerateCurvedPrismWithHole = function (basePolygon, curveGroups, direction, height, withTopAndBottom) -{ - var result = JSM.GeneratePrismWithHole (basePolygon, direction, height, withTopAndBottom); - if (curveGroups === undefined || curveGroups === null) { - return result; - } - - if (basePolygon.length != curveGroups.length) { - return result; - } - - var index = 0; - var i, current; - for (i = 0; i < basePolygon.length; i++) { - current = curveGroups[i]; - if (current === null) { - continue; - } - result.GetPolygon (index).SetCurveGroup (current); - index++; - } - return result; -}; - /** * Function: GeneratePrismShell * Description: Generates a prism with the given width of sides. diff --git a/test/unittest/tests/modeler.js b/test/unittest/tests/modeler.js index 6e813b4f..6853a403 100644 --- a/test/unittest/tests/modeler.js +++ b/test/unittest/tests/modeler.js @@ -845,7 +845,7 @@ generatorSuite.AddTest ('GeneratePrismTest', function (test) ]; var direction = new JSM.Vector (0.0, 0.0, 1.0); - var prism = JSM.GeneratePrism (basePoints, direction, 1.0, true); + var prism = JSM.GeneratePrism (basePoints, direction, 1.0, true, null); test.Assert (prism.VertexCount () == 10 && prism.PolygonCount () == 7); test.Assert (JSM.CheckSolidBody (prism)); test.Assert (prism.GetVertex (0).position.IsEqual (new JSM.Vector (0.0, 0.0, 0.0))); @@ -873,7 +873,7 @@ generatorSuite.AddTest ('GeneratePrismTest', function (test) ]; var direction2 = new JSM.Vector (0.0, 0.0, 1.0); - var prism2 = JSM.GeneratePrism (basePoints2, direction2, 1.0, true); + var prism2 = JSM.GeneratePrism (basePoints2, direction2, 1.0, true, null); test.Assert (JSM.CheckSolidBody (prism2)); var vertexNormals = JSM.CalculateBodyVertexNormals (prism2); diff --git a/test/unittest/tests/polygon.js b/test/unittest/tests/polygon.js index 44d398fa..8c32c08d 100644 --- a/test/unittest/tests/polygon.js +++ b/test/unittest/tests/polygon.js @@ -400,6 +400,29 @@ simpleSuite.AddTest ('ComplexityTest', function (test) test.AssertEqual (polygon6.GetComplexity (), JSM.Complexity.Convex); }); +simpleSuite.AddTest ('VertexAngleTest', function (test) +{ + var polygon = new JSM.Polygon (); + polygon.AddVertex (0, 0, 0); + polygon.AddVertex (2, 0, 0); + polygon.AddVertex (2, 2, 0); + polygon.AddVertex (1, 2, 0); + polygon.AddVertex (1, 1, 0); + polygon.AddVertex (0, 1, 0); + var i; + for (i = 0; i < polygon.VertexCount (); i++) { + test.AssertEqualNum (polygon.GetVertexAngle (i), Math.PI / 2.0, JSM.Eps); + } + + var circle = JSM.GenerateCirclePoints (1, 20, new JSM.Coord (0, 0, 0)); + polygon.FromArray (circle); + test.AssertEqual (polygon.VertexCount (), 20); + var angleSum = (20 - 2) * Math.PI; + for (i = 0; i < polygon.VertexCount (); i++) { + test.AssertEqualNum (polygon.GetVertexAngle (i), angleSum / 20.0, JSM.Eps); + } +}); + simpleSuite.AddTest ('FromToArrayTest', function (test) { var polygon = new JSM.Polygon2D (); diff --git a/test/unittest/tests/visual.js b/test/unittest/tests/visual.js index 19e13175..3bcc6606 100644 --- a/test/unittest/tests/visual.js +++ b/test/unittest/tests/visual.js @@ -88,7 +88,7 @@ visualSuite.AddTest ('DrawingTest', function (test) ]; var direction = new JSM.Vector (0.0, 0.0, 1.0); - var body = JSM.GeneratePrism (basePoints, direction, 1.0, true); + var body = JSM.GeneratePrism (basePoints, direction, 1.0, true, null); test.Assert (DrawAndCheck (body, 'Wireframe', 'drawing_wireframe.svg')); test.Assert (DrawAndCheck (body, 'HiddenLinePainter', 'drawing_hiddenlinepainter.svg')); @@ -121,7 +121,7 @@ visualSuite.AddTest ('CatmullClarkSubdivisionTest', function (test) ]; var direction = new JSM.Vector (0.0, 0.0, 1.0); - var body = JSM.GeneratePrism (basePoints, direction, 1.0, true); + var body = JSM.GeneratePrism (basePoints, direction, 1.0, true, null); test.Assert (DrawAndCheck (body, 'Wireframe', 'subdivision_00.svg')); body = JSM.CatmullClarkSubdivisionOneIteration (body); test.Assert (DrawAndCheck (body, 'Wireframe', 'subdivision_01.svg')); @@ -207,7 +207,7 @@ visualSuite.AddTest ('GeneratorFunctionTest', function (test) test.Assert (Test (JSM.GenerateLineShell (polyLine, new JSM.Vector (0, 0, 1), 1, 0.1, true, true), 'lineshell')); test.Assert (Test (JSM.GeneratePie (0.5, 0.2, Math.PI * 3 / 2, 10, true, false), 'pie')); test.Assert (Test (JSM.GeneratePolyTorus (polyLine2D, 0.5, 10, false), 'polytorus')); - test.Assert (Test (JSM.GeneratePrism (polyLine, new JSM.Vector (0, 0, 1), 1, true), 'prism')); + test.Assert (Test (JSM.GeneratePrism (polyLine, new JSM.Vector (0, 0, 1), 1, true, null), 'prism')); test.Assert (Test (JSM.GeneratePrismShell (polyLine, new JSM.Vector (0, 0, 1), 1, 0.1, true), 'prismshell')); test.Assert (Test (JSM.GenerateRectangle (1, 1), 'rectangle')); test.Assert (Test (JSM.GenerateRevolved (polyLine2, new JSM.Sector (new JSM.Coord (0, 0, 0), new JSM.Coord (0, 1, 0)), Math.PI * 3 / 2, 10, true, 'None'), 'revolved1')); diff --git a/test/viewertest/include/teststeps.js b/test/viewertest/include/teststeps.js index 121efd5e..691a2b2d 100644 --- a/test/viewertest/include/teststeps.js +++ b/test/viewertest/include/teststeps.js @@ -203,8 +203,8 @@ function TestStep (viewer, mode, step, info) ]; var direction = new JSM.Coord (0.0, 0.0, 1.0); - var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true); - var body2 = JSM.GeneratePrism (basePolygon, direction, 1.2, false); + var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null); + var body2 = JSM.GeneratePrism (basePolygon, direction, 1.2, false, null); OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0); model.AddBody (body1); @@ -622,22 +622,22 @@ function TestStep (viewer, mode, step, info) ]; var direction = new JSM.Coord (0.0, 0.0, 1.0); - var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true); + var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null); body1.GetPolygon (3).SetMaterialIndex (0); body1.GetPolygon (5).SetMaterialIndex (1); body1 = JSM.CatmullClarkSubdivision (body1, 1); - var body2 = JSM.GeneratePrism (basePolygon, direction, 1.0, true); + var body2 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null); body2.GetPolygon (3).SetMaterialIndex (0); body2.GetPolygon (5).SetMaterialIndex (1); body2 = JSM.CatmullClarkSubdivision (body2, 2); - var body3 = JSM.GeneratePrism (basePolygon, direction, 1.0, true); + var body3 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null); body3.GetPolygon (3).SetMaterialIndex (0); body3.GetPolygon (5).SetMaterialIndex (1); body3 = JSM.CatmullClarkSubdivision (body3, 3); - var body4 = JSM.GeneratePrism (basePolygon, direction, 1.0, true); + var body4 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null); body4.GetPolygon (3).SetMaterialIndex (0); body4.GetPolygon (5).SetMaterialIndex (1); body4 = JSM.CatmullClarkSubdivision (body4, 4); @@ -892,19 +892,8 @@ function TestStep (viewer, mode, step, info) new JSM.Coord (-0.1, 0.4, 0) ]; - var curveGroups = [ - -1, - 0, - 0, - 0, - -1, - 1, - 1, - 1 - ]; - var direction = new JSM.Vector (0.0, 0.0, 1.0); - var body1 = JSM.GenerateCurvedPrism (basePoints, curveGroups, direction, 0.3, true); + var body1 = JSM.GeneratePrism (basePoints, direction, 0.3, true, 160 * JSM.DegRad); var basePoints = [ new JSM.Coord (0, 0, 0), @@ -926,28 +915,8 @@ function TestStep (viewer, mode, step, info) new JSM.Coord (0.8, 0.2, 0) ]; - var curveGroups = [ - -1, - 0, - 0, - 0, - -1, - 1, - 1, - 1, - null, - 0, - 0, - 0, - -1, - 0, - 0, - 0, - -1 - ]; - var direction = new JSM.Vector (0.0, 0.0, 1.0); - var body2 = JSM.GenerateCurvedPrismWithHole (basePoints, curveGroups, direction, 0.3, true); + var body2 = JSM.GeneratePrismWithHole (basePoints, direction, 0.3, true, 150 * JSM.DegRad); OffsetTwoBodies (body1, body2, 0.8, 0.0, 0.0); From 68fa290d8ab67e238d2a3e64207b948e34d57d1b Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 6 Aug 2015 20:12:25 +0200 Subject: [PATCH 27/27] Change controls order in dialog. --- documentation/demo/include/shapegenerators.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/demo/include/shapegenerators.js b/documentation/demo/include/shapegenerators.js index 860668a5..a6c84309 100644 --- a/documentation/demo/include/shapegenerators.js +++ b/documentation/demo/include/shapegenerators.js @@ -387,8 +387,8 @@ JSM.PrismGenerator = function () ]], 'left'), direction : new JSM.Parameter ('direction', 'coord', new JSM.Coord (0.0, 0.0, 1.0), 'right'), height : new JSM.Parameter ('height', 'number', 1.0, 'right'), - withTopAndBottom : new JSM.Parameter ('top and bottom', 'check', true, 'right'), - curveAngle : new JSM.Parameter ('curve angle', 'number', 150, 'right') + curveAngle : new JSM.Parameter ('curve angle', 'number', 150, 'right'), + withTopAndBottom : new JSM.Parameter ('top and bottom', 'check', true, 'right') }; };