changeset 1319:43db6f5abb61

add: more vector utils
author sam <sam@basx.dev>
date Tue, 13 Aug 2024 15:28:56 +0700
parents 03400de84910
children 19e3eedb9a41
files semicongine/core/vector.nim
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/core/vector.nim	Tue Aug 13 14:45:18 2024 +0700
+++ b/semicongine/core/vector.nim	Tue Aug 13 15:28:56 2024 +0700
@@ -178,6 +178,11 @@
 func abs*[T](vec: TVec3[T]): auto = TVec3([abs(vec[0]), abs(vec[1]), abs(vec[2])])
 func abs*[T](vec: TVec4[T]): auto = TVec4([abs(vec[0]), abs(vec[1]), abs(vec[2]), abs(vec[3])])
 
+func floor*[T](vec: TVec1[T]): auto = TVec1([floor(vec[0])])
+func floor*[T](vec: TVec2[T]): auto = TVec2([floor(vec[0]), floor(vec[1])])
+func floor*[T](vec: TVec3[T]): auto = TVec3([floor(vec[0]), floor(vec[1]), floor(vec[2])])
+func floor*[T](vec: TVec4[T]): auto = TVec4([floor(vec[0]), floor(vec[1]), floor(vec[2]), floor(vec[3])])
+
 func manhattan*(vec: TVec1): auto = abs(vec[0])
 func manhattan*(vec: TVec2): auto = abs(vec[0]) + abs(vec[1])
 func manhattan*(vec: TVec3): auto = abs(vec[0]) + abs(vec[1]) + abs(vec[2])