Commit 1dd6e504 authored by amandaghassaei's avatar amandaghassaei
Browse files

eod

parent c5eae2cf
...@@ -32,7 +32,7 @@ function initPattern(globals){ ...@@ -32,7 +32,7 @@ function initPattern(globals){
}); });
} }
loadSVG("/assets/Tessellations/miura-ori-dashed.svg", function(svg){ loadSVG("/assets/Tessellations/miura-ori.svg", function(svg){
var _$svg = $(svg); var _$svg = $(svg);
//format all lines //format all lines
...@@ -150,7 +150,6 @@ function initPattern(globals){ ...@@ -150,7 +150,6 @@ function initPattern(globals){
cutsRaw = _cutsRaw; cutsRaw = _cutsRaw;
mergeVertices(); mergeVertices();
drawPattern();
} }
function mergeVertices(){ function mergeVertices(){
...@@ -160,23 +159,27 @@ function initPattern(globals){ ...@@ -160,23 +159,27 @@ function initPattern(globals){
var tolSq = globals.vertTol*globals.vertTol; var tolSq = globals.vertTol*globals.vertTol;
var combined = []; var combined = [];
var mergedVertices = []; var mergedVertices = [];
var diff = 1; var weededVertices = vertices.slice();
var diff = 0;
for (var i=vertices.length-1;i>=0;i--){ for (var i=vertices.length-1;i>=0;i--){
var _combined = []; var _combined = [];
for (var j=i-diff;j>=0;j--){ for (var j=i-1+diff;j>=0;j--){
if ((vertices[i].clone().sub(vertices[j])).lengthSq()<tolSq){ if ((weededVertices[i].clone().sub(vertices[j])).lengthSq()<tolSq){
_combined.push(j); _combined.push(j);
} }
} }
var numCombined = _combined.length; var numCombined = _combined.length;
if (numCombined>0){ if (numCombined>0){
_combined.push(i); _combined.push(i+diff);
mergedVertices.push(vertices[i]); mergedVertices.push(weededVertices[i]);
combined.push(_combined); combined.push(_combined);
for (var k=0;k<numCombined-1;k++){ console.log(_combined);
vertices.splice(_combined[k], 1); weededVertices.splice(i, 1);
for (var k=0;k<numCombined;k++){
weededVertices.splice(_combined[k], 1);
} }
diff -= numCombined diff += numCombined;
i -= numCombined;
} }
} }
console.log(combined.length); console.log(combined.length);
...@@ -191,7 +194,13 @@ function initPattern(globals){ ...@@ -191,7 +194,13 @@ function initPattern(globals){
removeCombinedFromSet(combined, valleys); removeCombinedFromSet(combined, valleys);
removeCombinedFromSet(combined, cuts); removeCombinedFromSet(combined, cuts);
console.log(outlines);
vertices = mergedVertices; vertices = mergedVertices;
//find cycles
//triangulate
drawPattern();
} }
function removeCombinedFromSet(combined, set){ function removeCombinedFromSet(combined, set){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment