|
local function | float_eq (l, r, tol) |
|
local function | clamp (v, min, max) return math.max(min |
|
local function math | min (max, v)) end |
|
local function | circle_iter (r, a0, n) |
|
local local function | vec2 (x, y) |
|
local function | vec3 (x, y, z) |
|
local function | vec2_rand (f) return vec2(f() |
|
local function | f ()) end |
|
local function | vec2_unm (v) return vec2(-v[1] |
|
local function | vec2_add (v, u) return vec2(v[1]+u[1] |
|
local function | vec2_sub (v, u) return vec2(v[1] - u[1] |
|
local function | vec2_mul (v, u) return vec2(v[1] *u[1] |
|
local function | vec2_div (v, u) return vec2(v[1]/u[1] |
|
local function | vec2_idiv (v, u) return vec2(v[1] local function-vec2_dot(v |
|
local function | vec2_sqrt (v) return vec2(math.sqrt(v[1]) |
|
local function math | sqrt (v[2])) end |
|
local function | vec2_str (v) return string.format(" |
|
local function | vec2_map (v, f) return vec2(f(v[1]) |
|
local function | f (v[2])) end |
|
function | vec2_random_dist (n, xoff, yoff, xspread, yspread) |
|
local function | vec3_rand (f) return vec3(f() |
|
local function | vec3_unm (v) return vec3(-v[1] |
|
local function | vec3_add (v, u) |
|
local function | vec3_sub (v, u) |
|
local function | vec3_mul (v, u) |
|
local function | vec3_div (v, u) |
|
local function | vec3_idiv (v, u) |
|
local function | vec3_dot (v, u) |
|
local function | vec3_cross (v, u) |
|
local function | vec3_sqrt (v) |
|
local function | vec3_str (v) |
|
local function | vec3_map (v, f) return vec3(f(v[1]) |
|
local function | f (v[3])) end |
|
local function vec_norm(v) return v/v. new(v local function vec_len_sq(v) return v local function | vec_len (v) return math.sqrt(vec_len_sq(v)) end |
|
local function | vec_reflect (v, n) |
|
local function | vec_refract (v, n, n0, n1) |
|
local function | vec_interp (v, u, t) return v. new(1 - t) *v+v. new(t) *u end |
|