Angularjs оценивает выражение jquery Math Library в переменной

0

Я хотел бы оценить это выражение ниже (которое содержит ternary operator и ключевые слова Javascript Math Library) в одной переменной, например

var result = EvaluatedResult;

который должен дать мне одно значение, оттуда я буду использовать это значение для другого вычисления.

((((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))) < 0.3)?(((((23)*((5-1))*3.7)/2.68)<1)?((24/((((23)*((5-1))*3.7)/2.68)))):(((((23)*((5-1))*3.7)/2.68)>1 && (((23)*((5-1))*3.7)/2.68)<1000)?(((24/(((23)*((5-1))*3.7)/2.68))*(1+(0.15*(Math.pow((((23)*((5-1))*3.7)/2.68),0.687)))))):(0.044))):((((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))) > 0.3) && ((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))<1))?(((24/((((23)*((5-1))*3.7)/2.68)+((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))),2))+0.2*Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))),8))*(Math.exp(-(((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt(62/2)))*(1-(Math.exp(-((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))/(((23)*((5-1))*3.7)/2.68))))))):(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))>1 && (((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))<1.75)?((((24/((((23)*((5-1))*3.7)/2.68)+(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow((1),2))+0.2*Math.pow((1),8))*(Math.exp(-1/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*(1*Math.sqrt(62/2)))*(1-(Math.exp(-(1/(((23)*((5-1))*3.7)/2.68))))))+((4/3)*((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))-1)*(((0.9+(1.86*Math.sqrt((1.75)/((((23)*((5-1))*3.7)/2.68))))*(2+2/(Math.pow((1.75*(Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),2)))+(1.058*Math.sqrt((2+273))/(1.75*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))-(Math.pow(1/(1.75*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),4)+(0.34/(Math.pow(1.75,2))))/(1+(1.86*Math.sqrt((1.75)/((((23)*((5-1))*3.7)/2.68))))))-((24/((((23)*((5-1))*3.7)/2.68)+(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow((1),2))+0.2*Math.pow((1),8))*(Math.exp(-1/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*(1*Math.sqrt(62/2)))*(1-(Math.exp(-(1/(((23)*((5-1))*3.7)/2.68)))))))))):(((0.9+(1.86*Math.sqrt(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))))/((((23)*((5-1))*3.7)/2.68))))*(2+2/(Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*(Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),2)))+(1.058*Math.sqrt((2+273))/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))-(Math.pow(1/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),4)+(0.34/(Math.pow((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))),2))))/(1+(1.86*Math.sqrt(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))))/((((23)*((5-1))*3.7)/2.68)))))))))) * (Math.pow((5-1),2))*(3.14*(Math.pow(3.7,2))/4))

Когда я пытался использовать $scope.$eval(expression) то он может анализировать ternary operator но не способен анализировать Math.pow(3,2), Math.sqrt(2) как Javascript Math Library. Я сделал несколько экспериментов, используя выражение в HTML, которое может это сделать.

http://codepen.io/anon/pen/Veprqx

Но мне нужен результат в переменной области angularjs.

  • 0
    Что такое математическая библиотека jQuery? Выражение возвращает 782.7423490194351 здесь; это ожидаемый результат?
  • 0
    Извините, это математическая библиотека Javascript. Библиотека похожа на Math.pow (3,2), который является квадратом 3. w3schools.com/jsref/jsref_obj_math.asp .
Показать ещё 5 комментариев

1 ответ

0
Лучший ответ

Не известно, какой ожидаемый результат, но должен иметь возможность возвращать результаты выражения с использованием выражения var expr =/* mathematical expression */; console.log(expr) var expr =/* mathematical expression */; console.log(expr). Также обратите внимание, что объект Math не является "библиотекой", а объектом внутри JavaScript

var expr = ((((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))) < 0.3)?(((((23)*((5-1))*3.7)/2.68)<1)?((24/((((23)*((5-1))*3.7)/2.68)))):(((((23)*((5-1))*3.7)/2.68)>1 && (((23)*((5-1))*3.7)/2.68)<1000)?(((24/(((23)*((5-1))*3.7)/2.68))*(1+(0.15*(Math.pow((((23)*((5-1))*3.7)/2.68),0.687)))))):(0.044))):((((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))) > 0.3) && ((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))<1))?(((24/((((23)*((5-1))*3.7)/2.68)+((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))),2))+0.2*Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))),8))*(Math.exp(-(((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt(62/2)))*(1-(Math.exp(-((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))/(((23)*((5-1))*3.7)/2.68))))))):(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))>1 && (((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))<1.75)?((((24/((((23)*((5-1))*3.7)/2.68)+(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow((1),2))+0.2*Math.pow((1),8))*(Math.exp(-1/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*(1*Math.sqrt(62/2)))*(1-(Math.exp(-(1/(((23)*((5-1))*3.7)/2.68))))))+((4/3)*((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))-1)*(((0.9+(1.86*Math.sqrt((1.75)/((((23)*((5-1))*3.7)/2.68))))*(2+2/(Math.pow((1.75*(Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),2)))+(1.058*Math.sqrt((2+273))/(1.75*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))-(Math.pow(1/(1.75*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),4)+(0.34/(Math.pow(1.75,2))))/(1+(1.86*Math.sqrt((1.75)/((((23)*((5-1))*3.7)/2.68))))))-((24/((((23)*((5-1))*3.7)/2.68)+(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))*(4.33+(((3.65-1.53)*((2+273)/2))/(1-0.353*((2+273)/2)))*Math.exp(-0.247*((((23)*((5-1))*3.7)/2.68)/(1*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))))))+((((4.5+0.38)*((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))/(1+((0.03*(((23)*((5-1))*3.7)/2.68))+(0.48*Math.sqrt((((23)*((5-1))*3.7)/2.68))))))+(0.1*Math.pow((1),2))+0.2*Math.pow((1),8))*(Math.exp(-1/(2*Math.sqrt((((23)*((5-1))*3.7)/2.68)))))+(0.6*(1*Math.sqrt(62/2)))*(1-(Math.exp(-(1/(((23)*((5-1))*3.7)/2.68)))))))))):(((0.9+(1.86*Math.sqrt(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))))/((((23)*((5-1))*3.7)/2.68))))*(2+2/(Math.pow(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*(Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),2)))+(1.058*Math.sqrt((2+273))/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2)))-(Math.pow(1/((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56))))*Math.sqrt((((52)*((2+273)))/(Math.sqrt(2)*(3.14)*(Math.pow(3,2))*(9)))/2))),4)+(0.34/(Math.pow((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))),2))))/(1+(1.86*Math.sqrt(((((5-1))/((Math.sqrt((1.3*3.4*((2+273)))/56)))))/((((23)*((5-1))*3.7)/2.68)))))))))) * (Math.pow((5-1),2))*(3.14*(Math.pow(3.7,2))/4));

console.log(expr)

Ещё вопросы

Сообщество Overcoder
Наверх
Меню