From 19c9ef1b0b5dcbcc993d97fa7c3a3dc80ea21b4a Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Mon, 30 Nov 2020 00:50:07 -0600 Subject: [PATCH] add missing --- src/vmath.nim | 13 +++++++++++++ tests/test.nim | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/vmath.nim b/src/vmath.nim index 597c052..aeb892b 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -1202,6 +1202,19 @@ proc `*`*(q: Quat, v: float32): Quat {.inline.} = result.z = q.z * v result.w = q.w * v +proc `/`*(q: Quat, v: float32): Quat {.inline.} = + ## Divide the quaternion by a float32. + result.x = q.x / v + result.y = q.y / v + result.z = q.z / v + result.w = q.w / v + +proc `*=`*(a: var Quat, b: float32) {.inline.} = + a = a * b + +proc `/=`*(a: var Quat, b: float32) {.inline.} = + a = a / b + proc `*`*(q: Quat, v: Vec3): Vec3 = ## Multiply the quaternion by a vector. let diff --git a/tests/test.nim b/tests/test.nim index 2a87526..9134b8d 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -1,5 +1,21 @@ import vmath, osproc, random, streams +var v2 = vec2(0, 0) +v2 *= 1 +v2 /= 1 + +var v3 = vec3(0, 0, 0) +v3 *= 1 +v3 /= 1 + +var v4 = vec4(0, 0, 0, 0) +v4 *= 1 +v4 /= 1 + +var q = quat(0, 0, 0, 0) +q *= 1 +q /= 1 + var s = newFileStream("tests/test-output.txt", fmWrite) randomize(1234)