
Function CompassRose ( V As Double ) As Double
	
	CompassRose =  ( Frac ( V ) * 16 ) Mod 16 : Exit Function

End Function
	
Sub CompassDigital ( V As Double, ByRef X As Double, ByRef Y As Double  )

	Dim As Double F = CompassRose ( Frac ( V ) ) / 16
	
	X = 320 + Sin ( 2 * F * Pi ) * 64
	Y = 240 + -Cos ( 2 * F * Pi ) * 64
			
End Sub

Function VertexConvert Overload ( VI As VertexIntType ) As VertexType

	VertexConvert =  VertexFunnel ( CDbl ( VI.XYZ ( Vec.X ) ), CDbl ( VI.XYZ ( Vec.Y ) ), CDbl ( VI.XYZ ( Vec.Z ) ) ) : Exit Function

End Function
	
Function VertexConvert Overload ( VF As VertexType ) As VertexIntType

	VertexConvert =  VertexFunnel ( CLng ( VF.XYZ ( Vec.X ) ), CLng ( VF.XYZ ( Vec.Y ) ), CLng ( VF.XYZ ( Vec.Z ) ) ) : Exit Function

End Function

Function VertexFunnel Overload ( X As Double = 0.0, Y As Double = 0.0, Z As Double = 0.0 ) As VertexType
	
	Dim Vertex As VertexType
	
	Vertex.XYZ ( Vec.X ) = X
	Vertex.XYZ ( Vec.Y ) = Y
	Vertex.XYZ ( Vec.Z ) = Z
	
	VertexFunnel =  Vertex : Exit Function
	
End Function

Function VertexFunnel Overload ( X As Long = 0, Y As Long = 0, Z As Long = 0 ) As VertexIntType
	
	Dim Vertex As VertexIntType
	
	Vertex.XYZ ( Vec.X ) = X
	Vertex.XYZ ( Vec.Y ) = Y
	Vertex.XYZ ( Vec.Z ) = Z
	
	VertexFunnel =  Vertex : Exit Function

End Function

Function VectorToDecimal_II ( X As Double, Y As Double, X2 As Double, Y2 As Double ) As Double
	VectorToDecimal_II =  VectorToDecimal_V ( VertexFunnel ( X - X2, Y - Y2 ) ) : Exit Function
End Function
	
Function VectorToDecimal ( X As Double, Y As Double ) As Double
		
	Dim As Double V = 0, D = atan2( Y, X ) / Pi
		
	Select Case Sgn ( Y )
	Case -1

		V =  - ( D / 2 )

	Case 0, 1

		V = 1 - ( D / 2 )

	End Select
		
	V = 1 - V
	V = V + .75
	V = Frac ( V )
	
	VectorToDecimal =  V : Exit Function
	
End Function

Function VectorToRadius ( X As Double, Y As Double ) As Double
		
	Dim As Double V = ( X ^ 2 + Y ^ 2 )
	If V = 0 Then
		VectorToRadius = 0 : Exit Function
	Else
		VectorToRadius = V : Exit Function
	End If
		
End Function

Function VectorToDecimal_V ( V As VertexType ) As Double
	VectorToDecimal_V = VectorToDecimal ( V.XYZ ( Vec.X ), V.XYZ ( Vec.Y ) ) : Exit Function
End Function

Function VectorToRadius_V ( V As VertexType ) As Double
	VectorToRadius_V = VectorToRadius ( V.XYZ ( Vec.X ), V.XYZ ( Vec.Y ) ) : Exit Function
End Function
