Click here to Skip to main content
15,893,622 members
Articles / Programming Languages / Visual Basic

Mathemathics Framework

Rate me:
Please Sign up or sign in to vote.
4.76/5 (56 votes)
16 Sep 2008CPOL6 min read 75.4K   6.2K   171  
.NET Mathematical Framework
Imports FormUtils
Imports Basics
Imports MidRange
Imports GraphicsObjects
Imports System.Drawing
Imports BVCtl
Imports SecundaryForms
Imports GraphicsUtilities
Imports System.ComponentModel
Imports System.Windows.Forms

Public Class NewParseCommonConfiguration
    Inherits CommonConfiguration

    Protected FnManager As FunctionManager
    Protected htbl As BVHashTable
    Protected GoV As GraphOfVisorComplex
    Protected intRealIsScanVariable As Boolean

    Public Sub New(ByVal FormToolBar As BVToolBar)
        MyBase.New(FormToolBar)
        'Me.intVisor.Add(ParallelObj)
        FnManager = New FunctionManager
        htbl = New BVHashTable
        intRealIsScanVariable = True
    End Sub

#Region "Properties"

    <Description("Analized Mathematical function expresion"), _
    Category("Function Properties")> _
    Public Property Expresion() As String
        Get
            Return Me.FnManager.CurrentFunction.Expresions(0)
        End Get
        Set(ByVal Value As String)
            If Me.FnManager.Functions Is Nothing Then
                Me.FnManager.Add(Value)
                Me.Add(Me.FnManager.CurrentFunction)
            Else
                Me.FnManager.CurrentFunction.Parts(0).Expresion = Value
                Me.Redraw()
            End If
        End Set
    End Property

    Public Overrides ReadOnly Property Description() As String
        Get
            Return "Roor Locus Demo Configuration"
        End Get
    End Property

    <Browsable(False)> _
    Public ReadOnly Property ParseManager() As FunctionManager
        Get
            Return Me.FnManager
        End Get
    End Property

    <Description("Selected function Name"), _
    Category("Function Properties")> _
    Public Property SelectedFunctionName() As String
        Get
            Return Me.FnManager.CurrentFunction.Name
        End Get
        Set(ByVal Value As String)
            Me.FnManager.CurrentFunction.Name = Value
            If Me.FnManager.CurrentFunction.Name = Value Then
                Me.FnManager.Add(Me.FnManager.CurrentFunction)
            End If
        End Set
    End Property

    <Browsable(False)> _
    Public Property SelectedFunction() As [Function]
        Get
            Return Me.FnManager.CurrentFunction
        End Get
        Set(ByVal Value As [Function])
            Me.FnManager.CurrentFunction = Value
        End Set
    End Property

    Public Property RealIsScanVariable() As Boolean
        Get
            Return Me.intRealIsScanVariable
        End Get
        Set(ByVal Value As Boolean)
            Me.intRealIsScanVariable = Value
        End Set
    End Property

#End Region

    Public Sub Add(ByVal Ecuation As String)
        Dim s() As String
        s = Ecuation.Split("=")
        If s Is Nothing Then
            Exit Sub
        End If

        Dim f As [Function]
        If s.GetUpperBound(0) = 1 Then
            Me.FnManager.Add(s(1), s(0))
            f = Me.FnManager.CurrentFunction
            Me.Add(f)
            'RaiseEvent FunctionsChange(Me, New EventArgs)
        ElseIf s.GetUpperBound(0) = 0 Then

        End If
    End Sub

    Public Sub Add(ByVal F As [Function])
        If Not Me.htbl.Contains(F) Then
            Me.ParallelObj = New ParallelSystemCalc
            Me.htbl.Add(F, Me.ParallelObj)
            Me.intVisor.Add(Me.ParallelObj)
            GoV = intVisor.CurrentGoV
            GoV.LineType = TypeOfVisorLine.Solid
            GoV.Show = GraphShow.Real
            GoV.AutoScale = AutoScaleCplxTypes.X
            GoV.BriefDescription = F.Name

            Me.Redraw()
        End If
    End Sub

    Public Overrides Sub Redraw()
        Dim s() As Single
        Dim i, j As Integer
        Dim b() As PointC

        intBr.Reset()
        intBr.Run()
        s = intBr.OldValues
        For Each f As [Function] In Me.htbl.Keys
            ReDim b(intBr.NumberOfPoints - 1)
            If intRealIsScanVariable Then
                For i = 0 To b.GetUpperBound(0)
                    b(i) = New PointC(f.Calc(s(i)), s(i))
                Next
            Else
                For i = 0 To b.GetUpperBound(0)
                    b(i) = New PointC(f.Calc(New ComplexUndefinied(0, s(i))), s(i))
                Next
            End If
            If j = 0 Then
                a = b
            End If
            j += 1
            htbl.Item(f).In(b)
        Next

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Universidad Tecnológica Nacional
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions