Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi guys!

How can I plot functions in vb net?

The user enters a math expression for f(x) and the program plots this.,eg: f(x)=x^2+Sin(x)

Is that possible with vb net??

Thanks

  • 5 weeks later...
  • Leaders
Posted

That's what I did.

You can just put a function...

Private Function F(ByVal X As Currency) As Currency
F = X*X
End Function

Then you can graph it like this:

For X = -20 To 20
 Y = F(X)
 'You can draw Y here with whatever graphics you need
 'Preferably a DrawPixel of some sort at (X, Y), however
 'it will be upside down, so you'd have to take your Y
 'value and negate it.
 Y = -Y
 'Then you need to move it on the visible area of the form.
 Y += Width
 'Where Width is the width of the area that you want to
 'see the drawing at.
Next

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

Is there a command which can convert string variables to arithmetical values, eg:

user types "x^2+5*x" as string and the machine regocnise it as an operation.???????

  • Leaders
Posted

There may be some addin of some sort (like a MS Scripting addin) that will do this for you, but I doubt if .NET comes with a way to do this, mainly because there are so many ways to parse an arithmetic function.

You would have to either hardcode all the functions or use the polynomial approach, in which you specify the coefficients for each exponent... i.e. for x^3 + 3x^2 + 12, you would have 1, 3, 0, and 12. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...