From 8817578a2db96e5258eec4f8ccd33b7488bea083 Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 20 Jul 2021 12:16:00 +0800 Subject: [PATCH 1/4] fix links Before it is `https://github.com/treeform/vmath/blob/master/tests%5Cbench_raytracer.nim` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0954093..5468c6e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Your one stop shop for vector math routines for 2d and 3d graphics. * Pure Nim with no dependencies. * Very similar to GLSL Shader Language with extra stuff. -* Extensively [benchmarked](tests\bench_raytracer.nim). +* Extensively [benchmarked](tests/bench_raytracer.nim). * Docs: https://nimdocs.com/treeform/vmath ## Has vector functions for GLSL types: From 7b55ea0b12accf0b01030af1265b7784f65d9a7b Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 5 Sep 2021 12:15:15 -0500 Subject: [PATCH 2/4] 1.0.11 Mat3 bycopy --- src/vmath.nim | 18 +++++++++--------- vmath.nimble | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/vmath.nim b/src/vmath.nim index 431e387..0411ed9 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -55,9 +55,9 @@ when defined(vmathArrayBased): template `w=`*[T](a: var GVec4[T], value: T) = a[3] = value type - GMat2*[T] = array[2, GVec2[T]] - GMat3*[T] = array[3, GVec3[T]] - GMat4*[T] = array[4, GVec4[T]] + GMat2*[T] {.bycopy.} = array[2, GVec2[T]] + GMat3*[T] {.bycopy.} = array[3, GVec3[T]] + GMat4*[T] {.bycopy.} = array[4, GVec4[T]] GMat234[T] = GMat2[T] | GMat3[T] | GMat4[T] @@ -139,14 +139,14 @@ elif defined(vmathObjBased): cast[ptr T](cast[uint64](a.addr) + i * sizeof(T))[] = v type - GMat2*[T] = object + GMat2*[T] {.bycopy.} = object m00*, m01*: T m10*, m11*: T - GMat3*[T] = object + GMat3*[T] {.bycopy.} = object m00*, m01*, m02*: T m10*, m11*, m12*: T m20*, m21*, m22*: T - GMat4*[T] = object + GMat4*[T] {.bycopy.} = object m00*, m01*, m02*, m03*: T m10*, m11*, m12*, m13*: T m20*, m21*, m22*, m23*: T @@ -271,11 +271,11 @@ elif true or defined(vmathObjArrayBased): template `[]=`*[T](a: var GVec234[T], i: int, v: T) = a.arr[i] = v type - GMat2*[T] = object + GMat2*[T] {.bycopy.} = object arr: array[4, T] - GMat3*[T] = object + GMat3*[T] {.bycopy.} = object arr: array[9, T] - GMat4*[T] = object + GMat4*[T] {.bycopy.} = object arr: array[16, T] proc gmat2*[T]( diff --git a/vmath.nimble b/vmath.nimble index 9c6c8fb..b75b4a1 100644 --- a/vmath.nimble +++ b/vmath.nimble @@ -1,4 +1,4 @@ -version = "1.0.10" +version = "1.0.11" author = "treeform" description = "Your single stop for vector math routines for 2d and 3d graphics." license = "MIT" From fa66fc65386b2647cfed492877616f3e7fbb6b77 Mon Sep 17 00:00:00 2001 From: Andre von Houck Date: Sun, 26 Sep 2021 21:46:49 -0700 Subject: [PATCH 3/4] Small change. --- src/vmath.nim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vmath.nim b/src/vmath.nim index 0411ed9..a1e0d5a 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -1473,17 +1473,18 @@ proc toAxisAngle*[T](q: GVec4[T]): (GVec3[T], T) = proc orthogonal*[T](v: GVec3[T]): GVec3[T] = ## Returns orthogonal vector to given vector. - let v = abs(v) - var other: type(v) = - if v.x < v.y: - if v.x < v.z: - gvec3(T(1), 0, 0) # X_AXIS + let + v = abs(v) + other: type(v) = + if v.x < v.y: + if v.x < v.z: + gvec3(T(1), 0, 0) # X_AXIS + else: + gvec3(T(0), 0, 1) # Z_AXIS + elif v.y < v.z: + gvec3(T(0), 1, 0) # Y_AXIS else: - gvec3(T(0), 0, 1) # Z_AXIS - elif v.y < v.z: - gvec3(T(0), 1, 0) # Y_AXIS - else: - gvec3(T(0), 0, 1) # Z_AXIS + gvec3(T(0), 0, 1) # Z_AXIS return cross(v, other) proc fromTwoVectors*[T](a, b: GVec3[T]): GVec4[T] = @@ -1510,8 +1511,7 @@ proc fromTwoVectors*[T](a, b: GVec3[T]): GVec4[T] = proc nlerp*(a: Quat, b: Quat, v: float32): Quat = if dot(a, b) < 0: - var c = a - (-c * (1.0 - v) + b * v).normalize() + (-a * (1.0 - v) + b * v).normalize() else: (a * (1.0 - v) + b * v).normalize() From 3cda6de7b8438540989ece8b9d9e14cc41c4f323 Mon Sep 17 00:00:00 2001 From: treeform Date: Thu, 30 Sep 2021 16:57:26 -0700 Subject: [PATCH 4/4] Update readme. --- README.md | 11 ++++++++--- vmath.nimble | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5468c6e..5d8b625 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,22 @@ -# VMath +# VMath - 2d and 3d vector math. + +`nimble install vmath` ![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg) -`nimble install vmath` +[API reference](https://nimdocs.com/treeform/vmath) + +This library has no dependencies other than the Nim standard libarary. + +## About Your one stop shop for vector math routines for 2d and 3d graphics. * Pure Nim with no dependencies. * Very similar to GLSL Shader Language with extra stuff. * Extensively [benchmarked](tests/bench_raytracer.nim). -* Docs: https://nimdocs.com/treeform/vmath ## Has vector functions for GLSL types: diff --git a/vmath.nimble b/vmath.nimble index b75b4a1..758b7fc 100644 --- a/vmath.nimble +++ b/vmath.nimble @@ -1,5 +1,5 @@ version = "1.0.11" -author = "treeform" +author = "Andre von Houck" description = "Your single stop for vector math routines for 2d and 3d graphics." license = "MIT"