Commit beb9206d authored by leonelrosano's avatar leonelrosano
Browse files

modificaciónes

parent 62ea701f
...@@ -78,6 +78,7 @@ export class Graph2DComponent { ...@@ -78,6 +78,7 @@ export class Graph2DComponent {
} }
switch(canvas.tipo) { switch(canvas.tipo) {
case 'graph': { case 'graph': {
console.log(canvas.resultado)
var jsonCanvas = JSON.parse(canvas.resultado); var jsonCanvas = JSON.parse(canvas.resultado);
var conjs = this.obtenerConjunto(jsonCanvas.funs[0]); var conjs = this.obtenerConjunto(jsonCanvas.funs[0]);
...@@ -99,7 +100,6 @@ export class Graph2DComponent { ...@@ -99,7 +100,6 @@ export class Graph2DComponent {
funcionString = 'var ' + funs.fun + ' = function('+funs.args+'){\n return ' + this.generarExpresion(funs.bdy) + '}\n' + funcionString; funcionString = 'var ' + funs.fun + ' = function('+funs.args+'){\n return ' + this.generarExpresion(funs.bdy) + '}\n' + funcionString;
} }
funcionString = '(x)=>{\n' + funcionString + '}'; funcionString = '(x)=>{\n' + funcionString + '}';
console.log(funcionString)
obj.conj.sets.fdom = eval(funcionString); obj.conj.sets.fdom = eval(funcionString);
...@@ -158,8 +158,8 @@ export class Graph2DComponent { ...@@ -158,8 +158,8 @@ export class Graph2DComponent {
let fun = eval(funcionGenerada); let fun = eval(funcionGenerada);
var colores = ['violet', 'red', 'blue', 'orange', 'green','black',''] var colores = ['violet', 'red', 'blue', 'orange', 'green','black']
var num = this.getRandomArbitrary(0, 4); var num = this.getRandomArbitrary(0, 5);
var color = colores[num]; var color = colores[num];
var tipoGraf; var tipoGraf;
...@@ -233,6 +233,7 @@ export class Graph2DComponent { ...@@ -233,6 +233,7 @@ export class Graph2DComponent {
}else{ }else{
this.funciones.push({ this.funciones.push({
id: this.funciones.length, id: this.funciones.length,
sampler: 'builtIn', sampler: 'builtIn',
fn: function(scope) { fn: function(scope) {
...@@ -953,7 +954,9 @@ export class Graph2DComponent { ...@@ -953,7 +954,9 @@ export class Graph2DComponent {
exp.fun = 'Math.sin' exp.fun = 'Math.sin'
} else if (exp.fun == 'round') { } else if (exp.fun == 'round') {
exp.fun = 'Math.round' exp.fun = 'Math.round'
} }else if (exp.fun == 'sqrt'){
exp.fun = 'Math.sqrt'
}
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
} else if (exp.kind == 'tup') { } else if (exp.kind == 'tup') {
...@@ -1146,6 +1149,13 @@ generateFunctionAndExp = function (exp,graph,namefun6) { ...@@ -1146,6 +1149,13 @@ generateFunctionAndExp = function (exp,graph,namefun6) {
aux6[0]= aux26; aux6[0]= aux26;
aux6[1] = aux16; aux6[1] = aux16;
myList.push(aux6); myList.push(aux6);
}else if ((exp.fun == 'Math.sqrt') || (exp.fun == 'sqrt')){
var aux7 = [];
var aux17 = 'Math.sqrt('+ exp.args.map(e => this.generarExpresion(e)).join() +')';
var aux27 = 'N'
aux7[0]= aux27;
aux7[1] = aux17;
myList.push(aux7);
}else{ }else{
if(!namefun6.includes(exp.fun)){ if(!namefun6.includes(exp.fun)){
var ListnameFNew = namefun6; var ListnameFNew = namefun6;
...@@ -1262,6 +1272,11 @@ createListExp = function (exp) { ...@@ -1262,6 +1272,11 @@ createListExp = function (exp) {
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
funcione.push(expresion) funcione.push(expresion)
} else if (exp.fun == 'Math.sqrt') {
exp.fun = 'Math.sqrt'
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
funcione.push(expresion)
}else{ }else{
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
funcione.push(expresion) funcione.push(expresion)
...@@ -1408,7 +1423,12 @@ createListExp = function (exp) { ...@@ -1408,7 +1423,12 @@ createListExp = function (exp) {
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresionDisc(e,grap,ListnameF)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresionDisc(e,grap,ListnameF)).join() + ') ';
funcione.push(expresion) funcione.push(expresion)
}else{ } else if (exp.fun == 'Math.sqrt') {
exp.fun = 'Math.sqrt'
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresionDisc(e,grap,ListnameF)).join() + ') ';
funcione.push(expresion)
}else{
if(!ListnameF.includes(exp.fun)){ if(!ListnameF.includes(exp.fun)){
...@@ -1594,6 +1614,8 @@ createListExp = function (exp) { ...@@ -1594,6 +1614,8 @@ createListExp = function (exp) {
exp.fun = 'Math.sin' exp.fun = 'Math.sin'
} else if (exp.fun == 'round') { } else if (exp.fun == 'round') {
exp.fun = 'Math.round' exp.fun = 'Math.round'
}else if (exp.fun == 'sqrt'){
exp.fun = 'Math.sqrt'
} }
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarF(e)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarF(e)).join() + ') ';
} else if (exp.kind == 'tup') { } else if (exp.kind == 'tup') {
......
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