From a4662ebf0a35ba4697ca5284077e74149ae896cb Mon Sep 17 00:00:00 2001 From: treeform Date: Fri, 26 Mar 2021 15:15:21 -0700 Subject: [PATCH] Fix bug with perspective and add back nlerp. --- src/vmath.nim | 11 +++++++++-- vmath.nimble | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vmath.nim b/src/vmath.nim index 4539625..18a43e4 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -777,8 +777,8 @@ proc frustum*[T](left, right, bottom, top, near, far: T): GMat4[T] = proc perspective*[T](fovy, aspect, near, far: T): GMat4[T] = let - top = near * tan(fovy * PI / 360.0) - right = top * aspect + top: T = near * tan(fovy * PI.float32 / 360.0) + right: T = top * aspect frustum(-right, right, -top, top, near, far) proc ortho*[T](left, right, bottom, top, near, far: T): GMat4[T] = @@ -980,6 +980,13 @@ proc fromTwoVectors*[T](a, b: GVec3[T]): GVec4[T] = w = dot(u, half) return [q.x, q.y, q.z, w] +proc nlerp*(a: Quat, b: Quat, v: float32): Quat = + if dot(a, b) < 0: + var c = a + (-c * (1.0 - v) + b * v).normalize() + else: + (a * (1.0 - v) + b * v).normalize() + proc quat*[T](m: GMat4[T]): GVec4[T] = let m00 = m[0, 0] diff --git a/vmath.nimble b/vmath.nimble index a90da73..e410a79 100644 --- a/vmath.nimble +++ b/vmath.nimble @@ -1,4 +1,4 @@ -version = "1.0.0" +version = "1.0.1" author = "treeform" description = "Your single stop for vector math routines for 2d and 3d graphics." license = "MIT"