Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
e5e0945e
Commit
e5e0945e
authored
May 07, 2017
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing svg...
parent
ad1ab187
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
24 deletions
+29
-24
index.html
index.html
+1
-0
js/pattern.js
js/pattern.js
+28
-24
No files found.
index.html
View file @
e5e0945e
...
...
@@ -413,6 +413,7 @@
<a
tabindex=
"-1"
>
Origami
<span
class=
"pull-right fui-arrow-right"
></span></a>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"#"
class=
"demo"
data-url=
"Origami/randlettflappingbird.svg"
>
Randlett Flapping Bird
</a></li>
<li><a
href=
"#"
class=
"demo"
data-url=
"Origami/crane.svg"
>
Traditional Crane
</a></li>
<li><a
href=
"#"
class=
"demo"
data-url=
"Origami/singlesquaretwist.svg"
>
Square Twist (single)
</a></li>
<li><a
href=
"#"
class=
"demo"
data-url=
"Origami/squaretwistManyAngles.svg"
>
Square Twist (many angles)
</a></li>
<li><a
href=
"#"
class=
"demo"
data-url=
"Origami/hypar.svg"
>
Hypar (not fully working yet)
</a></li>
...
...
js/pattern.js
View file @
e5e0945e
...
...
@@ -204,6 +204,11 @@ function initPattern(globals){
triangulationsRaw
=
_triangulationsRaw
;
mergeVertices
();
console
.
log
(
vertices
);
console
.
log
(
vertices
.
length
);
console
.
log
(
mountains
);
console
.
log
(
valleys
);
console
.
log
(
outlines
);
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulationsRaw
);
polygons
=
findPolygons
(
allEdges
);
...
...
@@ -264,13 +269,14 @@ function initPattern(globals){
function
mergeVertices
(){
vertices
=
verticesRaw
.
slice
();
console
.
log
(
vertices
.
length
);
var
tolSq
=
globals
.
vertTol
*
globals
.
vertTol
;
var
combined
=
[];
var
mergedVertices
=
[];
var
_weededVertices
=
vertices
.
slice
();
var
goodVertices
=
[];
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulations
);
var
allEdges
=
outlines
Raw
.
concat
(
mountains
Raw
).
concat
(
valleys
Raw
).
concat
(
cuts
Raw
).
concat
(
triangulations
Raw
);
var
js
=
[];
for
(
var
i
=
0
;
i
<
vertices
.
length
;
i
++
){
js
.
push
(
i
);
...
...
@@ -297,17 +303,17 @@ function initPattern(globals){
}
i
-=
numCombined
;
}
else
{
//
var vertexEdges = [];
//
for (k=0;k<allEdges.length;k++){
//
if (allEdges[k][0] ==
i
|| allEdges[k][1] ==
i
) vertexEdges.push(k);
//
}
//
if (vertexEdges.length>
2
){
//
goodVertices.push([vertices[i],
i
].concat(vertexEdges));
//
_weededVertices.splice(i, 1);
//
}
var
vertexEdges
=
[];
for
(
k
=
0
;
k
<
allEdges
.
length
;
k
++
){
if
(
allEdges
[
k
][
0
]
==
js
[
i
]
||
allEdges
[
k
][
1
]
==
js
[
i
]
)
vertexEdges
.
push
(
k
);
}
if
(
vertexEdges
.
length
>
1
){
goodVertices
.
push
([
vertices
[
i
],
js
[
i
]
].
concat
(
vertexEdges
));
_weededVertices
.
splice
(
i
,
1
);
}
}
}
outlines
=
outlinesRaw
.
slice
();
mountains
=
mountainsRaw
.
slice
();
valleys
=
valleysRaw
.
slice
();
...
...
@@ -315,7 +321,6 @@ function initPattern(globals){
triangulations
=
triangulationsRaw
.
slice
();
var
strays
=
findStrayVertices
();
combined
.
concat
(
strays
);
for
(
var
i
=
0
;
i
<
strays
.
length
;
i
++
){
for
(
var
j
=
0
;
j
<
_weededVertices
.
length
;
j
++
){
if
(
vertices
[
strays
[
i
]].
equals
(
_weededVertices
[
j
])){
...
...
@@ -335,18 +340,17 @@ function initPattern(globals){
removeCombinedFromSet
(
combined
,
cuts
);
removeCombinedFromSet
(
combined
,
triangulations
);
// for (var i=0;i<goodVertices.length;i++){
// var newIndex = mergedVertices.length;
// var oldIndex = goodVertices[i][1];
// mergedVertices.push(goodVertices[i][0]);
// for (var j=0;j<goodVertices[i].length-2;j++){
// var edge = allEdges[goodVertices[i][j+2]];
// console.log(goodVertices[i][j+2]);
// edge[edge.indexOf(oldIndex)] = newIndex;
// }
// }
vertices
=
mergedVertices
.
concat
(
goodVertices
);
for
(
var
i
=
0
;
i
<
goodVertices
.
length
;
i
++
){
var
newIndex
=
mergedVertices
.
length
;
var
oldIndex
=
goodVertices
[
i
][
1
];
mergedVertices
.
push
(
goodVertices
[
i
][
0
]);
for
(
var
j
=
0
;
j
<
goodVertices
[
i
].
length
-
2
;
j
++
){
var
edge
=
allEdges
[
goodVertices
[
i
][
j
+
2
]];
edge
[
edge
.
indexOf
(
oldIndex
)]
=
newIndex
;
}
}
vertices
=
mergedVertices
;
}
function
findStrayVertices
(){
...
...
@@ -633,7 +637,7 @@ function initPattern(globals){
for
(
var
i
=
0
;
i
<
combined
.
length
;
i
++
){
if
(
combined
[
i
].
indexOf
(
set
[
j
][
0
])
>=
0
)
{
set
[
j
][
0
]
=
i
;
break
;
break
;
//ensures that we replace only once
}
}
for
(
var
i
=
0
;
i
<
combined
.
length
;
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment