-
Notifications
You must be signed in to change notification settings - Fork 9
/
New Functions Documentation.txt
5060 lines (4254 loc) · 126 KB
/
New Functions Documentation.txt
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
ALL ARGUMENTS ARE FLOATS UNLESS STATED OTHERWISE
"T": Any type
----------------------------------------------> [Base Script] <----------------------------------------------
--------------------------------> New Constants <--------------------------------
M_PI = pi ; 3.14159265358979323846
M_PI_2 = M_PI / 2 ; 1.57079632679489661923
M_PI_4 = M_PI / 4 ; 0.78539816339744830962
M_PI_X2 = M_PI * 2 ; 6.28318530717958647693
M_PI_X4 = M_PI * 4 ; 12.5663706143591729539
M_1_PI = 1 / M_PI ; 0.31830988618379067154
M_2_PI = 2 / M_PI ; 0.63661977236758134308
M_SQRTPI = sqrt(M_PI) ; 1.772453850905516027298
M_1_SQRTPI = 1 / sqrt(M_PI) ; 0.56418958354775628695
M_2_SQRTPI = 2 / sqrt(M_PI) ; 1.128379167095512573896
M_SQRT2 = sqrt(2) ; 1.4142135623730950488
M_SQRT2_2 = sqrt(2) / 2 ; 0.7071067811865475244
M_SQRT2_X2 = sqrt(2) * 2 ; 2.8284271247461900976
M_E = e ; 2.71828182845904523536
M_LOG2E = log2(e) ; 1.44269504088896340736
M_LOG10E = log10(e) ; 0.43429448190325182765
M_LN2 = ln(2) ; 0.69314718055994530942
M_LN10 = ln(10) ; 2.30258509299404568402
M_PHI = (1 + sqrt(5)) / 2 ; 1.61803398874989484821
M_1_PHI = 1 / M_PHI ; 0.6180339887498948482
INF = infinity float
NAN = NaN float
--------------------------------> Basic Operations <--------------------------------
__DEBUG_BREAK
Description:
Triggers a debug break. For developers.
wait
Arguments:
1) (int) frame
Description:
Pauses the execution for the given amount of frames.
Much faster than loop(n){yield;}
typeof
Arguments:
1) (T) value
Returns:
(int) type
Description:
Returns the type of the given value.
Example:
-60i -> VAR_INT
920 -> VAR_FLOAT
false -> VAR_BOOL
"str" -> VAR_STRING
[8, 0, 2] -> VAR_ARRAY
ftypeof
Arguments:
1) (T) value
Returns:
(int) type
Description:
Returns the root type of the given value.
Example:
920 -> VAR_FLOAT
false -> VAR_BOOL
"str" -> VAR_CHAR
[8, 0, 2] -> VAR_FLOAT
[[["a"]]] -> VAR_CHAR
resize
Arguments:
1) (T[]) array
2) (int) new size
Returns:
(T[]) result
Description:
Resizes the given array.
The array must not be a null array.
resize (Overload)
Arguments:
1) (T[]) array
2) (int) new size
3) (T) fill value
Returns:
(T[]) result
Description:
Overloaded with 3 arguments.
Resizes the given array.
If the new size is larger than the old size, newly inserted elements will be assigned the fill value.
Unless the array is a null array, the fill value's type must be convertible to the array's element type.
insert
Arguments:
1) (T[]) array
2) (int) insert position
3) (T) value
Returns:
(T[]) result
Description:
Inserts the given value into the given position of the array.
Insertion method is "insert-before".
contains
Arguments:
1) (T[]) array
2) (T) value
Returns:
(bool) result
Description:
Checks if the given value is present as an element of the given array.
replace
Arguments:
1) (T[]) array
2) (T) replace from
2) (T) replace to
Returns:
(T[]) result
Description:
Replaces all occurences of the given element with the other in the array.
remove
Arguments:
1) (T[]) array
2) (T) value
Returns:
(T[]) result
Description:
Removes all occurences of the given element in the array.
--------------------------------> Type Casting <--------------------------------
as_int
Arguments:
1) (T) value
Returns:
(int) result
Description:
Returns the given value casted to an int value.
as_float
Arguments:
1) (T) value
Returns:
(float) result
Description:
Returns the given value casted to a float value.
as_bool
Arguments:
1) (T) value
Returns:
(bool) result
Description:
Returns the given value casted to a bool value.
as_char
Arguments:
1) (T) value
Returns:
(char) result
Description:
Returns the given value casted to a char value.
as_int_array
Arguments:
1) (T[]) array
Returns:
(int[]) result
Description:
Casts array elements to ints, then returns the result.
Casting is recursive.
Example:
as_int_array([[true, true], [false, true]]); //-> [[1, 1], [0, 1]]
as_float_array
Arguments:
1) (T[]) array
Returns:
(float[]) result
Description:
Casts array elements to floats, then returns the result.
Casting is recursive.
as_bool_array
Arguments:
1) (T[]) array
Returns:
(bool[]) result
Description:
Casts array elements to bools, then returns the result.
Casting is recursive.
as_char_array
Arguments:
1) (T[]) array
Returns:
(char[]) result
Description:
Casts array elements to chars, then returns the result.
Casting is recursive.
Not an alias of ToString.
as_x_array
Arguments:
1) (T[]) array
2) (const) type
Returns:
(T[]) result
Description:
Casts array elements to the given type, then returns the result.
Supported types:
VAR_INT
VAR_FLOAT
VAR_BOOL
VAR_CHAR
Casting is recursive.
--------------------------------> Bitwise Operations <--------------------------------
bit_not
Arguments:
1) (int) value
Returns:
(int) result
Description:
Performs a bitwise NOT operation.
bit_and
Arguments:
1) (int) value 1
2) (int) value 2
Returns:
(int) result
Description:
Performs a bitwise AND operation.
bit_or
Arguments:
1) (int) value 1
2) (int) value 2
Returns:
(int) result
Description:
Performs a bitwise OR operation.
bit_xor
Arguments:
1) (int) value 1
2) (int) value 2
Returns:
(int) result
Description:
Performs a bitwise XOR operation.
bit_left
Arguments:
1) (int) value
2) (int) shift factor
Returns:
(int) result
Description:
Performs a bitwise left shift operation.
bit_right
Arguments:
1) (int) value
2) (int) shift factor
Returns:
(int) result
Description:
Performs a bitwise right shift operation.
--------------------------------> Float Utilities <--------------------------------
Float_Classify
Arguments:
1) x
Returns:
(const) result
Description:
Classifies the given float value.
Possible return values:
- FLOAT_TYPE_ZERO ; Value is either +0 or -0.
- FLOAT_TYPE_NORMAL ; Value is a normal float.
- FLOAT_TYPE_SUBNORMAL ; Value is a subnormal float. (https://en.wikipedia.org/wiki/Subnormal_number)
- FLOAT_TYPE_INFINITY ; Value is either +infinity or -infinity.
- FLOAT_TYPE_NAN ; Value is not-a-number.
Float_IsNan
Arguments:
1) x
Returns:
(bool) result
Description:
Returns true if the given float is NaN.
Float_IsInf
Arguments:
1) x
Returns:
(bool) result
Description:
Returns true if the given float is +infinity or -infinity.
Float_GetSign
Arguments:
1) x
Returns:
(float) sign
Description:
Returns +1.0 if the given float is positive, and -1.0 if the given float is negative.
Float_CopySign
Arguments:
1) x
2) y
Returns:
(float) result
Description:
Copies the sign of x to y, and returns the result.
--------------------------------> Maths <--------------------------------
clamp
Arguments:
1) x
2) lower bound
3) upper bound
Returns:
(float) result
Description:
Returns x clamped between the specified range.
log2
Arguments:
1) x
Returns:
(float) result
Description:
Returns base-2 logarithm of x.
logn
Arguments:
1) x
2) base
Returns:
(float) result
Description:
Returns base-n logarithm of x.
erf
Arguments:
1) x
Returns:
(float) result
Description:
Returns the error function value of x.
erf(x) = (2/sqrt(pi)) * integral(0, x, "e^(-t^2) dt")
gamma
Arguments:
1) x
Returns:
(float) result
Description:
Returns the gamma function value of x.
gamma(z + 1) = integral(0, infinity, "(x^z)(e^(-x)) dx")
exp
Arguments:
1) value
Returns:
(float) result
Description:
Returns e (Euler's number) raised to the power of x.
sqrt
Arguments:
1) x
Returns:
(float) result
Description:
Returns the square root of x.
Much faster than pow(x, 0.5).
cbrt
Arguments:
1) x
Returns:
(float) result
Description:
Returns the cube root of x.
Equivalent to (x ^ (1/3)).
nroot
Arguments:
1) x
2) root
Returns:
(float) result
Description:
Returns the nth root of x.
Equivalent to pow(x, 1 / root).
hypot
Arguments:
1) a
2) b
Returns:
(float) result
Description:
Returns the hypotenuse of the triangle formed by the two given values.
hypot(a, b) = sqrt(a * a + b * b)
distance
Arguments:
1) x1
2) y1
3) x2
4) y2
Returns:
(float) result
Description:
Returns distance between the given two points.
distance(x1, y1, x2, y2) = hypot(x1 - x2, y1 - y2)
distancesq
Arguments:
1) x1
2) y1
3) x2
4) y2
Returns:
(float) result
Description:
Returns square of the distance between the given two points.
distancesq(x1, y1, x2, y2) = (x1 - x2)^2 + (y1 - y2)^2
dottheta
Arguments:
1) x1
2) y1
3) x2
4) y2
Returns:
(float) result (degrees)
Description:
Returns angle (in degrees) between the given two points.
dottheta(x1, y1, x2, y2) = atan2(y2 - y1, x2 - x1)
rdottheta
Arguments:
1) x1
2) y1
3) x2
4) y2
Returns:
(float) result (radians)
Description:
Returns angle (in radians) between the given two points.
rdottheta(x1, y1, x2, y2) = ratan2(y2 - y1, x2 - x1)
--------------------------------> Trigonometry and Angular Maths <--------------------------------
sincos
Arguments:
1) angle
Returns:
(float[2]) [sin(angle), cos(angle)]
rsin
Arguments:
1) angle
Returns:
(float) result
Description:
sin() for radians input.
rcos
Arguments:
1) angle (radians)
Returns:
(float) result
Description:
cos() for radians input.
rtan
Arguments:
1) angle (radians)
Returns:
(float) result
Description:
tan() for radians input.
rsincos
Arguments:
1) angle (radians)
Returns:
(float[2]) result
Description:
sincos() for radians input.
rasin
Arguments:
1) value
Returns:
(float) result
Description:
asin() for radians output.
racos
Arguments:
1) value
Returns:
(float) result
Description:
acos() for radians output.
ratan
Arguments:
1) y
2) x
Returns:
(float) result
Description:
atan() for radians output.
ratan2
Arguments:
1) value
Returns:
(float) result
Description:
atan2() for radians output.
ToDegrees
Arguments:
1) angle
Returns:
(float) result
Description:
Converts the given angle to degrees.
ToRadians
Arguments:
1) angle
Returns:
(float) result
Description:
Converts the given angle to radians.
NormalizeAngle
Arguments:
1) angle (degrees)
Returns:
(float) result
Description:
Normalizes the given angle. (Range = [0, 360))
NormalizeAngleR
Arguments:
1) angle (radians)
Returns:
(float) result
Description:
Normalizes the given angle. (Range = [0, 2pi))
AngularDistance
Arguments:
1) angle from (degrees)
2) angle to (degrees)
Returns:
(float) result
Description:
Calculates the shortest angular distance between the given angles. (Range = [-180, 180))
AngularDistanceR
Arguments:
1) angle from (radians)
2) angle to (radians)
Returns:
(float) result
Description:
Calculates the shortest angular distance between the given angles. (Range = [-pi, pi))
ReflectAngle
Arguments:
1) ray angle (degrees)
2) surface angle (degrees)
Returns:
(float) result
Description:
Calculates the given ray's angle of reflection upon a surface of the given angle. (Range = [0, 360))
ReflectAngleR
Arguments:
1) ray angle (radians)
2) surface angle (radians)
Returns:
(float) result
Description:
Calculates the given ray's angle of reflection upon a surface of the given angle. (Range = [0, 2pi))
--------------------------------> Interpolation <--------------------------------
For the functions in this section, refer to these Desmos graph plot.
"Basic" interpolations -> https://www.desmos.com/calculator/m8dnz348cq
Bezier interpolations -> https://www.desmos.com/calculator/q1uptzx8ti
Interpolate_Linear
Arguments:
1) a
2) b
3) x
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is linear.
Direct formula is (a + (b - a) * (x))
Represented by the red graph.
When interpolating between two arrays, they must be of the same size.
Interpolate_Smooth
Arguments:
1) a
2) b
3) x
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is first-order smoothstep curve.
Direct formula is (a + (b - a) * (x^2 * (3 - 2 * x)))
Represented by the blue graph.
When interpolating between two arrays, they must be of the same size.
Interpolate_Smoother
Arguments:
1) a
2) b
3) x
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is second-order smoothstep curve.
Direct formula is (a + (b - a) * (x^3 * (x * (x * 6 - 15) + 10)))
Represented by the green graph.
When interpolating between two arrays, they must be of the same size.
Interpolate_Accelerate
Arguments:
1) a
2) b
3) x
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is parabolic.
Direct formula is (a + (b - a) * (x^2))
Represented by the purple graph.
When interpolating between two arrays, they must be of the same size.
Interpolate_Decelerate
Arguments:
1) a
2) b
3) x
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is inverse parabolic.
Direct formula is (a + (b - a) * (1 - (1 - x)^2))
Represented by the black graph.
When interpolating between two arrays, they must be of the same size.
Interpolate_Modulate
Arguments:
1) a
2) b
3) c
4) x
Returns:
(float) result
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is sine.
Direct formula is (a + (b - a) * (x + (rsin(2pi * x) / (2pi)) * c))
Represented by the dotted red graph.
Interpolate_Overshoot
Arguments:
1) a
2) b
3) c
4) x
Returns:
(float) result
Description:
Returns the result of interpolation between a and b, using x as the interpolation value.
Interpolation method is half sine.
Direct formula is (a + (b - a) * (x + (rsin(pi * x) / pi) * c))
Represented by the dotted blue graph.
Interpolate_QuadraticBezier
Arguments:
1) a
2) b
3) c
4) x
Returns:
(float) result
Description:
Calculates a coordinate component of a quadratic Bezier curve.
Direct formula is ((a * (1 - x)^2) + (2 * c * x * (1 - x)) + (b * x^2))
Represented by the red graph.
Interpolate_CubicBezier
Arguments:
1) a
2) b
3) c1
4) c2
5) x
Returns:
(float) result
Description:
Calculates a coordinate component of a cubic Bezier curve.
Direct formula is ((a * (1 - x)^3) + (3 * c1 * x * (1 - x)^2) + (3 * c2 * x^2 * (1 - x)) + (b * x^3))
Represented by the blue graph.
Interpolate_Hermite
Arguments:
1) start x
2) start y
3) end x
4) end y
5) starting point tangent vector magnitude
6) starting point tangent vector angle (degrees)
5) ending point tangent vector magnitude
6) ending point tangent vector angle (degrees)
9) x
Returns:
(float[2]) [x, y]
Description:
Calculates the position along the given cubic Hermite spline curve.
https://en.wikipedia.org/wiki/Cubic_Hermite_spline
Interpolate_X
Arguments:
1) a
2) b
3) x
4) (int) interpolation type
Returns:
IF a, b are not arrays
(float) result
ELSE
(float[]) result array
Description:
Interpolates between a and b using x with the given interpolation type.
Available interpolation types:
LERP_LINEAR:
Interpolate_Linear
LERP_SMOOTH:
Interpolate_Smooth
LERP_SMOOTHER:
Interpolate_Smoother
LERP_ACCELERATE:
Interpolate_Accelerate
LERP_DECELERATE:
Interpolate_Decelerate
Interpolate_X_PackedInt
Arguments:
1) (int) a
2) (int) b
3) x
4) (int) interpolation type
Returns:
(int) result
Description:
Divides a and b (both 8-byte ints) into eight 1-byte chunks, performs interpolation on each pair, and recombines them to return the result.
Example:
Interpolate_X_PackedInt(0x37ff4040, 0xaa001010, 0.5, LERP_LINEAR); //result = 0x707f2828
Interpolate_X_Angle
Arguments:
1) a (degrees)
2) b (degrees)
3) x
4) (int) interpolation type
Returns:
(float) angle (degrees)
Description:
Interpolates between angles a and b using x with the given interpolation type.
Equivalent to:
NormalizeAngle(a + Interpolate_X(0, AngularDistance(a, b), x, type));
Interpolate_X_AngleR
Arguments:
1) a (radians)
2) b (radians)
3) x
4) (int) interpolation type
Returns:
(float) angle (radians)
Description:
Interpolates between angles a and b using x with the given interpolation type.
Equivalent to:
NormalizeAngleR(a + Interpolate_X(0, AngularDistanceR(a, b), x, type));
Interpolate_X_Array
Arguments:
1) (T[]) values
2) x
3) (int) interpolation type
Returns:
(float) result
Description:
Interpolates between multiple elements of the array.
Examples:
Interpolate_X_Array([a, b, c, d], 0.2, LERP_LINEAR);
= Interpolate_X(a, b, 0.2, LERP_LINEAR);
Interpolate_X_Array([a, b, c, d], 1.5, LERP_LINEAR);
= Interpolate_X(b, c, 0.5, LERP_LINEAR);
Interpolate_X_Array([a, b, c, d], 2.9, LERP_LINEAR);
= Interpolate_X(c, d, 0.9, LERP_LINEAR);
--------------------------------> Random <--------------------------------
rand_int
Arguments:
1) (int) min
2) (int) max
Returns:
(int) random integer
Description:
Returns a random integer within the range [a, b].
rand_int(a, b) = as_int(rand(a, b + 0.99999))
prand
Arguments:
1) min
2) max
Returns:
(float) random value
Description:
Exactly like rand(), but the seed of which doesn't get saved to replays, and does not affect the state of rand().
prand_int
Arguments:
1) (int) min
2) (int) max
Returns:
(int) random integer
Description:
Returns a random integer within the range [a, b] using the prand() function.
prand_int(a, b) = as_int(prand(as_int(a), as_int(b) + 0.99999))
psrand
Arguments:
1) (int) seed
Description:
Sets the seed for prand and prand_int.
count_rand
Returns:
(int) count
Description:
Returns the amount of number rand or rand_int have been used.
Resets when restarting the game or exiting to the script select menu.
count_prand
Returns:
(int) count
Description:
Returns the amount of number prand or prand_int have been used.
Resets when restarting the game or exiting to the script select menu.
reset_count_rand
Description:
Sets the rand count to 0.
reset_count_prand
Description:
Sets the prand count to 0.
--------------------------------> Rotation Maths <--------------------------------
Rotate2D
Arguments:
1) x
2) y
3) angle
Returns:
(float[2]) rotated position [x, y]
Description:
Rotates the given (x, y) point around the origin (0, 0).
Direct formula is:
x = x * cos(angle) - y * sin(angle)
y = x * sin(angle) + y * cos(angle)
Rotate2D (overload)
Arguments:
1) x
2) y
3) angle
4) origin x
5) origin y
Returns:
(float[2]) rotated position [x, y]
Description:
Overloaded with 5 arguments.
Rotates the given (x, y) point around the given origin.
Direct formula is:
_x = x - ox
_y = y - oy
x = ox + (_x * cos(angle) - _y * sin(angle))
y = oy + (_x * sin(angle) + _y * cos(angle))
Rotate3D
Arguments:
1) x
2) y
3) z
4) X angle
5) Y angle
6) Z angle
Returns:
(float[3]) rotated position [x, y, z]
Description:
Rotates the given (x, y, z) point around the origin (0, 0) with the given Euler angles.
Direct formula is:
x = x * (cos(angY) * cos(angZ) - sin(angX) * sin(angY) * sin(angZ)) + y * (-cos(angX) * sin(angZ)) + z * (sin(angY) * cos(angZ) + sin(angX) * cos(angY) * sin(angZ))
y = x * (cos(angY) * sin(angZ) + sin(angX) * sin(angY) * cos(angZ)) + y * (cos(angX) * cos(angZ)) + z * (sin(angY) * sin(angZ) - sin(angX) * cos(angY) * cos(angZ))