diff --git a/src/vmath.nim b/src/vmath.nim index ab15289..c03fec3 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -499,7 +499,11 @@ proc `~=`*[T](a, b: GMat4[T]): bool = a[0] ~= b[0] and a[1] ~= b[1] and a[2] ~= b[2] and a[3] ~= b[3] proc pos*[T](a: GMat3[T]): GVec2[T] = - return [a[2][2], a[2][1]] + [a[2][0], a[2][1]] + +proc `pos=`*[T](a: var GMat3[T], pos: GVec2[T]) = + a[2][0] = pos.x + a[2][1] = pos.y proc `*`*[T](a, b: GMat3[T]): GMat3[T] = result[0, 0] = b[0, 0] * a[0, 0] + b[0, 1] * a[1, 0] + b[0, 2] * a[2, 0] diff --git a/tests/test.nim b/tests/test.nim index 4bd01bd..90e2d10 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -355,6 +355,12 @@ block: [0.0, 0.0, 0.0, 1.0] ] + doAssert translate(vec2(1, 2)).pos == vec2(1, 2) + + var translation = translate(vec2(1, 2)) + translation.pos = vec2(3, 4) + doAssert translation.pos == vec2(3, 4) + block: # Test basic vector mat4 and quat. var m1 = mat4( diff --git a/vmath.nimble b/vmath.nimble index af78ac5..6e38ff6 100644 --- a/vmath.nimble +++ b/vmath.nimble @@ -1,4 +1,4 @@ -version = "1.0.3" +version = "1.0.4" author = "treeform" description = "Your single stop for vector math routines for 2d and 3d graphics." license = "MIT"