Results 1 to 13 of 13

Thread: Non-functions plot app...

  1. #1

    Thread Starter
    Lively Member poggo's Avatar
    Join Date
    Sep 2005
    Posts
    90

    Question Non-functions plot app...

    Hi everybody!! I have a question: is it possible to code a plot app that can also plot non-functions, like an ellipsis or a circle, on the plane, given its equation?? What should i do to solve the equation and get the points? I'm assuming not to only draw those curves but even complex curves like beziers curves, etc..
    Currently using VB.NET 2005...

  2. #2
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    Quote Originally Posted by poggo
    Hi everybody!! I have a question: is it possible to code a plot app that can also plot non-functions, like an ellipsis or a circle, on the plane, given its equation?? What should i do to solve the equation and get the points? I'm assuming not to only draw those curves but even complex curves like beziers curves, etc..
    I'm not quite sure what your problem is. Can you be a bit more explicit? Plotting a function given its equation shouldn't be too difficult, just choose an interval for the independent variable, select a step, calculate the function value and place this in a loop where you include some code for plotting.
    As for circles and other closed curves, the best you could do is use polar or parametric coordinates, otherwise you have 2 (or more) function values for every single value of the independent variable.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  3. #3

    Thread Starter
    Lively Member poggo's Avatar
    Join Date
    Sep 2005
    Posts
    90

    Re: Non-functions plot app...

    My fault. I meant how can i solve that equations with 2 variables?? And if these variables are cubic? Or fourth powered?? How do i find solutions of an user-input equation?
    Currently using VB.NET 2005...

  4. #4
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    Quote Originally Posted by poggo
    My fault. I meant how can i solve that equations with 2 variables?? And if these variables are cubic? Or fourth powered?? How do i find solutions of an user-input equation?
    It depends on what type of equations. If they are linear it's quite easy. Otherwise you'll have to look into numerical methods. However, different types of equations may require different recipes. Can you post a few samples?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5

    Thread Starter
    Lively Member poggo's Avatar
    Join Date
    Sep 2005
    Posts
    90

    Re: Non-functions plot app...

    Yes... for example a circle: x^2+y^2+3x-4y+5=0
    Or an ellipsis: x^2/12 + y^2/25=0
    Do you need any other examples?
    Anyway, i mean curves like these, or even like cosh, sinh, tanh, etc...
    Currently using VB.NET 2005...

  6. #6
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    The circle is not too hard to solve:
    x2+y2+3x-4y+5=0
    Compare this to the general equation of a circle with center at (a,b) and radius R:

    (x - a)2 + (y - b)2 = R2

    x2 -2ax +a2 + y2 -2by + b2 - R2 = 0

    Identifying terms:

    -2a = 3
    2b = 4
    a2 + b2 - R2 = 5

    From this you get
    a = -3/2
    b = 2
    R = Sqrt(5) / 2

    The presumed ellipse is not such:

    x2/12 + y2/25=0

    The right term should be 1 !!! If this is the case (i.e. you mistranscribed it) then the right equation is:

    x2/12 + y2/25 = 1

    from which:

    y2/25 = 1 - x2/12

    y2 = 25(1 - x2/12)

    y = Sqrt[25(1 - x2/12)] = 5*Sqrt[1 - x2/12)]

    As for other types of equations, each needs its own way to be dealt with.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  7. #7
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Non-functions plot app...

    If, on the other hand, your trouble is getting from the string of an equation that a user has typed in a textbox to actually doing the calculation, then you'll need to program a calculator.

    This thread might be of use...


    zaza

  8. #8
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    Quote Originally Posted by zaza
    If, on the other hand, your trouble is getting from the string of an equation that a user has typed in a textbox to actually doing the calculation, then you'll need to program a calculator.

    This thread might be of use...


    zaza
    I once programmed a calculator which parsed a user-input RPN string and evaluated the expression. Indeed, RPN is much easier to code!
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  9. #9
    Member
    Join Date
    Nov 2005
    Location
    California
    Posts
    41

    Re: Non-functions plot app...

    I made a application like what you are trying to do.
    I had to use regression to figure out the y value once I had an x value....
    for like the circle x^2+y^2=4
    Here is a little sample of what it would be like...
    VB Code:
    1. For x as integer = -2 to 2
    2.  
    3. for y as integer = -10 to 10
    4. If evaluate(x^2+y^2)=4 Then
    5. StorePoint(x,y)
    6. End if
    7. next y
    8.  
    9. next x
    I wouldn't suggest it, but maybe that will get you started...

    If you need an application check out: http://www.peda.com/grafeq/
    Nice quick application. Very useful/ easy & strait forward....

    Maybe talk them into releasing their source....? <good luck>

  10. #10
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    I didn't know about "evaluate", I assume it's a sub you coded yourself.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Non-functions plot app...

    Nope. Scripting control:

    VBSCRIPT

    VB Code:
    1. Option Explicit
    2.  
    3. ' Add a reference to Microsoft Script Control 1.0
    4.  
    5. Private Sub Form_Load()
    6. Dim str1 As String
    7. Dim dbl1 As Double
    8. Dim x As New ScriptControl
    9. Dim z%, a%, q$
    10.  
    11. z = 55
    12. a = 24
    13. q = "*"
    14. x.Language = "vbScript"
    15. MsgBox Format(x.Eval(z & q & a), "standard")
    16.  
    17. ' ===============================================
    18.  
    19.  str1 = "(5+50)*2/3"
    20.  dbl1 = (x.Eval(str1))
    21.  MsgBox dbl1
    22. End Sub

    JSCRIPT
    VB Code:
    1. Option Explicit
    2.  
    3. ' Add a reference to Microsoft Script Control 1.0
    4.  
    5. Private Sub Form_Load()
    6.   Dim strExpression As String
    7.   Dim x As New ScriptControl
    8.  
    9.   x.Language = "jScript"
    10.   strExpression = "unescape('%2F')"
    11.   MsgBox x.Eval(strExpression)
    12.  
    13.   strExpression = "escape(':')"
    14.   MsgBox x.Eval(strExpression)
    15. End Sub

  12. #12
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Non-functions plot app...

    Quote Originally Posted by dglienna
    Nope. Scripting control...
    Gee, I wasn't aware that such a thing existed... what are these scripts used for, i.e. what can you do with them that couldn't be done in VB without?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  13. #13
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Non-functions plot app...

    Quote Originally Posted by dglienna
    Nope. Scripting control:

    VBSCRIPT

    VB Code:
    1. Option Explicit
    2.  
    3. ' Add a reference to Microsoft Script Control 1.0
    4.  
    5. Private Sub Form_Load()
    6. Dim str1 As String
    7. Dim dbl1 As Double
    8. Dim x As New ScriptControl
    9. Dim z%, a%, q$
    10.  
    11. z = 55
    12. a = 24
    13. q = "*"
    14. x.Language = "vbScript"
    15. MsgBox Format(x.Eval(z & q & a), "standard")
    16.  
    17. ' ===============================================
    18.  
    19.  str1 = "(5+50)*2/3"
    20.  dbl1 = (x.Eval(str1))
    21.  MsgBox dbl1
    22. End Sub

    JSCRIPT
    VB Code:
    1. Option Explicit
    2.  
    3. ' Add a reference to Microsoft Script Control 1.0
    4.  
    5. Private Sub Form_Load()
    6.   Dim strExpression As String
    7.   Dim x As New ScriptControl
    8.  
    9.   x.Language = "jScript"
    10.   strExpression = "unescape('%2F')"
    11.   MsgBox x.Eval(strExpression)
    12.  
    13.   strExpression = "escape(':')"
    14.   MsgBox x.Eval(strExpression)
    15. End Sub
    ...Which is the slowest imaginable way to do string math.

    It's is useless for doing many evaluations at once. You'll need to find a bespoke, optimised string math evaluator.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width