@@ -11,82 +11,64 @@ public final class skript {
11
11
//region Maths
12
12
13
13
//region Trigonometry
14
- public static double acos (Object object ) {
15
- if (object == null ) return 90 ;
16
- if (object instanceof Number number ) return Math .toDegrees (Math .acos (number .doubleValue ()));
17
- throw new ScriptRuntimeError ("Unable to acos(" + object + ") - not a number." );
14
+ public static double acos (double number ) {
15
+ if (number == 0 ) return 90 ;
16
+ return Math .toDegrees (Math .acos (number ));
18
17
}
19
18
20
- public static double asin (Object object ) {
21
- if (object == null ) return 0 ;
22
- if (object instanceof Number number ) return Math .toDegrees (Math .asin (number .doubleValue ()));
23
- throw new ScriptRuntimeError ("Unable to asin(" + object + ") - not a number." );
19
+ public static double asin (double number ) {
20
+ if (number == 0 ) return 0 ;
21
+ return Math .toDegrees (Math .asin (number ));
24
22
}
25
23
26
- public static double atan (Object object ) {
27
- if (object == null ) return 0 ;
28
- if (object instanceof Number number ) return Math .toDegrees (Math .atan (number .doubleValue ()));
29
- throw new ScriptRuntimeError ("Unable to atan(" + object + ") - not a number." );
30
- }
31
-
32
- public static double atan2 (Object rawX , Object rawY ) {
33
- double x , y ;
34
- if (rawX == null ) x = 0 ;
35
- else if (rawX instanceof Number number ) x = number .doubleValue ();
36
- else throw new ScriptRuntimeError ("Unable to atan2(" + rawX + ") - not a number." );
37
- if (rawY == null ) y = 0 ;
38
- else if (rawY instanceof Number number ) y = number .doubleValue ();
39
- else throw new ScriptRuntimeError ("Unable to atan2(" + rawY + ") - not a number." );
24
+ public static double atan (double number ) {
25
+ if (number == 0 ) return 0 ;
26
+ return Math .toDegrees (Math .atan (number ));
27
+ }
28
+
29
+ public static double atan2 (double x , double y ) {
40
30
return Math .toDegrees (Math .atan2 (y , x ));
41
31
}
42
32
43
- public static double cos (Object object ) {
44
- if (object == null ) return 1 ;
45
- if (object instanceof Number number ) return Math .cos (Math .toRadians (number .doubleValue ()));
46
- throw new ScriptRuntimeError ("Unable to cos(" + object + ") - not a number." );
33
+ public static double cos (double number ) {
34
+ if (number == 0 ) return 1 ;
35
+ return Math .cos (Math .toRadians (number ));
47
36
}
48
37
49
- public static double cosh (Object object ) {
50
- if (object == null ) return 1 ;
51
- if (object instanceof Number number ) return Math .toDegrees (Math .cosh (Math .toRadians (number .doubleValue ())));
52
- throw new ScriptRuntimeError ("Unable to cosh(" + object + ") - not a number." );
38
+ public static double cosh (double number ) {
39
+ if (number == 0 ) return 1 ;
40
+ return Math .toDegrees (Math .cosh (Math .toRadians (number )));
53
41
}
54
42
55
- public static double sin (Object object ) {
56
- if (object == null ) return 0 ;
57
- if (object instanceof Number number ) return Math .sin (Math .toRadians (number .doubleValue ()));
58
- throw new ScriptRuntimeError ("Unable to sin(" + object + ") - not a number." );
43
+ public static double sin (double number ) {
44
+ if (number == 0 ) return 0 ;
45
+ return Math .sin (Math .toRadians (number ));
59
46
}
60
47
61
- public static double sinh (Object object ) {
62
- if (object == null ) return 0 ;
63
- if (object instanceof Number number ) return Math .toDegrees (Math .sinh (Math .toRadians (number .doubleValue ())));
64
- throw new ScriptRuntimeError ("Unable to sinh(" + object + ") - not a number." );
48
+ public static double sinh (double number ) {
49
+ if (number == 0 ) return 0 ;
50
+ return Math .toDegrees (Math .sinh (Math .toRadians (number )));
65
51
}
66
52
67
- public static double tan (Object object ) {
68
- if (object == null ) return 0 ;
69
- if (object instanceof Number number ) return Math .tan (Math .toRadians (number .doubleValue ()));
70
- throw new ScriptRuntimeError ("Unable to tan(" + object + ") - not a number." );
53
+ public static double tan (double number ) {
54
+ if (number == 0 ) return 0 ;
55
+ return Math .tan (Math .toRadians (number ));
71
56
}
72
57
73
- public static double tanh (Object object ) {
74
- if (object == null ) return 0 ;
75
- if (object instanceof Number number ) return Math .toDegrees (Math .tanh (Math .toRadians (number .doubleValue ())));
76
- throw new ScriptRuntimeError ("Unable to tanh(" + object + ") - not a number." );
58
+ public static double tanh (double number ) {
59
+ if (number == 0 ) return 0 ;
60
+ return Math .toDegrees (Math .tanh (Math .toRadians (number )));
77
61
}
78
62
//endregion
79
63
80
- public static double to_degrees (Object object ) {
81
- if (object == null ) return 0 ;
82
- if (object instanceof Number number ) return Math .toDegrees (number .doubleValue ());
83
- throw new ScriptRuntimeError ("Unable to to_degrees(" + object + ") - not a number." );
64
+ public static double to_degrees (double number ) {
65
+ if (number == 0 ) return 0 ;
66
+ return Math .toDegrees (number );
84
67
}
85
68
86
- public static double to_radians (Object object ) {
87
- if (object == null ) return 0 ;
88
- if (object instanceof Number number ) return Math .toRadians (number .doubleValue ());
89
- throw new ScriptRuntimeError ("Unable to to_radians(" + object + ") - not a number." );
69
+ public static double to_radians (double number ) {
70
+ if (number == 0 ) return 0 ;
71
+ return Math .toRadians (number );
90
72
}
91
73
92
74
public static Number abs (Object object ) {
@@ -100,17 +82,16 @@ public static Number abs(Object object) {
100
82
throw new ScriptRuntimeError ("Unable to abs(" + object + ") - not a number." );
101
83
}
102
84
103
- public static double sqrt (Object object ) {
104
- if (object == null ) return 0 ;
105
- if (object instanceof Number number ) return Math .sqrt (number .doubleValue ());
106
- throw new ScriptRuntimeError ("Unable to sqrt(" + object + ") - not a number." );
85
+ public static double sqrt (double number ) {
86
+ if (number == 0 ) return 0 ;
87
+ return Math .sqrt (number );
107
88
}
108
89
109
90
public static double newton_root (Object object , Object accuracy ) {
110
91
if (object == null ) return 0 ;
111
92
final int times = (accuracy instanceof Number number ) ? number .intValue () : 1 ;
112
93
if (!(object instanceof Number number ))
113
- throw new ScriptRuntimeError ("Unable to sqrt (" + object + ") - not a number." );
94
+ throw new ScriptRuntimeError ("Unable to root (" + object + ") - not a number." );
114
95
final double value = number .doubleValue ();
115
96
double result = Double .longBitsToDouble (((Double .doubleToLongBits (value ) - (1L << 52 )) >> 1 ) + (1L << 61 ));
116
97
for (int i = 0 ; i < times ; i ++) {
@@ -119,23 +100,19 @@ public static double newton_root(Object object, Object accuracy) {
119
100
return result ;
120
101
}
121
102
122
- public static double ceil (Object object ) {
123
- if (object == null ) return 0 ;
124
- if (object instanceof Number number ) return Math .ceil (number .doubleValue ());
125
- throw new ScriptRuntimeError ("Unable to ceil(" + object + ") - not a number." );
103
+ public static double ceil (double number ) {
104
+ if (number == 0 ) return 0 ;
105
+ return Math .ceil (number );
126
106
}
127
107
128
- public static double floor (Object object ) {
129
- if (object == null ) return 0 ;
130
- if (object instanceof Number number ) return Math .floor (number .doubleValue ());
131
- throw new ScriptRuntimeError ("Unable to floor(" + object + ") - not a number." );
108
+ public static double floor (double number ) {
109
+ if (number == 0 ) return 0 ;
110
+ return Math .floor (number );
132
111
}
133
112
134
- public static long round (Object object ) {
135
- if (object == null ) return 0 ;
136
- if (object instanceof Float number ) return Math .round (number .doubleValue ());
137
- if (object instanceof Number number ) return Math .round (number .doubleValue ());
138
- throw new ScriptRuntimeError ("Unable to round(" + object + ") - not a number." );
113
+ public static int round (double number ) {
114
+ if (number == 0 ) return 0 ;
115
+ return (int ) Math .round (number );
139
116
}
140
117
141
118
public static double ln (Object object ) {
0 commit comments