-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.pi
More file actions
76 lines (54 loc) · 1.08 KB
/
utils.pi
File metadata and controls
76 lines (54 loc) · 1.08 KB
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
use std::math;
pub fn itoa_pl(i:i64) string {
let bs = [u8 * 10;];
let len = itoa(i, &bs[0]);
let ss = "";
ss.from_raw(&bs[0], len);
return ss;
}
pub fn itoa(i:i64, to:*u8) i64;
pub fn sqrt_64(x: f64) f64;
fn abs_f(f:f64) f64 {
if f < 0.0 {
return -f;
}
return f;
}
var INFINITY = (1.0/0.0);
var PIE = 3.1415926535897932385;
pub fn degrees_to_radians(degrees:f64) f64 {
return degrees * PIE / 180.0;
}
const RAND_MAX:i32;
pub fn random_f64() f64 {
let r = rand1();
return r as i64 as f64 /((RAND_MAX as i64+1) as f64);
}
var seed = 123456789;
fn rand1() i64
{
seed = (1103515245 * seed + 12345) % (1 << 31);
return seed;
}
pub fn random_f64_range(min:f64,max:f64) f64 {
return min + random_f64() * (max - min);
}
pub fn fabs(x:f64) f64 {
if x < 0.0 {
return -x;
}
return x;
}
pub fn fmin(x:f64, y:f64) f64 {
if x < y {
return x;
}
return y;
}
pub fn pow(x:f64, y:f64) f64;
pub fn tan(x:f64) f64{
return math::tan(x);
}
pub fn cos(x:f64) f64{
return math::cos(x);
}