how can i draw a graph of a function using visual basic.net 2010? eg graph of y=cos2x +5x
drawing of functional graphs
Collapse
X
-
Tags: None
-
Basically you need to look up the System.Drawing. Graphics class on how to draw lines and points from code. After that simply create 2 perpendicular axes. Your function should look something like:
Code:Public Function y(byval x as double) as double Return (5*x) + Math.Cos(2*x) End Function
If you want arcs (and a more fluid graph) you'll need to compute slopes and such, but you can avoid these computations by giving very very small increments to "x" and drawing lines ;) Basically any curve can be approximated as successive lines made between points very close together (check Darboux integrals, if i remember correctly).
I don't know if there are better way to do this (and they could very well be), but i hope i pointed you in the right direction.
Comment