-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdlFuncTrigonometricas.bas
177 lines (170 loc) · 4.24 KB
/
mdlFuncTrigonometricas.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Attribute VB_Name = "mdlFuncTrigonometricas"
'**************************************
'Name: Trigonometria
'Descripción: Simplifica el uso de las funciones deben comunes trigonométricas (seno, coseno, tangente)
'och Dess funciones inversas (arcoseno, arcocoseno, arcotangente).
'Los nativos VB funciones trigonométricas Exigir la conversión de dos grados de radiancia o viceversa.
'Funciones Dessa Elimina la necesidad att.
Option Explicit
Public Function Sine(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Degree Input Radian Output
On Error GoTo PROC_ERR
Dim dblPi As Double
Dim dblRadian As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert degrees to radians,
'multiply degrees by Pi / 180.
dblRadian = dblPi / 180
p_dblVal = Val(p_dblVal * dblRadian)
Sine = Sin(p_dblVal)
PROC_EXIT:
Exit Function
PROC_ERR:
Sine = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function
Public Function Cosine(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Degree Input Radian Output
On Error GoTo PROC_ERR
Dim dblPi As Double
Dim dblRadian As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert degrees to radians,
'multiply degrees by Pi / 180.
dblRadian = dblPi / 180
p_dblVal = Val(p_dblVal * dblRadian)
Cosine = Cos(p_dblVal)
PROC_EXIT:
Exit Function
PROC_ERR:
Cosine = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function
Public Function Tangent(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Degree Input Radian Output
On Error GoTo PROC_ERR
Dim dblPi As Double
Dim dblRadian As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert degrees to radians,
'multiply degrees by Pi / 180.
dblRadian = dblPi / 180
p_dblVal = Val(p_dblVal * dblRadian)
Tangent = Tan(p_dblVal)
PROC_EXIT:
Exit Function
PROC_ERR:
Tangent = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function
Public Function ArcSine(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Radian Input Degree Output
On Error GoTo PROC_ERR
Dim dblSqr As Double
Dim dblPi As Double
Dim dblDegree As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert radians to degrees,
' multiply radians by 180/pi.
dblDegree = 180 / dblPi
p_dblVal = Val(p_dblVal)
dblSqr = Sqr(-p_dblVal * p_dblVal + 1)
' xx Prevent division by Zero error
If dblSqr = 0 Then
dblSqr = 1E-30
End If
ArcSine = Atn(p_dblVal / dblSqr) * dblDegree
PROC_EXIT:
Exit Function
PROC_ERR:
ArcSine = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function
Public Function ArcCosine(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Radian Input Degree Output
On Error GoTo PROC_ERR
Dim dblSqr As Double
Dim dblPi As Double
Dim dblDegree As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert radians to degrees,
' multiply radians by 180/pi.
dblDegree = 180 / dblPi
p_dblVal = Val(p_dblVal)
dblSqr = Sqr(-p_dblVal * p_dblVal + 1)
' xx Prevent division by Zero error
If dblSqr = 0 Then
dblSqr = 1E-30
End If
ArcCosine = (Atn(-p_dblVal / dblSqr) + 2 * Atn(1)) * dblDegree
PROC_EXIT:
Exit Function
PROC_ERR:
ArcCosine = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function
Public Function ArcTangent(p_dblVal As Double) As Double
' Comments :
' Parameters: p_dblVal -
' Returns: Double -
' Modified :
'
' -------------------------
'Radian Input Degree Output
On Error GoTo PROC_ERR
Dim dblPi As Double
Dim dblDegree As Double
' xx Calculate the value of Pi.
dblPi = 4 * Atn(1)
' xx To convert radians to degrees,
' multiply radians by 180/pi.
dblDegree = 180 / dblPi
p_dblVal = Val(p_dblVal)
ArcTangent = Atn(p_dblVal) * dblDegree
PROC_EXIT:
Exit Function
PROC_ERR:
ArcTangent = 0
MsgBox Err.Description, vbExclamation
Resume PROC_EXIT
End Function