@@ -17,45 +17,45 @@ export const Expressions = {
1717 psplot : / \\ p s p l o t ( \[ [ ^ \] ] * \] ) ? \{ ( [ ^ \} ] * ) \} \{ ( [ ^ \} ] * ) \} \{ ( [ ^ \} ] * ) \} / ,
1818 psarc : new RegExp (
1919 '\\\\psarc' +
20- RE . options +
21- RE . type +
22- RE . coords +
23- RE . squiggle +
24- RE . squiggle +
25- RE . squiggle
20+ RE . options +
21+ RE . type +
22+ RE . coords +
23+ RE . squiggle +
24+ RE . squiggle +
25+ RE . squiggle
2626 ) ,
2727 pscircle : / \\ p s c i r c l e .* \( \s * ( .* ) , ( .* ) \s * \) \{ ( .* ) \} / ,
2828 pspolygon : new RegExp ( '\\\\pspolygon' + RE . options + '(.*)' ) ,
2929 psaxes : new RegExp (
3030 '\\\\psaxes' +
31- RE . options +
32- RE . type +
33- RE . coords +
34- RE . coordsOpt +
35- RE . coordsOpt
31+ RE . options +
32+ RE . type +
33+ RE . coords +
34+ RE . coordsOpt +
35+ RE . coordsOpt
3636 ) ,
3737 slider : new RegExp (
3838 '\\\\slider' +
39- RE . options +
40- RE . squiggle +
41- RE . squiggle +
42- RE . squiggle +
43- RE . squiggle +
44- RE . squiggle
39+ RE . options +
40+ RE . squiggle +
41+ RE . squiggle +
42+ RE . squiggle +
43+ RE . squiggle +
44+ RE . squiggle
4545 ) ,
4646 psline : new RegExp (
4747 '\\\\psline' + RE . options + RE . type + RE . coords + RE . coordsOpt
4848 ) ,
4949 userline : new RegExp (
5050 '\\\\userline' +
51- RE . options +
52- RE . type +
53- RE . coords +
54- RE . coords +
55- RE . squiggleOpt +
56- RE . squiggleOpt +
57- RE . squiggleOpt +
58- RE . squiggleOpt
51+ RE . options +
52+ RE . type +
53+ RE . coords +
54+ RE . coords +
55+ RE . squiggleOpt +
56+ RE . squiggleOpt +
57+ RE . squiggleOpt +
58+ RE . squiggleOpt
5959 ) ,
6060 uservariable : new RegExp (
6161 '\\\\uservariable' + RE . options + RE . squiggle + RE . coords + RE . squiggle
@@ -191,26 +191,21 @@ export const Functions = {
191191 Object . entries ( this . variables || { } ) . forEach ( ( [ name , val ] ) => {
192192 expression += 'var ' + name + ' = ' + val + ';' ;
193193 } ) ;
194-
194+
195195 const mathFunctions = 'var cos=Math.cos,sin=Math.sin,tan=Math.tan,atan=Math.atan,atan2=Math.atan2,exp=Math.exp,log=Math.log,sqrt=Math.sqrt,abs=Math.abs,floor=Math.floor,ceil=Math.ceil,round=Math.round,pow=Math.pow,PI=Math.PI,E=Math.E;' ;
196196 expression += mathFunctions + 'return ' + m [ 4 ] + ';' ;
197-
198- console . log ( 'psplot expression setup:' , { expression, startX, endX, mathExpression : m [ 4 ] } ) ;
199-
197+
200198 for ( x = startX ; x <= endX ; x += 0.005 ) {
201199 data . push ( X . call ( this , x ) ) ;
202200 try {
203201 const evalFunc = new Function ( 'x' , expression ) ;
204202 const yValue = evalFunc ( x ) ;
205- console . log ( 'psplot evaluation:' , { x, yValue, expression : m [ 4 ] } ) ;
206203 if ( yValue !== undefined && ! isNaN ( yValue ) ) {
207204 data . push ( Y . call ( this , yValue ) ) ;
208205 } else {
209- console . warn ( 'Invalid yValue:' , yValue , 'for x:' , x ) ;
210206 data . push ( Y . call ( this , 0 ) ) ;
211207 }
212208 } catch ( err ) {
213- console . warn ( 'Error evaluating expression:' , err , { x, expression : m [ 4 ] } ) ;
214209 data . push ( Y . call ( this , 0 ) ) ; // fallback value
215210 }
216211 }
@@ -374,7 +369,7 @@ export const Functions = {
374369 var xExp = m [ 7 ] ;
375370 var yExp = m [ 8 ] ;
376371 const mathFunctions = 'var cos=Math.cos,sin=Math.sin,tan=Math.tan,atan=Math.atan,atan2=Math.atan2,exp=Math.exp,log=Math.log,sqrt=Math.sqrt,abs=Math.abs,floor=Math.floor,ceil=Math.ceil,round=Math.round,pow=Math.pow,PI=Math.PI,E=Math.E;' ;
377-
372+
378373 if ( xExp )
379374 xExp = mathFunctions + xExp . replace ( / ^ \{ / , '' ) . replace ( / \} $ / , '' ) ;
380375 if ( yExp )
0 commit comments