解析和绘制方程式 [英] Parsing and plotting equations

查看:95
本文介绍了解析和绘制方程式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从用户那里读取一个方程式,并且我想绘制该方程式的图形.我该怎么办?

I want to read from the user an equation, and I want to plot the graph of this equation. How would I go about this?

推荐答案

数据输入:
您可以给用户一个文本框和一个按钮,然后当他们按下按钮时,对文本进行语法分析以确保它是有效的数学表达式.或者,您可以构建一个公式编辑器GUI,以强制用户逐步构建公式,以便每个步骤都能确保公式的完整性.无论哪种方式,您都可能不得不将其转换为某些对象或对象层次结构,以执行他们输入的方程式.

图形:
那里有大量的图形控件,只有Google"C#图形控件".也许您甚至可以找到一个原样接受并绘制方程的图形.如果不是,那么您可能必须在方程中运行一堆数字才能生成大量数据点.任何体面的图形控件都应该能够绘制一组数据点,但是如果您真的愿意,甚至可以滚动自己的图形控件来完成这项工作.
Data Entry:
You could give the user a text box and button and then when they push the button parse the text to ensure it''s a valid mathematical expression. Alternatively you could build an Equation Editor GUI that forces the user to build an equation step by step so that each step ensures the integrity of the equation. Either way you''re then probably going to have to convert this into some object or hierarchy of objects that will execute the equation they''ve entered.

Graphing:
There are tons of graph controls out there, just Google "C# graph control". Maybe you can even find one that accepts and graphs an equation as is. If not then you''ll probably have to run a bunch of numbers through the equation to generate a good number of data points. Any decent graph control should be able to plot a set of data points but if you really want to you could even roll your own graph control to do the job.


这篇关于解析和绘制方程式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆