From 80a2b4dadeb7d77635926402ce3ea8c8a4cecbf6 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 29 Nov 2020 18:58:47 -0600 Subject: [PATCH] rand param --- src/vmath.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vmath.nim b/src/vmath.nim index dafa4b6..9b2cf28 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -167,9 +167,9 @@ proc `[]=`*(a: var Vec2, i: int, b: float32) = else: a.y = b -proc randVec2*(): Vec2 = - let a = rand(PI * 2) - let v = rand(1.0) +proc randVec2*(r: var Rand): Vec2 = + let a = r.rand(PI * 2) + let v = r.rand(1.0) vec2(cos(a) * v, sin(a) * v) proc `$`*(a: Vec2): string = @@ -368,12 +368,12 @@ proc almostEquals*(a, b: Vec3, precision = 1e-6): bool = let c = a - b abs(c.x) < precision and abs(c.y) < precision and abs(c.z) < precision -proc randVec3*(): Vec3 = +proc randVec3*(r: var Rand): Vec3 = ## Generates a random unit vector based on ## http://mathworld.wolfram.com/SpherePointPicking.html let - u = rand(0.0 .. 1.0) - v = rand(0.0 .. 1.0) + u = r.rand(0.0 .. 1.0) + v = r.rand(0.0 .. 1.0) th = 2 * PI * u ph = arccos(2 * v - 1) vec3(