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

📄 position.vb

📁 苏金明编写的《用VB.NET和VC#.NET开发交互式CAD系统》一书的源代码
💻 VB
字号:
Imports System.Math

Public Class Position

    Private m_x, m_y As Single
    Private m_ID As Integer

    Public Property x() As Single
        Get
            Return m_x
        End Get
        Set(ByVal newValue As Single)
            m_x = newValue
        End Set
    End Property

    Public Property y() As Single
        Get
            Return m_y
        End Get
        Set(ByVal newValue As Single)
            m_y = newValue
        End Set
    End Property

    Public ReadOnly Property Disto() As Single
        Get
            Return Sqrt(m_x * m_x + m_y * m_y)
        End Get
    End Property

    Public Property ID() As Integer
        Get
            Return m_ID
        End Get
        Set(ByVal newValue As Integer)
            m_ID = newValue
        End Set
    End Property

    Public Function GetAngle() As Single
        '坐标原点为Org,全局变量
        Dim org As New Position(0, 0)
        Dim sita, tanSita, subx As Single
        subx = Abs(m_x - org.x)
        If org.x = m_x Then subx = 0.0001
        tanSita = (Abs(m_x - org.x)) / subx
        sita = Atan(tanSita)
        If m_x >= org.x And m_y <= org.y Then
            Return sita
        ElseIf m_x <= org.x And m_y >= org.y Then
            Return (3.1416 - sita)
        ElseIf m_x <= org.x And m_y >= org.y Then
            Return (3.1416 + sita)
        ElseIf m_x >= org.x And m_y >= org.y Then
            Return (2 * 3.1416 - sita)
        End If
    End Function

    Public Sub New()
    End Sub

    Public Sub New(ByVal xx As Single, ByVal yy As Single)
        m_x = xx
        m_y = yy
    End Sub

    Public Sub New(ByVal aPos As Position)
        With aPos
            m_x = .x
            m_y = .y
        End With
    End Sub

    Public Sub Move(ByVal deltaX As Single)
        m_x += deltaX
    End Sub

    Public Sub Move(ByVal deltaX As Single, ByVal deltaY As Single)
        m_x += deltaX
        m_y += deltaY
    End Sub

    Public Sub MeTest()
        Console.WriteLine("坐标为:{0},{1}", Me.x, Me.y)
    End Sub

End Class

⌨️ 快捷键说明

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