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
use rhai::plugin::*;
#[export_module]
#[allow(non_upper_case_globals)]
pub mod constant_definitions {
use rhai::FLOAT;
// The ratio of a circle's circumference to its diameter.
#[allow(non_upper_case_globals)]
pub const pi: FLOAT = 3.14159265358979323846264338327950288;
//Speed of light in meters per second (m/s).
#[allow(non_upper_case_globals)]
pub const c: FLOAT = 299792458.0;
// Euler's number.
#[allow(non_upper_case_globals)]
pub const e: FLOAT = 2.71828182845904523536028747135266250;
// Acceleration due to gravity on Earth in meters per second per second (m/s^2).
#[allow(non_upper_case_globals)]
pub const g: FLOAT = 9.80665;
// The Planck constant in Joules per Hertz (J/Hz)
#[allow(non_upper_case_globals)]
pub const h: FLOAT = 6.62607015e-34;
// The golden ratio
#[allow(non_upper_case_globals)]
pub const phi: FLOAT = 1.61803398874989484820;
// Newtonian gravitational constant
pub const G: FLOAT = 6.6743015e-11;
/// Physical constants useful for science.
/// ### `pi: FLOAT`
/// The ratio of a circle's circumference to its diameter (non-dimensional).
/// ```typescript
/// assert_eq(pi, 3.14159265358979323846264338327950288);
/// ```
/// ### `c: FLOAT`
/// The speed of light in meters per second (m/s).
/// ```typescript
/// assert_eq(c, 299792458.0);
/// ```
/// ### `e: FLOAT`
/// Euler's number (non-dimensional).
/// ```typescript
/// assert_eq(e, 2.71828182845904523536028747135266250);
/// ```
/// ### `g: FLOAT`
/// The acceleration due to gravity on Earth in meters per second per second (m/s^2).
/// ```typescript
/// assert_eq(g, 9.80665);
/// ```
/// ### `h: FLOAT`
/// The Planck constant in Joules per Hertz (J/Hz).
/// ```typescript
/// assert_eq(h, 6.62607015e-34);
/// ```
/// ### `phi: FLOAT`
/// The golden ratio (non-dimensional).
/// ```typescript
/// assert_eq(phi, 1.61803398874989484820);
/// ```
/// ### `G: FLOAT`
/// The Newtonian gravitational constant (non-dimensional).
/// ```typescript
/// assert_eq(G, 6.6743015e-11);
/// ```
#[rhai_fn(name = "$CONSTANTS$")]
pub fn constants() {}
}