-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asymptotes and Discontinuities #64
Comments
+1 on that. Any Ideas how to approach this? |
Put some very cumbersome solution for one simple singularity ( form of y=(1/x+p)+q works fine ) Find those lines in main.js //begin the path. Colour (fill and stroke) is already done for us in ui.js
builder+="ctx.beginPath();var x=boundleft;ctx.move(x,"+jsc+");";
if(0 && singularities.length){
//Better plot logic.
//For example, this would allow us to plot y=sqrt(1-x^2) from [-1,1] exactly with no abrupt endings. and add below //Better plot logic.
//For example, this would allow us to plot y=sqrt(1-x^2) from [-1,1] exactly with no abrupt endings.
window.sings=[];
for(var i=0; i<singularities.length; i++){
sings.push(singularities[i]);
}
builder+="var jsc =0; window.c = ctx; window.interval= (boundright-boundleft)/width;\
for(var x=boundleft;x<boundright;x+=interval){\
if(!(x<sings[0] && x+interval>sings[0])){\
ctx.line(x,"+jsc+");\
}else{\
var color = ctx.strokeStyle;\
ctx.stroke();\
\
/* Vertical Asymptote */\
ctx.beginPath();\
ctx.strokeStyle = '#ff0000';\
for(var draw=false,start = boundbottom; start < boundtop;start+=0.1){\
ctx[draw? 'move' : 'line'](x,start);\
draw = !draw;\
}\
ctx.stroke();\
\
/* Horizontal Asymptote */\
if(this.math.length && this.math[0].type==2){\
ctx.beginPath(); console.log("+jsc+",this);\
for(var draw=false,start = boundleft; start < boundright;start+=0.1){\
ctx[draw? 'move' : 'line'](start,this.math[0][1]);\
draw = !draw;\
}\
ctx.stroke();\
}\
\
ctx.beginPath();\
ctx.strokeStyle = color;\
}}ctx.stroke();"; Let me know if its something You might use and whats missing. Sample equations welcomed. FYI: |
Fix to better handle vertical asymptotes "/* Horizontal Asymptote */\
ctx.beginPath(); console.log("+jsc+",this);\
for(var draw=false,start = boundleft; start < boundright;start+=0.1){\
var t=x; x=boundleft;\
ctx[draw? 'move' : 'line'](start,"+jsc+");x=t;\
draw = !draw;\
}\
ctx.stroke();\ It works well but not quite perfect. Same as with vertical a mathematical solution would be better than graphical one. http://www.onlinemathlearning.com/asymptote.html - some inspiration on calculating asymptotes things like roots() factorise() and singularities() are already in place. No time to do it properly though. |
Thank you for your additions, and for the link. But since that code is pretty old, and nothing at all like what the next release will be like (thank god), these code improvements won't be able to be used. |
Are you planning to support all kinds of Asymptotes the right way? (the way singularities are calculated, not my way ;)) |
Any chance the next version will correctly graph horizontal, vertical asymptotes and discontinuities?
The text was updated successfully, but these errors were encountered: