Commit c031e835 authored by amandaghassaei's avatar amandaghassaei

mechanical sim is relatively happy

parent ac2e1171
......@@ -31,10 +31,10 @@ define([], function(){
properties:{
conductive: false,
density: 3500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
bending1DOF: {
......@@ -46,10 +46,10 @@ define([], function(){
properties:{
conductive: false,
density: 3500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:30},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:30},
torsionK:{x:150,y:150,z:150}
}
},
bending2DOF: {
......@@ -61,10 +61,10 @@ define([], function(){
properties:{
conductive: false,
density: 3500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:30,z:30},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:30,z:30},
torsionK:{x:150,y:150,z:150}
}
},
torsion1DOF: {
......@@ -76,10 +76,10 @@ define([], function(){
properties:{
conductive: false,
density: 3500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:30}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:30}
}
},
shear1DOF: {
......@@ -90,10 +90,10 @@ define([], function(){
properties:{
conductive: false,
density: 3500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:10,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:10,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
isoFlex: {
......@@ -103,7 +103,7 @@ define([], function(){
texture: "stripes",
properties:{
conductive: false,
density: 8500,//kg/m^3
density: 3500,//kg/m^3
longitudalK:{x:10,y:10,z:10},
shearK:{xy:10,xz:10,yx:10,yz:10,zx:10,zy:10},
bendingK:{x:10,y:10,z:10},
......@@ -118,10 +118,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
conductiveBend:{
......@@ -132,10 +132,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
conductiveJunction1:{
......@@ -146,10 +146,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
conductiveJunction2:{
......@@ -160,10 +160,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
flexureCond: {
......@@ -205,10 +205,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
flexureCondJunction2:{
......@@ -220,10 +220,10 @@ define([], function(){
properties:{
conductive: true,
density: 8500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
actuatorLinear1DOF: {
......@@ -234,10 +234,10 @@ define([], function(){
properties:{
conductive: false,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
actuatorBending1DOF: {
......@@ -248,10 +248,10 @@ define([], function(){
properties:{
conductive: false,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
actuatorTorsion1DOF: {
......@@ -262,10 +262,10 @@ define([], function(){
properties:{
conductive: false,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
actuatorShear: {
......@@ -276,10 +276,10 @@ define([], function(){
properties:{
conductive: false,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
signal: {
......@@ -290,10 +290,10 @@ define([], function(){
properties:{
conductive: true,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
},
script: {
......@@ -304,10 +304,10 @@ define([], function(){
properties:{
conductive: true,
density: 6500,//kg/m^3
longitudalK:{x:500,y:500,z:500},
shearK:{xy:500,xz:500,yx:500,yz:500,zx:500,zy:500},
bendingK:{x:500,y:500,z:500},
torsionK:{x:500,y:500,z:500}
longitudalK:{x:150,y:150,z:150},
shearK:{xy:150,xz:150,yx:150,yz:150,zx:150,zy:150},
bendingK:{x:150,y:150,z:150},
torsionK:{x:150,y:150,z:150}
}
}
},
......
......@@ -674,39 +674,31 @@ define(['underscore', 'backbone', 'threeModel', 'lattice', 'plist', 'emWire', 'G
//todo this is causing instability
//bending and torsion
//var quaternionDiff = this._multiplyQuaternions(this._invertQuaternion(quaternion), neighborQuaternion);
//var diffEuler = this._eulerFromQuaternion(quaternionDiff);
//for (var _axis=0;_axis<3;_axis++) {
// if (_axis == neighborAxis){
// rForce[_axis] += 0.00001*torsionK[_axis]*(diffEuler[_axis]);// + torsionD[_axis]*(neighborAngVelocity[_axis]-angVelocity[_axis]);
// } else {
// rForce[_axis] += 0.00001*bendingK[_axis]*(diffEuler[_axis]);// + bendingD[_axis]*(neighborAngVelocity[_axis]-angVelocity[_axis]);
// }
//}
//console.log(rotation);
//console.log(neighborRotation);
//console.log(angVelocity);
//console.log(neighborAngVelocity);
//console.log(quaternion);
//console.log(rForce);
//console.log("");
var quaternionDiff = this._multiplyQuaternions(this._invertQuaternion(quaternion), neighborQuaternion);
var diffEuler = this._eulerFromQuaternion(quaternionDiff);
for (var _axis=0;_axis<3;_axis++) {
if (_axis == neighborAxis){
rForce[_axis] += 0.00001*torsionK[_axis]*(diffEuler[_axis]);// + torsionD[_axis]*(neighborAngVelocity[_axis]-angVelocity[_axis]);
} else {
rForce[_axis] += 0.00001*bendingK[_axis]*(diffEuler[_axis]);// + bendingD[_axis]*(neighborAngVelocity[_axis]-angVelocity[_axis]);
}
}
}
////simple collision detection
//var zPosition = this.originalPosition[rgbaIndex+2]+translation[2]*multiplier-groundHeight;
//var collisionK = 1;
//if (zPosition<0) {
// var normalForce = -zPosition*collisionK-velocity[2]*collisionK/10;
// force[2] += normalForce;
// if (friction) {
// var mu = 10;
// if (velocity[0] > 0) force[0] -= mu * normalForce;
// else if (velocity[0] < 0) force[0] += mu * normalForce;
// if (velocity[1] > 0) force[1] -= mu * normalForce;
// else if (velocity[1] < 0) force[1] += mu * normalForce;
// }
//}
//simple collision detection
var zPosition = this.originalPosition[rgbaIndex+2]+translation[2]*multiplier-groundHeight;
var collisionK = 1;
if (zPosition<0) {
var normalForce = -zPosition*collisionK-velocity[2]*collisionK/10;
force[2] += normalForce;
if (friction) {
var mu = 10;
if (velocity[0] > 0) force[0] -= mu * normalForce;
else if (velocity[0] < 0) force[0] += mu * normalForce;
if (velocity[1] > 0) force[1] -= mu * normalForce;
else if (velocity[1] < 0) force[1] += mu * normalForce;
}
}
var acceleration = [force[0]/mass, force[1]/mass, force[2]/mass];
velocity = [velocity[0] + acceleration[0]*dt, velocity[1] + acceleration[1]*dt, velocity[2] + acceleration[2]*dt];
......
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