Commit 04b418ba authored by amandaghassaei's avatar amandaghassaei
Browse files

solver is working better

parent a1ccbd7b
......@@ -327,37 +327,6 @@
<div id="threeContainer"></div>
<canvas id="gpuMathCanvas"></canvas>
<div id="controlsLeft" class="flipped">
<!--<div>-->
<!--3D View:-->
<!--<div class="indent">-->
<!--<label class="checkbox" for="dynamic">-->
<!--<input id="dynamic" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>-->
<!--Dynamic Simulation-->
<!--</label>-->
<!--<label class="checkbox" for="static">-->
<!--<input id="static" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>-->
<!--Static Simulation-->
<!--</label>-->
<!--<label class="checkbox" for="schematic">-->
<!--<input id="schematic" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>-->
<!--Crease Pattern-->
<!--</label>-->
<!--</div>-->
<!--</div>-->
<br/><br/>
<div class="dynamicSim">
<div class="paddingBottom">Dynamic Sim Settings:</div>
<div class="indent">
<div class="sliderContainer">
<span class="label-slider">Damping : </span><div id="damping" class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div><br/>
</div>
<a href="#" id="resetDynamicSim" class="paddingBottom btn btn-lg btn-default">Replay Dynamic Simulation</a>
<div>&Delta; t = <span id="deltaT"></span> seconds</div>
</div>
</div>
<div class="extraSpace"></div>
</div>
<div id="controls">
<div class="sliderInput" id="creasePercent">
<span class="label-slider">Crease Percent : </span><div class="flat-slider ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content"></div>
......
......@@ -42,9 +42,9 @@ Crease.prototype.getTargetTheta = function(){
};
Crease.prototype.getK = function(){
var length = this.getLength();
if (this.type == 0) return globals.panelStiffness*length;
return globals.creaseStiffness*length;
// var length = this.getLength(); //todo *length?
if (this.type == 0) return globals.panelStiffness;
return globals.creaseStiffness;
};
Crease.prototype.getD = function(){
......
......@@ -25,7 +25,7 @@ function initGlobals(){
//sim settings
creasePercent: 0,
axialStiffness: 100,
creaseStiffness: 30,
creaseStiffness: 10,
panelStiffness: 1,
//dynamic sim settings
......
......@@ -56,7 +56,7 @@ function initModel(globals){
}
var _creases = [];
for (var i=0;i<1;i++) {//allCreaseParams.length
for (var i=0;i<allCreaseParams.length;i++) {//allCreaseParams.length
var creaseParams = allCreaseParams[i];//face1Ind, vertInd, face2Ind, ver2Ind, edgeInd, angle
_edges[creaseParams[4]].highlight();
_creases.push(new Crease(_edges[creaseParams[4]], creaseParams[0], creaseParams[2], creaseParams[5], 1, _nodes[creaseParams[1]], _nodes[creaseParams[3]], _creases.length));
......
......@@ -210,6 +210,36 @@ function initPattern(globals){
}
}
}
for (var i=outlines.length+mountains.length+valleys.length+cuts.length;i<allEdges.length;i++){
var v1 = allEdges[i][0];
var v2 = allEdges[i][1];
var creaseParams = [];
for (var j=0;j<faces.length;j++){
var face = faces[j];
var faceVerts = [face.a, face.b, face.c];
var v1Index = faceVerts.indexOf(v1);
if (v1Index>=0){
var v2Index = faceVerts.indexOf(v2);
if (v2Index>=0){
creaseParams.push(j);
if (v2Index>v1Index) {
faceVerts.splice(v2Index, 1);
faceVerts.splice(v1Index, 1);
} else {
faceVerts.splice(v1Index, 1);
faceVerts.splice(v2Index, 1);
}
creaseParams.push(faceVerts[0]);
if (creaseParams.length == 4) {
creaseParams.push(i);
creaseParams.push(0);//zero target angle
allCreaseParams.push(creaseParams);
break;
}
}
}
}
}
return allCreaseParams;
}
......
......@@ -177,7 +177,7 @@ function initStaticSolver(){
var length = edge.getOriginalLength();
var diff = edgeVector0.length() - length;
var rxnForceScale = globals.axialStiffness*diff/length;
var rxnForceScale = globals.axialStiffness*diff;
edgeVector0.normalize();
if (!_nodes[0].fixed) {
......@@ -222,10 +222,10 @@ function initStaticSolver(){
if (!crease.node1.fixed){
var i = indicesMapping.indexOf(crease.node1.getIndex());
var dist = crease.getLengthToNode1();
C[j+numFreeEdges][3*i] = -normal1.x/dist;//todo not sure about sign
C[j+numFreeEdges][3*i+1] = -normal1.y/dist;
C[j+numFreeEdges][3*i+2] = -normal1.z/dist;
rxnForceScale = crease.getK()*diff/dist;
C[j+numFreeEdges][3*i] = -normal1.x;//todo not sure about sign
C[j+numFreeEdges][3*i+1] = -normal1.y;
C[j+numFreeEdges][3*i+2] = -normal1.z;
rxnForceScale = crease.getK()*diff;
F_rxn[3*i] += normal1.x*rxnForceScale;
F_rxn[3*i+1] += normal1.y*rxnForceScale;
F_rxn[3*i+2] += normal1.z*rxnForceScale;
......@@ -234,10 +234,10 @@ function initStaticSolver(){
var i = indicesMapping.indexOf(crease.node2.getIndex());
// console.log(normal);
var dist = crease.getLengthToNode2();
C[j+numFreeEdges][3*i] = -normal2.x/dist;
C[j+numFreeEdges][3*i+1] = -normal2.y/dist;
C[j+numFreeEdges][3*i+2] = -normal2.z/dist;
rxnForceScale = crease.getK()*diff/dist;
C[j+numFreeEdges][3*i] = -normal2.x;///dist;
C[j+numFreeEdges][3*i+1] = -normal2.y;///dist;
C[j+numFreeEdges][3*i+2] = -normal2.z;///dist;
rxnForceScale = crease.getK()*diff;///dist;
F_rxn[3*i] += normal2.x*rxnForceScale;
F_rxn[3*i+1] += normal2.y*rxnForceScale;
F_rxn[3*i+2] += normal2.z*rxnForceScale;
......@@ -248,8 +248,7 @@ function initStaticSolver(){
function calcQ() {
var axialStiffness = globals.axialStiffness;
for (var i = 0; i < numFreeEdges; i++) {
var edge = edges[freeEdgesMapping[i]];
Q[i][i] = axialStiffness/edge.getOriginalLength();
Q[i][i] = axialStiffness;
}
for (var i = 0; i < numFreeCreases; i++) {
var crease = creases[freeCreasesMapping[i]];
......
Markdown is supported
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