I came across this old thread that states that implicit plotting functionality is being worked on but the thread is kinda old and I was wondering if anything came from it.
https://groups.google.com/forum/#!topic/jsxgraph/pvRgjLS6Du0
Also, if the functionality has not been implemented yet, does anyone have any advice as to what approach can I take to start implementing such a feature?
Thank you.
I found it very easy (i.e. less than an hour of work) to take implicit.js (http://shamshad-npti.github.io/scripts/implicit.js) from this fellow's quad tree marching squares example http://shamshad-npti.github.io/implicit/curve/2015/10/08/Implicit-curve/ and adapt it to use the data curve like so (replacing his CanvasPlotter with ImplicitPlotter):
var ImplicitPlotter = function(board, func)
{
var me = {};
me.board = board; me.func = func;
me.colour = "blue";
me.px = 300; me.py = 300;
me.tx = 0; me.ty = 0;
me.curves = [];
me.finish = function(segments)
{
board.create('transform', [-me.x1 * me.tx, me.y2 * me.ty], {type: 'translate'});
board.create('transform', [me.tx, -me.ty], {type: 'scale'});
var xs = [];
var ys = [];
var curves = [];
for (var i = 0; i < segments.length; i++)
{
var s = segments[i];
if (!s.lineTo && xs.length)
{
curves.push(board.create('curve', [xs, ys], {strokeWidth:1, strokeColor:me.colour}));
xs = [];
ys = [];
}
xs.push(segments[i].x);
ys.push(segments[i].y);
}
if (xs.length)
{
curves.push(board.create('curve', [xs, ys], {strokeWidth:1, strokeColor:me.colour}));
}
return curves;
}
me.update = function()
{
var bbox = board.getBoundingBox();
me.x1 = 1.2 * bbox[0]; me.x2 = 1.2 * bbox[2];
me.y1 = 1.2 * bbox[1]; me.y2 = 1.2 * bbox[3];
me.px = board.canvasWidth;
me.py = board.canvasHeight;
me.tx = me.px / (me.x2 - me.x1);
me.ty = me.py / (me.y2 - me.y1);
me.plot = new Implicit(me.func, me.finish);
me.curves = me.plot.update(me.x1, me.y1, me.x2, me.y2, me.px, me.py);
}
return me;
};
Adding in a bit of a check to see when updates are needed, and using jessie script to interpret an equation I've got implicit plotting working nicely along side the more standard cartesian, parametric and polar plots.
Ken
I made a fiddle but each time I post a link the post gets deleted. :(
The link is at jsfiddle <dot> net <slash> xaczkdm0 <slash> 6 <slash>
If this is not some automated thing but a moderator is deleting the post, could you explain why?
Thanks,
Ken