⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linecurve.vb

📁 这里是用VB写的数学库。以前用C、C++写的比较多。内容有:复数运算、矩阵运算、解方程、积分微分等。非常有用。
💻 VB
字号:
' The Point structure and Line class reside in the 
' Extreme.Mathematics.Curves namespace.
Imports Extreme.Mathematics.Curves

Namespace Extreme.Mathematics.QuickStart.VB

    Module LineCurve

        ' Illustrates the use of the Point structure and the Line
        ' class in the Extreme.Mathematics.Curve namespace of the 
        ' Extreme Optimization Mathematics Library for .NET.
        Sub Main()
            ' All curves inherit from the Curve abstract base
            ' class. The Line class overrides implements all
            ' the methods and properties of the Curve class,
            ' and adds a few more.
            '
            ' In a few places, we will need the Point structure.
            ' It simply containts an X and a Y component, much
            ' like the PointF structure in the System.Drawing
            ' namespace.
            '
            ' Let's create some points:
            Dim point1 As Point = New Point(1, 3)
            Dim point2 As Point = New Point(4, 9)

            '
            ' Line constructors
            '

            ' The Line class has multiple constructors. Each
            ' constructor derives from a different way to define
            ' a straight line.

            ' 1st option: a line through 2 points.
            Dim line1 As Line = New Line(point1, point2)
            ' 2nd option: same as above, but we use the x and 
            ' y coordinates of the points directly.
            Dim line2 As Line = New Line(point1.X, point1.Y, _
                point2.X, point2.Y)
            ' 3rd option: a line through a point with a specified
            ' slope,
            Dim line3 As Line = New Line(point1, 2)
            ' 4th option: same as above, but we use the x and 
            ' y coordinates of the point directly.
            Dim line4 As Line = New Line(point1.x, point1.y, 2)
            ' 5th option: a line with specified slope and 
            ' specified value at x = 0
            Dim line5 As Line = New Line(2, 1)

            '
            ' Curve Parameters
            '

            ' The shape of any curve is determined by a set of parameters.
            ' These parameters can be retrieved and set through the
            ' Parameters collection. The number of parameters for a curve 
            ' is given by this collection's Count property.
            '
            ' Lines have two parameters: the y value at x = 0
            ' and the slope.
            Console.WriteLine("line1.ParameterCount = {0}", _
                line1.Parameters.Count)
            ' Parameters can easily be retrieved:
            Console.WriteLine("line1 parameters {0}, {1}", _
                line1.Parameters(0), line1.Parameters(1))
            ' We can see that line2, line3, line4 and line5
            ' all define the same line as line1:
            Console.WriteLine("line2 parameters {0}, {1}", _
                line2.Parameters(0), line2.Parameters(1))
            Console.WriteLine("line3 parameters {0}, {1}", _
                line3.Parameters(0), line3.Parameters(1))
            Console.WriteLine("line4 parameters {0}, {1}", _
                line4.Parameters(0), line4.Parameters(1))
            Console.WriteLine("line5 parameters {0}, {1}", _
                line5.Parameters(0), line5.Parameters(1))
            ' Parameters can also be set:
            line1.Parameters(0) = 1

            '
            ' Curve Methods
            '

            ' The ValueAt method returns the y value of the
            ' curve at the specified x value:
            Console.WriteLine("line1.ValueAt(2) = {0}", _
                line1.ValueAt(2))

            ' The SlopeAt method returns the slope of the curve
            ' a the specified x value:
            Console.WriteLine("line1.SlopeAt(2) = {0}", _
                line1.SlopeAt(2))

            ' You can also create a new curve that is the 
            ' derivative of the original:
            Dim derivative As Curve = line1.GetDerivative()
            Console.WriteLine("Slope at 2 (derivative) = {0}", _
                derivative.ValueAt(2))

            ' For Line curves, you can access the slope directly
            ' through the Slope property:
            Console.WriteLine("Slope of the line = {0}", line1.Slope)

            ' You can get a Line that is the tangent to a curve
            ' at a specified x value using the TangentAt method:
            Dim tangent As Line = line1.TangentAt(2)
            Console.WriteLine("Slope of tangent line at 2 = {0}", _
                tangent.Slope)

            ' For many curves, you can evaluate a definite
            ' integral exactly:
            Console.WriteLine("Integral between 0 and 1 = {0}", _
                line1.Integral(0, 1))

            ' You can find the zeroes or roots of the curve
            ' by calling the FindRoots method:
            Dim roots As Double() = line1.FindRoots()
            Console.WriteLine("line1 has {0} roots.", _
                roots.Length)
            Console.WriteLine("Value of root = {0}", roots(0))

            Console.Write("Press Enter key to exit...")
            Console.ReadLine()

        End Sub

    End Module

End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -