# HG changeset patch # User sam # Date 1723640811 -25200 # Node ID 19e3eedb9a41e4925a2552b585a0c755d46080de # Parent 43db6f5abb61ab7b9ca4a6cefa59f4d478d906ff add: ceil and round for vectors diff -r 43db6f5abb61 -r 19e3eedb9a41 semicongine/core/vector.nim --- a/semicongine/core/vector.nim Tue Aug 13 15:28:56 2024 +0700 +++ b/semicongine/core/vector.nim Wed Aug 14 20:06:51 2024 +0700 @@ -178,11 +178,21 @@ 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 round*[T](vec: TVec1[T]): auto = TVec1([round(vec[0])]) +func round*[T](vec: TVec2[T]): auto = TVec2([round(vec[0]), round(vec[1])]) +func round*[T](vec: TVec3[T]): auto = TVec3([round(vec[0]), round(vec[1]), round(vec[2])]) +func round*[T](vec: TVec4[T]): auto = TVec4([round(vec[0]), round(vec[1]), round(vec[2]), round(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 ceil*[T](vec: TVec1[T]): auto = TVec1([ceil(vec[0])]) +func ceil*[T](vec: TVec2[T]): auto = TVec2([ceil(vec[0]), ceil(vec[1])]) +func ceil*[T](vec: TVec3[T]): auto = TVec3([ceil(vec[0]), ceil(vec[1]), ceil(vec[2])]) +func ceil*[T](vec: TVec4[T]): auto = TVec4([ceil(vec[0]), ceil(vec[1]), ceil(vec[2]), ceil(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])