Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
ef8e07ef
Commit
ef8e07ef
authored
Jun 01, 2017
by
amandaghassaei
Browse files
tirangular stiffness working
parent
af87b75c
Changes
1
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
ef8e07ef
...
...
@@ -288,33 +288,36 @@
vec3
ac
=
c
-
a
;
vec3
bc
=
c
-
b
;
float
lengthABsq
=
length
(
ab
);
float
lengthACsq
=
length
(
ac
);
float
lengthBCsq
=
length
(
bc
);
lengthABsq
*=
lengthABsq
;
lengthACsq
*=
lengthACsq
;
lengthBCsq
*=
lengthBCsq
;
vec3
angles
=
vec3
(
acos
(
dot
(
ab
,
ac
)),
acos
(
-
1.0
*
dot
(
ab
,
bc
)),
acos
(
dot
(
ac
,
bc
)));
float
lengthAB
=
length
(
ab
);
float
lengthAC
=
length
(
ac
);
float
lengthBC
=
length
(
bc
);
ab
/=
lengthAB
;
ac
/=
lengthAC
;
bc
/=
lengthBC
;
vec3
angles
=
vec3
(
acos
(
dot
(
ab
,
ac
)),
acos
(
-
1.0
*
dot
(
ab
,
bc
)),
acos
(
dot
(
ac
,
bc
)));
vec3
anglesDiff
=
nominalAngles
-
angles
;
vec3
normal
=
getFromArray
(
faceMeta
[
0
],
u_textureDimFaces
,
u_normals
).
xyz
;
//calc forces
float
triangleStiffness
=
0.1
;
anglesDiff
*=
triangleStiffness
;
anglesDiff
*=
-
triangleStiffness
;
if
(
faceIndex
==
0
){
//a
force
-=
anglesDiff
[
0
]
*
(
cross
(
ac
,
normal
)
/
lengthAC
sq
-
cross
(
ab
,
normal
)
/
lengthAB
sq
);
force
+=
anglesDiff
[
1
]
*
cross
(
-
ab
,
normal
)
/
lengthAB
sq
;
force
-=
anglesDiff
[
2
]
*
cross
(
-
ac
,
normal
)
/
lengthAC
sq
;
force
-=
anglesDiff
[
0
]
*
(
cross
(
ac
,
normal
)
/
lengthAC
-
cross
(
ab
,
normal
)
/
lengthAB
);
force
+=
anglesDiff
[
1
]
*
cross
(
-
ab
,
normal
)
/
lengthAB
;
force
-=
anglesDiff
[
2
]
*
cross
(
-
ac
,
normal
)
/
lengthAC
;
}
else
if
(
faceIndex
==
1
){
force
-=
anglesDiff
[
0
]
*
cross
(
ab
,
normal
)
/
lengthAB
sq
;
force
-=
anglesDiff
[
1
]
*
(
cross
(
-
ab
,
normal
)
/
lengthAB
sq
-
cross
(
bc
,
normal
)
/
lengthBC
sq
);
force
+=
anglesDiff
[
2
]
*
cross
(
-
bc
,
normal
)
/
lengthBC
sq
;
force
-=
anglesDiff
[
0
]
*
cross
(
ab
,
normal
)
/
lengthAB
;
force
-=
anglesDiff
[
1
]
*
(
cross
(
-
ab
,
normal
)
/
lengthAB
-
cross
(
bc
,
normal
)
/
lengthBC
);
force
+=
anglesDiff
[
2
]
*
cross
(
-
bc
,
normal
)
/
lengthBC
;
}
else
if
(
faceIndex
==
2
){
force
+=
anglesDiff
[
0
]
*
cross
(
ac
,
normal
)
/
lengthAC
sq
;
force
-=
anglesDiff
[
1
]
*
cross
(
bc
,
normal
)
/
lengthBC
sq
;
force
-=
anglesDiff
[
2
]
*
(
cross
(
-
bc
,
normal
)
/
lengthBC
sq
-
cross
(
-
ac
,
normal
)
/
lengthAC
sq
);
force
+=
anglesDiff
[
0
]
*
cross
(
ac
,
normal
)
/
lengthAC
;
force
-=
anglesDiff
[
1
]
*
cross
(
bc
,
normal
)
/
lengthBC
;
force
-=
anglesDiff
[
2
]
*
(
cross
(
-
bc
,
normal
)
/
lengthBC
-
cross
(
-
ac
,
normal
)
/
lengthAC
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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