Win32 Demo - Minor math tests

This commit is contained in:
gingerBill
2016-08-18 09:24:52 +01:00
parent 6f9d11b381
commit 6b2cd1b33f
5 changed files with 955 additions and 95 deletions
+18
View File
@@ -0,0 +1,18 @@
type Vec2: {2}f32
type Vec3: {3}f32
type Vec4: {4}f32
type Mat2: {4}f32
sqrt_f32 :: proc(x: f32) -> f32 #foreign "llvm.sqrt.f32"
sqrt_f64 :: proc(x: f64) -> f64 #foreign "llvm.sqrt.f64"
vec2_dot :: proc(a, b: Vec2) -> f32 { c := a*b; return c[0] + c[1]; }
vec3_dot :: proc(a, b: Vec3) -> f32 { c := a*b; return c[0] + c[1] + c[2]; }
lerp :: proc(a, b, t: f32) -> f32 { return a*(1-t) + b*t; }
vec2_mag :: proc(a: Vec2) -> f32 { return sqrt_f32(vec2_dot(a, a)); }
vec3_mag :: proc(a: Vec3) -> f32 { return sqrt_f32(vec3_dot(a, a)); }