112 lines
3.1 KiB
VB.net
112 lines
3.1 KiB
VB.net
#Region "Microsoft.VisualBasic::69ceea95906ed80e045120aa58ab0bf6, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\Vector2D.vb"
|
|
|
|
' Author:
|
|
'
|
|
' asuka (amethyst.asuka@gcmodeller.org)
|
|
' xie (genetics@smrucc.org)
|
|
' xieguigang (xie.guigang@live.com)
|
|
'
|
|
' Copyright (c) 2018 GPL3 Licensed
|
|
'
|
|
'
|
|
' GNU GENERAL PUBLIC LICENSE (GPL3)
|
|
'
|
|
'
|
|
' This program is free software: you can redistribute it and/or modify
|
|
' it under the terms of the GNU General Public License as published by
|
|
' the Free Software Foundation, either version 3 of the License, or
|
|
' (at your option) any later version.
|
|
'
|
|
' This program is distributed in the hope that it will be useful,
|
|
' but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
' GNU General Public License for more details.
|
|
'
|
|
' You should have received a copy of the GNU General Public License
|
|
' along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
' /********************************************************************************/
|
|
|
|
' Summaries:
|
|
|
|
' Class Vector2D
|
|
'
|
|
' Properties: Length
|
|
'
|
|
' Constructor: (+3 Overloads) Sub New
|
|
' Operators: -, (+2 Overloads) *
|
|
'
|
|
'
|
|
' /********************************************************************************/
|
|
|
|
#End Region
|
|
|
|
Namespace Imaging.Math2D
|
|
|
|
''' <summary>
|
|
''' <see cref="Drawing.PointF"/>
|
|
''' </summary>
|
|
Public Class Vector2D
|
|
|
|
Public x As Double
|
|
Public y As Double
|
|
|
|
Public ReadOnly Property Length As Double
|
|
Get
|
|
Return Math.Sqrt(x ^ 2 + y ^ 2)
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub New()
|
|
Me.New(0.0, 0.0)
|
|
End Sub
|
|
|
|
Public Sub New(x As Double, y As Double)
|
|
Me.x = x
|
|
Me.y = y
|
|
End Sub
|
|
|
|
Public Sub New(x As Integer, y As Integer)
|
|
Me.x = x
|
|
Me.y = y
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' reverse
|
|
''' </summary>
|
|
''' <param name="v"></param>
|
|
''' <returns></returns>
|
|
Public Shared Operator -(v As Vector2D) As Vector2D
|
|
With v
|
|
Return New Vector2D(- .x, - .y)
|
|
End With
|
|
End Operator
|
|
|
|
''' <summary>
|
|
''' multiple
|
|
''' </summary>
|
|
''' <param name="scale#"></param>
|
|
''' <param name="v"></param>
|
|
''' <returns></returns>
|
|
Public Shared Operator *(scale#, v As Vector2D) As Vector2D
|
|
With v
|
|
Return New Vector2D(scale * .x, scale * .y)
|
|
End With
|
|
End Operator
|
|
|
|
''' <summary>
|
|
''' multiple
|
|
''' </summary>
|
|
''' <param name="v"></param>
|
|
''' <param name="scale#"></param>
|
|
''' <returns></returns>
|
|
Public Shared Operator *(v As Vector2D, scale#) As Vector2D
|
|
With v
|
|
Return New Vector2D(scale * .x, scale * .y)
|
|
End With
|
|
End Operator
|
|
End Class
|
|
End Namespace
|