Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
cd85ae89
Commit
cd85ae89
authored
May 05, 2017
by
amandaghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import fold angle in FOLD
parent
ba1a6fea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
js/controls.js
js/controls.js
+23
-4
No files found.
js/controls.js
View file @
cd85ae89
...
...
@@ -219,6 +219,7 @@ function initControls(globals){
faceEdges
.
push
(
thisFaceEdge
);
face
.
push
(
face
[
0
]);
});
//todo merge this with other code
var
faces
=
globals
.
pattern
.
triangulatePolys
([
json
.
faces_vertices
,
faceEdges
],
json
.
edges_vertices
,
json
.
vertices_coords
,
true
);
var
allCreaseParams
=
[];
for
(
var
i
=
0
;
i
<
json
.
edges_vertices
.
length
;
i
++
){
...
...
@@ -250,16 +251,34 @@ function initControls(globals){
creaseParams
.
push
(
i
);
var
shouldSkip
=
false
;
var
foldSign
=
1
;
switch
(
json
.
edges_assignment
[
i
]){
case
"
B
"
:
//outline
shouldSkip
=
true
;
break
;
case
"
M
"
:
creaseParams
.
push
(
Math
.
PI
);
break
;
case
"
V
"
:
creaseParams
.
push
(
-
Math
.
PI
);
foldSign
=
-
1
;
case
"
M
"
:
if
(
json
.
edges_foldAngles
&&
json
.
edges_foldAngles
[
i
]){
creaseParams
.
push
(
foldSign
*
json
.
edges_foldAngles
[
i
]);
break
;
}
if
(
globals
.
foldUseAngles
){
var
face1
=
faces
[
creaseParams
[
0
]];
var
vec1
=
json
.
vertices_coords
[
face1
[
1
]].
clone
().
sub
(
json
.
vertices_coords
[
face1
[
0
]]);
var
vec2
=
json
.
vertices_coords
[
face1
[
2
]].
clone
().
sub
(
json
.
vertices_coords
[
face1
[
0
]]);
var
normal1
=
(
vec2
.
cross
(
vec1
)).
normalize
();
var
face2
=
faces
[
creaseParams
[
2
]];
vec1
=
json
.
vertices_coords
[
face2
[
1
]].
clone
().
sub
(
json
.
vertices_coords
[
face2
[
0
]]);
vec2
=
json
.
vertices_coords
[
face2
[
2
]].
clone
().
sub
(
json
.
vertices_coords
[
face2
[
0
]]);
var
normal2
=
(
vec2
.
cross
(
vec1
)).
normalize
();
var
x
=
normal1
.
dot
(
normal2
);
var
y
=
normal1
.
cross
((
json
.
vertices_coords
[
v2
].
clone
().
sub
(
json
.
vertices_coords
[
v1
])).
normalize
()).
dot
(
normal2
);
creaseParams
.
push
(
Math
.
atan2
(
y
,
x
));
break
;
}
creaseParams
.
push
(
foldSign
*
Math
.
PI
);
break
;
default
:
creaseParams
.
push
(
0
);
...
...
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