summaryrefslogtreecommitdiff
path: root/data_structures_correct/BOUNCE.js
diff options
context:
space:
mode:
authorASP12342016-06-23 06:09:00 +0000
committerASP12342016-06-23 06:12:59 +0000
commitfaeb04600e13a5c1c4ca410cf65309d65e269b41 (patch)
tree2a1dcf2321735e2b67eeaf5d7991282274191d60 /data_structures_correct/BOUNCE.js
parent20e581facb1871847e0fa945ccd3020a10e653c9 (diff)
downloadxcos-on-web-faeb04600e13a5c1c4ca410cf65309d65e269b41.tar.gz
xcos-on-web-faeb04600e13a5c1c4ca410cf65309d65e269b41.tar.bz2
xcos-on-web-faeb04600e13a5c1c4ca410cf65309d65e269b41.zip
Implement BOUNCE Block
Diffstat (limited to 'data_structures_correct/BOUNCE.js')
-rw-r--r--data_structures_correct/BOUNCE.js104
1 files changed, 61 insertions, 43 deletions
diff --git a/data_structures_correct/BOUNCE.js b/data_structures_correct/BOUNCE.js
index 427b00a..78ccedc 100644
--- a/data_structures_correct/BOUNCE.js
+++ b/data_structures_correct/BOUNCE.js
@@ -1,50 +1,68 @@
function BOUNCE() {
+ BOUNCE.prototype.define = function BOUNCE() {
+ this.n = 2;
- var n = 2;
+ this.k = 0;
+ this.ipar = [];
- var k = 0;
- var ipar=[];
-
- for(var i=1; i<=n; i++)
- {
- for(var j=i+1; j<=n ;j++)
- {
- ipar[k]=[i];
- k++;
- ipar[k]=[j];
- k++;
+ for (var i = 1; i <= this.n; i++) {
+ for (var j = i + 1; j <= this.n; j++) {
+ this.ipar[this.k] = [i];
+ this.k++;
+ this.ipar[this.k] = [j];
+ this.k++;
+ }
}
+
+ this.walls = [
+ [0],
+ [5],
+ [0],
+ [5]
+ ];
+ this.x1 = [
+ [2],
+ [2.5]
+ ];
+ this.xd = [
+ [0],
+ [0]
+ ];
+ this.y1 = [
+ [3],
+ [5]
+ ];
+ this.yd = [
+ [0],
+ [0]
+ ];
+ this.g = 9.81;
+ this.C = 0;
+ this.rpar1 = ones(this.n, 1);
+ this.rpar2 = this.rpar1;
+ this.state = [...math.transpose(this.x1), ...math.transpose(this.xd), ...math.transpose(this.y1), ...math.transpose(this.yd)];
+
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["bounce_ball"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble();
+ model.out = new ScilabDouble([this.n], [this.n]);
+ model.state = new ScilabDouble(...colon_operator(this.state));
+ model.rpar = new ScilabDouble(...this.rpar1, ...this.rpar2, ...this.walls, [this.g], [this.C]);
+ model.ipar = new ScilabDouble(...this.ipar);
+ model.nzcross = new ScilabDouble([this.n * (this.n - 1) / 2 + 4 * this.n]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([false, true]);
+
+ var exprs = new ScilabString([sci2exp(this.rpar1)], [sci2exp(this.rpar2)], [sci2exp(this.walls)], [sci2exp(this.x1)], [sci2exp(this.xd)], [sci2exp(this.y1)], [sci2exp(this.yd)]);
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCE\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i);
+
+ return new BasicBlock(this.x);
+ }
+
+ BOUNCE.prototype.details = function BOUNCE() {
+
+ return this.x
}
-
- var walls=[[0],[5],[0],[5]];
- var x=[[2],[2.5]];
- var xd=[[0],[0]];
- var y=[[3],[5]];
- var yd=[[0],[0]];
- var g=9.81;
- var C=0;
- var rpar1=ones(n,1);
- var rpar2=rpar1;
- var state=[x,xd,y,yd];
- console.log(math.transpose([[1, 4], [2, 5], [3, 6]]));
- state=math.transpose(state);
-
- var model=scicos_model();
- model.sim=list(new ScilabString(["bounce_ball"]),new ScilabDouble([4]));
- model.in=new ScilabDouble();
- model.out=new ScilabDouble([n],[n]);
- model.state=new ScilabDouble(...state);
- model.rpar=new ScilabDouble(...rpar1,...rpar2,...walls,[g],[C]);
- model.ipar=new ScilabDouble(...ipar);
- model.nzcross=new ScilabDouble([n*(n-1)/2+4*n]);
- model.blocktype=new ScilabString(["c"]);
- model.dep_ut=new ScilabBoolean([false,true]);
-
- var exprs=new ScilabString();
- // var exprs=[strcat(sci2exp(rpar1));strcat(sci2exp(rpar2));strcat(sci2exp(walls));strcat(sci2exp(x));strcat(sci2exp(xd));strcat(sci2exp(y));strcat(sci2exp(yd))]
- var gr_i=new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCE\",sz(1),sz(2));"]);
- this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i);
-
- return new BasicBlock(this.x);
} \ No newline at end of file