1 #Region "Microsoft.VisualBasic::103acdb6fe820deeb5c59afeec50e77a, Microsoft.VisualBasic.Core\Extensions\Image\Math\Models\PolarPoint.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Class PolarPoint
35     
36     '         Properties: Angle, Point, Radius
37     
38     '         FunctionToString
39     
40     
41     ' /********************************************************************************/
42
43 #End Region
44
45 Imports System.Drawing
46 Imports System.Runtime.CompilerServices
47 Imports Microsoft.VisualBasic.Math
48
49 Namespace Imaging.Math2D
50
51     ''' <summary>
52     ''' 极坐标点
53     ''' </summary>
54     Public Class PolarPoint
55
56         Public Property Radius As Double
57         ''' <summary>
58         ''' Unit in degree.(单位为度)
59         ''' </summary>
60         ''' <returns></returns>
61         Public Property Angle As Single
62
63         ''' <summary>
64         ''' 与这个极坐标点等价的笛卡尔直角坐标系上面的坐标点
65         ''' </summary>
66         ''' <returns></returns>
67         Public ReadOnly Property Point As PointF
68             <MethodImpl(MethodImplOptions.AggressiveInlining)>
69             Get
70                 Return (Radius, Angle).ToCartesianPoint
71             End Get
72         End Property
73
74         ''' <summary>
75         ''' 显示这个极坐标点
76         ''' </summary>
77         ''' <returns></returns>
78         Public Overrides Function ToString() As String
79             Return $"({Radius}, {Angle}°)"
80         End Function
81
82         Public Shared Widening Operator CType(polar As (radius#, angle!)) As PolarPoint
83             Return New PolarPoint With {
84                 .Angle = polar.angle,
85                 .Radius = polar.radius
86             }
87         End Operator
88     End Class
89 End Namespace