I was getting this exact same plot using JSXGraph: = 0" referrerpolicy="no-referrer" style="max-width:100%"> Code fo"/>
  简体   繁体   中英

Inverse: true doesn't plot the right graph for all inequalities

I was trying to plot a graph for inequality 5x + 2y -5 >= 0.

So as expected and verified from Desmos's Graph I am getting:

方程5x + 2y-5> = 0的Desmos图

I was getting this exact same plot using JSXGraph:

方程5x + 2y-5> = 0的JSXGraph图

Code for creating this graph:

var board = JXG.JSXGraph.initBoard('graphDiv',{axis:true, boundingbox:[-4, 5, 4, -3]});  //Creates the cartesian graph

var input = [5,2,-5];  //5x + 2y - 5 = 0

line = board.create('line', [input[2],input[0],input[1]], {fixed: true });
ineq = board.create('inequality', [line], {inverse:true});

But the problem arised when I was trying for the inverted inequality. But my application was such that the coefficients for multiple line equations will be different and the corresponding lines are created via for loop. So, for the inequality: -5x -2y +5 >=0, following are the results:

As expected and verified from Desmos:

方程-5x-2y + 5> = 0的Desmos图

And as seen from JSXGraph:

方程的JSXGraph:-5x-2y + 5> = 0

Nopes, I haven't uploaded the same image twice. I am getting the same plot again.

The code for this part goes as:

var board = JXG.JSXGraph.initBoard('graphDiv',{axis:true, boundingbox:[-4, 5, 4, -3]});  //Creates the cartesian graph

var input = [-5,-2,5];  //-5x - 2y + 5 = 0

line = board.create('line', [input[2],input[0],input[1]], {fixed: true });
ineq = board.create('inequality', [line], {inverse:true});

Why am I not getting the inverted region highlighted in this JSXGraph? Is there any way I can display it the other way round?

I tried removing inverse: true and I am getting the right region highlighted for the second equation but I am getting the wrong one in case of the first equation. Why isn't inverse: true working in both the situations as I have correctly changed the coefficients.

As I already mentioned, in my application, I have equations of multiple lines and I cannot specify whether inverse: true has to be included or not for each line individually. Using a for loop is the only way out.

I had tried using a workaround earlier which worked out only for some inequalities. So I commented on this issue on JSXGraph's Github Repository. Thanks to the efficient development team and the speedy responses, this bug has now been fixed by their contributor Alfred Wassermann .

Yayy now I can draw the right inequalities!

This bug fix will be available in the next release. Till then you'll have to do the build the jsxgraphcore.js file and use it in your webapp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM