public void DrawRealPlot(Graphics g, string xt, string yt) { try { g.Clear(BC); DrawAxesNet(g); int width = (int)g.ClipBounds.Width, height = (int)g.ClipBounds.Height; XtensibleCalculator c = new XtensibleCalculator(); Func <Dictionary <string, double>, double> fx, fy; var exp = c.ParseFunction(xt); fx = exp.Compile(); exp = c.ParseFunction(yt); fy = exp.Compile(); Dictionary <string, double> Dict = new Dictionary <string, double>(); Dict.Add("t", StartT); Point p = new Point(conv.II(fx(Dict)), conv.JJ(-fy(Dict))); for (double i = StartT + Step; i < EndT; i += Step) { Dict["t"] = i; Point pt = new Point(conv.II(fx(Dict)), conv.JJ(-fy(Dict))); try { g.DrawLine(new Pen(LC), p, pt); } catch (OverflowException) { break; } p = pt; } } catch (Sprache.ParseException) { g.Clear(BC); DrawAxesNet(g); } }
public double SearchForT(int x, int y, string xt, string yt) { XtensibleCalculator c = new XtensibleCalculator(); Func <Dictionary <string, double>, double> fx, fy; var exp = c.ParseFunction(xt); fx = exp.Compile(); exp = c.ParseFunction(yt); fy = exp.Compile(); Dictionary <string, double> Dict = new Dictionary <string, double>(); Dict.Add("t", 0); for (double i = StartT; i < EndT; i += Step / 10) { Dict["t"] = i; Point pt = new Point(conv.II(fx(Dict)), conv.JJ(-fy(Dict))); if (Math.Abs(pt.X - x) < 5 && Math.Abs(pt.Y - y) < 5) { return(Dict["t"]); } } return(5000); }