www.pudn.com > vb.net_CAD.rar > Position.vb, change:2003-10-10,size:2133b


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