1046
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
303
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2008 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libjavascript' }"
|
|
15 |
|
893
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
303
|
18 |
Object subclass:#Math
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Languages-JavaScript-Framework'
|
|
23 |
!
|
|
24 |
|
|
25 |
!Math class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2008 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
documentation
|
|
42 |
"
|
|
43 |
Simulates the javascript Math protocol
|
|
44 |
|
|
45 |
allows for
|
|
46 |
Math.sin(foo)
|
|
47 |
or
|
|
48 |
Math.atan2(a,b)
|
|
49 |
"
|
|
50 |
! !
|
|
51 |
|
|
52 |
!Math class methodsFor:'constants'!
|
|
53 |
|
|
54 |
E
|
|
55 |
"Eulers constant, the base of the natural logarithm; approx 2.718"
|
|
56 |
|
|
57 |
^ Float e
|
|
58 |
|
|
59 |
"
|
|
60 |
JavaScriptParser
|
|
61 |
evaluate:'Math.E;'
|
|
62 |
"
|
|
63 |
!
|
|
64 |
|
|
65 |
LN10
|
|
66 |
"natural logarithm of 10, approx 2.302"
|
|
67 |
|
|
68 |
^ 10 ln
|
|
69 |
|
|
70 |
"
|
|
71 |
JavaScriptParser
|
|
72 |
evaluate:'Math.LN10;'
|
|
73 |
"
|
|
74 |
!
|
|
75 |
|
|
76 |
LN2
|
|
77 |
"natural logarithm of 2, approx 0.693"
|
|
78 |
|
|
79 |
^ Float ln2
|
|
80 |
|
|
81 |
"
|
|
82 |
JavaScriptParser
|
|
83 |
evaluate:'Math.LN2;'
|
|
84 |
"
|
|
85 |
!
|
|
86 |
|
|
87 |
LOG10E
|
|
88 |
"base 10 logarithm of E; approx. 0.434"
|
|
89 |
|
|
90 |
^ Float e log
|
|
91 |
|
|
92 |
"
|
|
93 |
JavaScriptParser
|
|
94 |
evaluate:'Math.LOG10E;'
|
|
95 |
"
|
|
96 |
!
|
|
97 |
|
|
98 |
LOG2E
|
|
99 |
"base2 logarithm of E; approx. 1.442"
|
|
100 |
|
|
101 |
^ Float e log / 2 log
|
|
102 |
|
|
103 |
"
|
|
104 |
JavaScriptParser
|
|
105 |
evaluate:'Math.LOG2E;'
|
|
106 |
"
|
|
107 |
!
|
|
108 |
|
893
|
109 |
NEGATIVE_INFINITY
|
|
110 |
"-inf"
|
|
111 |
|
|
112 |
^ Infinity negative
|
|
113 |
|
|
114 |
"
|
|
115 |
JavaScriptParser evaluate:'Math.NEGATIVE_INFINITY;'
|
|
116 |
"
|
|
117 |
!
|
|
118 |
|
|
119 |
NaN
|
|
120 |
"not a number"
|
|
121 |
|
|
122 |
^ Float NaN
|
|
123 |
|
|
124 |
"
|
|
125 |
JavaScriptParser evaluate:'Math.NaN;'
|
|
126 |
"
|
|
127 |
!
|
|
128 |
|
303
|
129 |
PI
|
|
130 |
"pi; approx 3.14159"
|
|
131 |
|
|
132 |
^ Float pi
|
|
133 |
|
|
134 |
"
|
|
135 |
JavaScriptParser
|
|
136 |
evaluate:'Math.PI;'
|
|
137 |
"
|
|
138 |
!
|
|
139 |
|
893
|
140 |
POSITIVE_INFINITY
|
|
141 |
"+Inf"
|
|
142 |
|
|
143 |
^ Infinity positive
|
|
144 |
|
|
145 |
"
|
|
146 |
JavaScriptParser evaluate:'Math.POSITIVE_INFINITY;'
|
|
147 |
"
|
|
148 |
!
|
|
149 |
|
303
|
150 |
SQRT1_2
|
|
151 |
"square root of 1/2; approx 0.707"
|
|
152 |
|
|
153 |
^ 1 / Float sqrt2
|
|
154 |
|
|
155 |
"
|
|
156 |
JavaScriptParser
|
|
157 |
evaluate:'Math.SQRT1_2;'
|
|
158 |
"
|
|
159 |
!
|
|
160 |
|
|
161 |
SQRT2
|
|
162 |
"square root of 2; approx. 1.414"
|
|
163 |
|
|
164 |
^ Float sqrt2
|
|
165 |
|
|
166 |
"
|
|
167 |
JavaScriptParser
|
|
168 |
evaluate:'Math.SQRT2;'
|
|
169 |
"
|
|
170 |
! !
|
|
171 |
|
|
172 |
!Math class methodsFor:'min & max'!
|
|
173 |
|
|
174 |
max
|
1046
|
175 |
"returns the largest of 0 to 6 args"
|
303
|
176 |
|
|
177 |
^ 0
|
|
178 |
|
|
179 |
"
|
|
180 |
JavaScriptParser
|
|
181 |
evaluate:'Math.max();'
|
314
|
182 |
|
303
|
183 |
JavaScriptParser
|
|
184 |
evaluate:'Math.max(1);'
|
314
|
185 |
|
303
|
186 |
JavaScriptParser
|
|
187 |
evaluate:'Math.max(10,2);'
|
314
|
188 |
|
303
|
189 |
JavaScriptParser
|
|
190 |
evaluate:'Math.max(10,5,20);'
|
|
191 |
"
|
1046
|
192 |
|
|
193 |
"Modified (comment): / 15-12-2018 / 09:49:52 / Claus Gittinger"
|
303
|
194 |
!
|
|
195 |
|
|
196 |
max:n1
|
1046
|
197 |
"returns the largest of 0 to 6 args"
|
303
|
198 |
|
|
199 |
^ n1
|
|
200 |
|
|
201 |
"
|
|
202 |
JavaScriptParser
|
|
203 |
evaluate:'Math.max();'
|
|
204 |
JavaScriptParser
|
|
205 |
evaluate:'Math.max(1);'
|
|
206 |
JavaScriptParser
|
|
207 |
evaluate:'Math.max(10,2);'
|
|
208 |
JavaScriptParser
|
|
209 |
evaluate:'Math.max(10,5,20);'
|
|
210 |
"
|
1046
|
211 |
|
|
212 |
"Modified (comment): / 15-12-2018 / 09:49:56 / Claus Gittinger"
|
303
|
213 |
!
|
|
214 |
|
|
215 |
max:n1 _:n2
|
1046
|
216 |
"returns the largest of 0 to 6 args"
|
303
|
217 |
|
|
218 |
^ n1 max:n2
|
|
219 |
|
|
220 |
"
|
|
221 |
JavaScriptParser
|
|
222 |
evaluate:'Math.max();'
|
|
223 |
JavaScriptParser
|
|
224 |
evaluate:'Math.max(1);'
|
|
225 |
JavaScriptParser
|
|
226 |
evaluate:'Math.max(10,2);'
|
|
227 |
JavaScriptParser
|
|
228 |
evaluate:'Math.max(10,5,20);'
|
|
229 |
"
|
1046
|
230 |
|
|
231 |
"Modified (comment): / 15-12-2018 / 09:49:58 / Claus Gittinger"
|
303
|
232 |
!
|
|
233 |
|
|
234 |
max:n1 _:n2 _:n3
|
1046
|
235 |
"returns the largest of 0 to 6 args"
|
303
|
236 |
|
|
237 |
^ (n1 max:n2) max:n3
|
|
238 |
|
|
239 |
"
|
|
240 |
JavaScriptParser
|
|
241 |
evaluate:'Math.max();'
|
|
242 |
JavaScriptParser
|
|
243 |
evaluate:'Math.max(1);'
|
|
244 |
JavaScriptParser
|
|
245 |
evaluate:'Math.max(10,2);'
|
|
246 |
JavaScriptParser
|
|
247 |
evaluate:'Math.max(10,5,20);'
|
|
248 |
"
|
1046
|
249 |
|
|
250 |
"Modified (comment): / 15-12-2018 / 09:50:01 / Claus Gittinger"
|
303
|
251 |
!
|
|
252 |
|
|
253 |
max:n1 _:n2 _:n3 _:n4
|
1046
|
254 |
"returns the largest of 0 to 6 args"
|
303
|
255 |
|
|
256 |
^ (n1 max:n2) max:(n3 max:n4)
|
|
257 |
|
|
258 |
"
|
|
259 |
JavaScriptParser
|
|
260 |
evaluate:'Math.max(10,5,20,3);'
|
|
261 |
"
|
1046
|
262 |
|
|
263 |
"Modified (comment): / 15-12-2018 / 09:50:04 / Claus Gittinger"
|
303
|
264 |
!
|
|
265 |
|
|
266 |
max:n1 _:n2 _:n3 _:n4 _:n5
|
1046
|
267 |
"returns the largest of 0 to 6 args"
|
303
|
268 |
|
|
269 |
^ ((n1 max:n2) max:(n3 max:n4)) max:n5
|
|
270 |
|
|
271 |
"
|
|
272 |
JavaScriptParser
|
|
273 |
evaluate:'Math.max(10,5,20,3,17);'
|
|
274 |
"
|
1046
|
275 |
|
|
276 |
"Modified (comment): / 15-12-2018 / 09:50:06 / Claus Gittinger"
|
|
277 |
!
|
|
278 |
|
|
279 |
max:n1 _:n2 _:n3 _:n4 _:n5 _:n6
|
|
280 |
"returns the largest of 0 to 6 args"
|
|
281 |
|
|
282 |
^ ((n1 max:n2) max:(n3 max:n4)) max:(n5 max:n6)
|
|
283 |
|
|
284 |
"
|
|
285 |
JavaScriptParser evaluate:'Math.max(10,5,20,3,17,1);'
|
|
286 |
"
|
|
287 |
|
|
288 |
"Created: / 15-12-2018 / 09:47:27 / Claus Gittinger"
|
303
|
289 |
!
|
|
290 |
|
|
291 |
min
|
1046
|
292 |
"returns the smallest of 0 to 6 args"
|
303
|
293 |
|
|
294 |
^ 0
|
|
295 |
|
|
296 |
"
|
|
297 |
JavaScriptParser
|
|
298 |
evaluate:'Math.min();'
|
|
299 |
JavaScriptParser
|
|
300 |
evaluate:'Math.min(1);'
|
|
301 |
JavaScriptParser
|
|
302 |
evaluate:'Math.min(10,2);'
|
|
303 |
JavaScriptParser
|
|
304 |
evaluate:'Math.min(10,5,20);'
|
|
305 |
"
|
1046
|
306 |
|
|
307 |
"Modified (comment): / 15-12-2018 / 09:49:36 / Claus Gittinger"
|
303
|
308 |
!
|
|
309 |
|
|
310 |
min:n1
|
1046
|
311 |
"returns the smallest of 0 to 6 args"
|
303
|
312 |
|
|
313 |
^ n1
|
|
314 |
|
|
315 |
"
|
|
316 |
JavaScriptParser
|
|
317 |
evaluate:'Math.min();'
|
|
318 |
JavaScriptParser
|
|
319 |
evaluate:'Math.min(1);'
|
|
320 |
JavaScriptParser
|
|
321 |
evaluate:'Math.min(10,2);'
|
|
322 |
JavaScriptParser
|
|
323 |
evaluate:'Math.min(10,5,20);'
|
|
324 |
"
|
1046
|
325 |
|
|
326 |
"Modified (comment): / 15-12-2018 / 09:50:17 / Claus Gittinger"
|
303
|
327 |
!
|
|
328 |
|
|
329 |
min:n1 _:n2
|
1046
|
330 |
"returns the smallest of 0 to 6 args"
|
303
|
331 |
|
|
332 |
^ n1 min:n2
|
|
333 |
|
|
334 |
"
|
|
335 |
JavaScriptParser
|
|
336 |
evaluate:'Math.min();'
|
|
337 |
JavaScriptParser
|
|
338 |
evaluate:'Math.min(1);'
|
|
339 |
JavaScriptParser
|
|
340 |
evaluate:'Math.min(10,2);'
|
|
341 |
JavaScriptParser
|
|
342 |
evaluate:'Math.min(10,5,20);'
|
|
343 |
"
|
1046
|
344 |
|
|
345 |
"Modified (comment): / 15-12-2018 / 09:50:19 / Claus Gittinger"
|
303
|
346 |
!
|
|
347 |
|
|
348 |
min:n1 _:n2 _:n3
|
1046
|
349 |
"returns the smallest of 0 to 6 args"
|
303
|
350 |
|
|
351 |
^ (n1 min:n2) min:n3
|
|
352 |
|
|
353 |
"
|
|
354 |
JavaScriptParser
|
|
355 |
evaluate:'Math.min();'
|
|
356 |
JavaScriptParser
|
|
357 |
evaluate:'Math.min(1);'
|
|
358 |
JavaScriptParser
|
|
359 |
evaluate:'Math.min(10,2);'
|
|
360 |
JavaScriptParser
|
|
361 |
evaluate:'Math.min(10,5,20);'
|
|
362 |
"
|
1046
|
363 |
|
|
364 |
"Modified (comment): / 15-12-2018 / 09:50:22 / Claus Gittinger"
|
303
|
365 |
!
|
|
366 |
|
|
367 |
min:n1 _:n2 _:n3 _:n4
|
1046
|
368 |
"returns the smallest of 0 to 6 args"
|
303
|
369 |
|
|
370 |
^ (n1 min:n2) min:(n3 min:n4)
|
|
371 |
|
|
372 |
"
|
|
373 |
JavaScriptParser
|
|
374 |
evaluate:'Math.min(10,5,20,3);'
|
|
375 |
"
|
1046
|
376 |
|
|
377 |
"Modified (comment): / 15-12-2018 / 09:50:24 / Claus Gittinger"
|
303
|
378 |
!
|
|
379 |
|
|
380 |
min:n1 _:n2 _:n3 _:n4 _:n5
|
1046
|
381 |
"returns the smallest of 0 to 6 args"
|
303
|
382 |
|
|
383 |
^ ((n1 min:n2) min:(n3 min:n4)) min:n5
|
|
384 |
|
|
385 |
"
|
|
386 |
JavaScriptParser
|
|
387 |
evaluate:'Math.min(10,5,20,3,17);'
|
|
388 |
"
|
1046
|
389 |
|
|
390 |
"Modified (comment): / 15-12-2018 / 09:50:27 / Claus Gittinger"
|
|
391 |
!
|
|
392 |
|
|
393 |
min:n1 _:n2 _:n3 _:n4 _:n5 _:n6
|
|
394 |
"returns the smallest of 0 to 6 args"
|
|
395 |
|
|
396 |
^ ((n1 min:n2) min:(n3 min:n4)) min:(n5 min:n6)
|
|
397 |
|
|
398 |
"
|
|
399 |
JavaScriptParser evaluate:'Math.min(10,5,20,3,17,1);'
|
|
400 |
"
|
|
401 |
|
|
402 |
"Created: / 15-12-2018 / 09:46:45 / Claus Gittinger"
|
303
|
403 |
! !
|
|
404 |
|
|
405 |
!Math class methodsFor:'misc math'!
|
|
406 |
|
|
407 |
abs:aNumber
|
|
408 |
"returns the absolute value of a number"
|
|
409 |
|
|
410 |
^ aNumber abs
|
|
411 |
|
|
412 |
"
|
893
|
413 |
JavaScriptParser evaluate:'Math.abs(-10);'
|
303
|
414 |
"
|
540
|
415 |
|
|
416 |
"Modified (comment): / 21-08-2012 / 19:54:00 / cg"
|
303
|
417 |
!
|
|
418 |
|
305
|
419 |
binco:n _:k
|
|
420 |
"returns the binomialcoefficient C(n,k) (n over k, choose k from n)"
|
|
421 |
|
|
422 |
^ n binomialCoefficient:k
|
|
423 |
|
|
424 |
" Lotto:
|
|
425 |
JavaScriptParser
|
|
426 |
evaluate:'Math.binco(49, 6);'
|
|
427 |
"
|
|
428 |
!
|
|
429 |
|
303
|
430 |
ceil:aNumber
|
|
431 |
"returns the smallest integer greater than or equal to aNumber"
|
|
432 |
|
|
433 |
^ aNumber ceiling
|
|
434 |
|
|
435 |
"
|
893
|
436 |
JavaScriptParser evaluate:'Math.ceil(9.5);'
|
303
|
437 |
"
|
|
438 |
!
|
|
439 |
|
|
440 |
exp:aNumber
|
|
441 |
"returns E^aNumber"
|
|
442 |
|
|
443 |
^ aNumber exp
|
|
444 |
|
|
445 |
"
|
893
|
446 |
JavaScriptParser evaluate:'Math.exp(1);'
|
303
|
447 |
|
|
448 |
JavaScriptParser
|
|
449 |
evaluate:'Math.log(Math.exp(1));'
|
|
450 |
"
|
|
451 |
!
|
|
452 |
|
305
|
453 |
fac:aNumber
|
|
454 |
"returns the factorial of aNumber"
|
|
455 |
|
|
456 |
^ aNumber factorial
|
|
457 |
|
|
458 |
"
|
|
459 |
JavaScriptParser
|
|
460 |
evaluate:'Math.fac(10);'
|
|
461 |
"
|
|
462 |
!
|
|
463 |
|
303
|
464 |
floor:aNumber
|
314
|
465 |
"returns the largest integer less than or equal to aNumber"
|
303
|
466 |
|
|
467 |
^ aNumber floor
|
|
468 |
|
|
469 |
"
|
893
|
470 |
JavaScriptParser evaluate:'Math.floor(9.5);'
|
303
|
471 |
"
|
|
472 |
!
|
|
473 |
|
305
|
474 |
gcd:a _:b
|
|
475 |
"returns the greatest common divisor of a and b"
|
|
476 |
|
|
477 |
^ a gcd:b
|
|
478 |
|
314
|
479 |
"
|
305
|
480 |
JavaScriptParser
|
|
481 |
evaluate:'Math.gcd(33, 6);'
|
|
482 |
"
|
|
483 |
!
|
|
484 |
|
1090
|
485 |
ln:aNumber
|
|
486 |
"returns the natural logarithm of aNumber."
|
|
487 |
|
|
488 |
^ aNumber ln
|
|
489 |
|
|
490 |
"
|
|
491 |
JavaScriptParser
|
|
492 |
evaluate:'Math.ln(10);'
|
|
493 |
|
|
494 |
JavaScriptParser
|
|
495 |
evaluate:'Math.exp(Math.ln(10));'
|
|
496 |
"
|
|
497 |
|
|
498 |
"Created: / 10-06-2019 / 17:11:37 / Claus Gittinger"
|
|
499 |
!
|
|
500 |
|
303
|
501 |
log10:aNumber
|
|
502 |
"returns the log base 10 of aNumber."
|
|
503 |
|
|
504 |
^ aNumber log10
|
|
505 |
|
|
506 |
"
|
|
507 |
JavaScriptParser
|
|
508 |
evaluate:'Math.log10(10);'
|
|
509 |
"
|
|
510 |
!
|
|
511 |
|
|
512 |
log:aNumber
|
|
513 |
"returns the log base E of aNumber.
|
|
514 |
ATTENTION:
|
|
515 |
JS log is a base E log
|
|
516 |
ST log is a base 10 log (use ln for base E)
|
|
517 |
in JS, better use log10 to make things explicit.
|
|
518 |
"
|
|
519 |
|
|
520 |
^ aNumber ln
|
|
521 |
|
|
522 |
"
|
893
|
523 |
JavaScriptParser evaluate:'Math.log(Math.exp(1));'
|
303
|
524 |
"
|
|
525 |
!
|
|
526 |
|
|
527 |
pow:base _:exp
|
|
528 |
"returns base^exp"
|
|
529 |
|
|
530 |
^ base raisedTo:exp
|
|
531 |
|
|
532 |
"
|
|
533 |
JavaScriptParser
|
|
534 |
evaluate:'Math.pow(10,2);'
|
|
535 |
"
|
|
536 |
!
|
|
537 |
|
|
538 |
random
|
|
539 |
"returns a pseudo random number between 0 and 1"
|
|
540 |
|
|
541 |
^ Random nextBetween:0.0 and:1.0
|
|
542 |
|
|
543 |
"
|
|
544 |
JavaScriptParser
|
314
|
545 |
evaluate:'Math.random();'
|
|
546 |
"
|
|
547 |
!
|
|
548 |
|
|
549 |
random:min _:max
|
|
550 |
"returns a pseudo random number between min and max"
|
|
551 |
|
|
552 |
^ Random nextBetween:min and:max
|
|
553 |
|
|
554 |
"
|
|
555 |
JavaScriptParser
|
|
556 |
evaluate:'Math.random(5, 7);'
|
|
557 |
"
|
|
558 |
!
|
|
559 |
|
|
560 |
randomInteger:min _:max
|
|
561 |
"returns a pseudo random number between min and max"
|
|
562 |
|
|
563 |
^ Random nextIntegerBetween:min and:max
|
|
564 |
|
|
565 |
"dice:
|
|
566 |
JavaScriptParser
|
|
567 |
evaluate:'Math.randomInteger(1, 6);'
|
303
|
568 |
"
|
|
569 |
!
|
|
570 |
|
|
571 |
round:aNumber
|
|
572 |
"returns the value of aNumber rounded to the nearest integer"
|
|
573 |
|
|
574 |
^ aNumber rounded
|
|
575 |
|
|
576 |
"
|
|
577 |
JavaScriptParser
|
314
|
578 |
evaluate:'Math.round(9.2);'
|
|
579 |
|
303
|
580 |
JavaScriptParser
|
|
581 |
evaluate:'Math.round(9.7);'
|
|
582 |
"
|
|
583 |
!
|
|
584 |
|
|
585 |
sqrt:aNumber
|
|
586 |
"returns the square root of aNumber"
|
|
587 |
|
|
588 |
^ aNumber sqrt
|
|
589 |
|
|
590 |
"
|
|
591 |
JavaScriptParser
|
|
592 |
evaluate:'Math.sqrt(2);'
|
|
593 |
"
|
|
594 |
! !
|
|
595 |
|
893
|
596 |
!Math class methodsFor:'queries'!
|
|
597 |
|
|
598 |
isUtilityClass
|
|
599 |
^ true
|
|
600 |
! !
|
|
601 |
|
303
|
602 |
!Math class methodsFor:'trigonometric'!
|
|
603 |
|
|
604 |
acos:aNumber
|
|
605 |
"returns the arccosine (in radians) of a number"
|
|
606 |
|
|
607 |
^ aNumber arcCos
|
|
608 |
|
|
609 |
"
|
893
|
610 |
JavaScriptParser evaluate:'Math.acos(1);'
|
303
|
611 |
"
|
|
612 |
!
|
|
613 |
|
|
614 |
asin:aNumber
|
|
615 |
"returns the arcsine (in radians) of a number"
|
|
616 |
|
|
617 |
^ aNumber arcSin
|
|
618 |
|
|
619 |
"
|
893
|
620 |
JavaScriptParser evaluate:'Math.asin(1);'
|
303
|
621 |
"
|
|
622 |
!
|
|
623 |
|
|
624 |
atan2:x _:y
|
|
625 |
"returns the arctangent of the quotient of its arguments (in radians)"
|
|
626 |
|
|
627 |
^ x arcTan2:y
|
|
628 |
|
|
629 |
"
|
893
|
630 |
JavaScriptParser evaluate:'Math.atan2(1,10);'
|
303
|
631 |
"
|
|
632 |
!
|
|
633 |
|
|
634 |
atan:aNumber
|
|
635 |
"returns the arctangent (in radians) of a number"
|
|
636 |
|
|
637 |
^ aNumber arcTan
|
893
|
638 |
|
|
639 |
"
|
|
640 |
JavaScriptParser evaluate:'Math.atan(1);'
|
|
641 |
"
|
303
|
642 |
!
|
|
643 |
|
|
644 |
cos:aNumber
|
|
645 |
"returns the cosine of a number (given in radians)"
|
|
646 |
|
|
647 |
^ aNumber cos
|
|
648 |
|
|
649 |
"
|
893
|
650 |
JavaScriptParser evaluate:'Math.cos(3.14159);'
|
303
|
651 |
"
|
|
652 |
!
|
|
653 |
|
961
|
654 |
degreesToRadians:aNumber
|
|
655 |
"converts degrees to radians"
|
|
656 |
|
|
657 |
^ aNumber degreesToRadians
|
|
658 |
|
|
659 |
"
|
|
660 |
JavaScriptParser evaluate:'Math.degreesToRadians(45);'
|
|
661 |
"
|
|
662 |
!
|
|
663 |
|
|
664 |
radiansToDegrees:aNumber
|
|
665 |
"converts radians to degrees"
|
|
666 |
|
|
667 |
^ aNumber radiansToDegrees
|
|
668 |
|
|
669 |
"
|
|
670 |
JavaScriptParser evaluate:'Math.radiansToDegrees(Math.degreesToRadians(45));'
|
|
671 |
"
|
|
672 |
!
|
|
673 |
|
303
|
674 |
sin:aNumber
|
|
675 |
"returns the sine of a number (given in radians)"
|
|
676 |
|
|
677 |
^ aNumber sin
|
|
678 |
|
|
679 |
"
|
893
|
680 |
JavaScriptParser evaluate:'Math.sin(3.14159);'
|
303
|
681 |
"
|
|
682 |
!
|
|
683 |
|
|
684 |
tan:aNumber
|
|
685 |
"returns the tangent of a number (given in radians)"
|
|
686 |
|
|
687 |
^ aNumber tan
|
|
688 |
|
|
689 |
"
|
893
|
690 |
JavaScriptParser evaluate:'Math.tan(3.14159);'
|
303
|
691 |
"
|
|
692 |
! !
|
|
693 |
|
|
694 |
!Math class methodsFor:'documentation'!
|
|
695 |
|
|
696 |
version
|
|
697 |
^ '$Header$'
|
|
698 |
! !
|
893
|
699 |
|