From e8b53ab066c7c66ac574cb6281eb434b0d841d05 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg <guzba8@gmail.com> Date: Wed, 6 Jan 2021 19:55:11 -0600 Subject: [PATCH] 0.4.1 add missing floor, ceil, round --- src/vmath.nim | 18 ++++++++++++++++++ vmath.nimble | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/vmath.nim b/src/vmath.nim index 09a3800..26a37f8 100644 --- a/src/vmath.nim +++ b/src/vmath.nim @@ -121,6 +121,15 @@ proc `length=`*(a: var Vec2, b: float32) {.inline.} = proc normalize*(a: Vec2): Vec2 {.inline.} = a / a.length +proc floor*(a: Vec2): Vec2 {.inline.} = + vec2(floor(a.x), floor(a.y)) + +proc round*(a: Vec2): Vec2 {.inline.} = + vec2(round(a.x), round(a.y)) + +proc ceil*(a: Vec2): Vec2 {.inline.} = + vec2(ceil(a.x), ceil(a.y)) + proc dot*(a, b: Vec2): float32 {.inline.} = a.x * b.x + a.y * b.y @@ -468,6 +477,15 @@ proc zero*(a: var Vec4) {.inline.} = proc hash*(a: Vec4): Hash {.inline.} = hash((a.x, a.y, a.z, a.w)) +proc floor*(a: Vec4): Vec4 {.inline.} = + vec4(floor(a.x), floor(a.y), floor(a.z), floor(a.w)) + +proc round*(a: Vec4): Vec4 {.inline.} = + vec4(round(a.x), round(a.y), round(a.z), round(a.w)) + +proc ceil*(a: Vec4): Vec4 {.inline.} = + vec4(ceil(a.x), ceil(a.y), ceil(a.z), ceil(a.w)) + proc `[]`*(a: Vec4, i: int): float32 = case i of 0: a.x diff --git a/vmath.nimble b/vmath.nimble index 2c71045..9be9409 100644 --- a/vmath.nimble +++ b/vmath.nimble @@ -1,4 +1,4 @@ -version = "0.4.0" +version = "0.4.1" author = "treeform" description = "Math vector library for graphical things." license = "MIT"