This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
development_javascript_Math.html
276 lines (214 loc) · 6.17 KB
/
development_javascript_Math.html
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobile Widgets</title>
<link rel="stylesheet" href="style/style.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/StructureElts.js"></script>
<script type="text/javascript" src="js/Structure.js"></script>
<script type="text/javascript" src="js/DocElements.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
idCurrentPage = "development_javascript_Math";
beginPage();
//-->
</script>
<h1 class="title">Math Javascript library</h1>
<script type="text/javascript">
<!--
addIndex();
//-->
</script>
<script type="text/javascript">addTitle("Description", 1);</script>
<p>
The Math class provides to compute numbers. It returns float type. It takes 32
bits : 16 bits for integer part and 16 bits for decimal parts.<br/>
So, we cannot go up to the number 32768. If you need a wider range of number,
you can use the <b>d-methods</b> (for double).
</p>
<br/>
<script type="text/javascript">addTitle("Methods", 1);</script>
<p>
<b>float cos (float v)</b>:<br/>
Returns the cosinus value of v (in radians)
</p>
<p>
<b>float sin (float v)</b>:<br/>
Returns the sinus value of v (in radians)
</p>
<p>
<b>float floor (float v)</b>:<br/>
Returns the closest smaller integer of the param
</p>
<p>
<b>float ceil (float v)</b>:<br/>
Returns the closest bigger integer of the param
</p>
<p>
<b>float sqrt (float v)</b>:<br/>
Returns the square root of the parameter
</p>
<p>
<b>float rand (float v)</b>:<br/>
Returns a random number between 0 and 1
</p>
<p>
<b>float abs (float v)</b>:<br/>
Returns the positive version of the parameter
</p>
<p>
<b>float acos (float v)</b>:<br/>
Returns the arc cosinus of the parameter
</p>
<p>
<b>float asin (float v)</b>:<br/>
Returns the arc sinus of the parameter
</p>
<p>
<b>float atan (float v)</b>:<br/>
Returns the arc tangent of the parameter
</p>
<br/>
<script type="text/javascript">addTitle("Constants", 1);</script>
<p>
<b>PI</b>:<br/>
The constant value for PI (3.141592)
</p>
<p>
<b>E</b>:<br/>
The constant value for E (2.71828182)
</p>
<br/>
<script type="text/javascript">addTitle("Examples", 1);</script>
<textarea wrap="off" readonly="readonly" rows="10" cols="80">
function test () {
Browser.print ('PI: '+ Math.PI); // Displays PI: 3.141592
Browser.print ('E: '+ Math.E); // Displays E: 2.71828182
}
function test2() {
var HA = Math.acos(String.toFloat(HAarg));
var cos2l0 = Math.cos(d_l0rad);
var sin2l0 = Math.sin(d_l0rad);
var result = Math.dadd('999999.5','0.51'); // result is a string with the value of '1000000.1'
}
</textarea>
<br/>
<script type="text/javascript">addTitle("D-Methods", 1);</script>
<p>
Redefines previous function for double type. Double type is not supported by
Memo so it uses string type instead. It enable to have better range and precision
than FixFloat.
</p>
<p>
<b>String dadd(String d1, Stringd2)</b>:<br/>
Returns the addition of the double values contained in Strings
</p>
<p>
<b>String dsub(String d1, Stringd2)</b>:<br/>
Returns the subtraction of the double values contained in Strings
</p>
<p>
<b>String dmul(String d1, Stringd2)</b>:<br/>
Returns the multiplication of the double values contained in Strings
</p>
<p>
<b>String ddiv(String d1, Stringd2)</b>:<br/>
Returns the division of the double values contained in Strings
</p>
<p>
<b>String dsin(String d1)</b>:<br/>
Returns the sinus of the double value contained in String
</p>
<p>
<b>String dasin(String d1)</b>:<br/>
Returns the arc sinus of the double value contained in String
</p>
<p>
<b>String dcos(String d1)</b>:<br/>
Returns the cosinus of the double value contained in String
</p>
<p>
<b>String dacos(String d1)</b>:<br/>
Returns the arc cosinus of the double value contained in String
</p>
<p>
<b>String dtan(String d1)</b>:<br/>
Returns the tangent of the double value contained in String
</p>
<p>
<b>String datan(String d1)</b>:<br/>
Returns the arc tangent of the double value contained in String
</p>
<p>
<b>String datan2(String d1,String d2)</b>:<br/>
Returns the arc tangent 2 of the double values contained in Strings
</p>
<p>
<b>String dfloor(String d1)</b>:<br/>
Returns the closest smaller integer of the param
</p>
<p>
<b>boolean dsup(String d1,String d2)</b>:<br/>
Returns the true if value of d1 is greater than the value of d2, else false
</p>
<p>
<b>boolean dsupeq(String d1,String d2)</b>:<br/>
Returns the true if value of d1 is greater or equal than the value of d2, else false
</p>
<p>
<b>boolean dinf(String d1,String d2)</b>:<br/>
Returns the true if value of d1 is smaller than the value of d2, else false
</p>
<p>
<b>boolean dinfeq(String d1,String d2)</b>:<br/>
Returns the true if value of d1 is smaller or equal than the value of d2, else false
</p>
<p>
<b>String dabs(String d1)</b>:<br/>
Returns the positive version of the parameter
</p>
<p>
<b>String dlog(String d1)</b>:<br/>
Returns the logarithm of the parameter.<br/>
<b>Since 1.4.8</b>
</p>
<br/>
<script type="text/javascript">addTitle("Examples", 1);</script>
<textarea wrap="off" readonly="readonly" rows="15" cols="80">
function calcGeomMeanLongSun(t) {
// var L0 = 280.46646 + t * (36000.76983 + t*(0.0003032))
var L0 = Math.dadd('280.46646', Math.dmul( t, Math.dadd( '36000.76983', Math.dmul( t, '0.0003032'))));
while( Math.dsup( L0 , '360') ) {
L0 = Math.dsub( L0, '360');
}
while( Math.dinf( L0 , '0') ) {
L0 = Math.dadd( L0, '360');
}
return L0; // in degrees
}
function test3() {
var alpha = Math.dfloor( Math.ddiv( Math.dsub(z,'1867216.25'), '36524.25'));
var result = Math.dadd('999999.5','0.51'); // result is a string with the value of '1000000.1'
var E = Math.dfloor(Math.ddiv(Math.dsub(B,D),'30.6001'));
var month = String.toInt(E);
var mrad = String.toFloat(result);
}
</textarea>
<br/>
<script type="text/javascript">
<!--
addBackPageNavigator('widgets_development_javascript_ref', '');
//-->
</script>
<script type="text/javascript">
<!--
endPage();
//-->
</script>
</body>
</html>