# HG changeset patch # User sam # Date 1723282162 -25200 # Node ID 4dbb9a0a6930fb6b08ccc80ed6045de4d45ca43e # Parent f7994a03b802304271eb705853d40206fe341b16 add: manhatten distance diff -r f7994a03b802 -r 4dbb9a0a6930 semicongine/core/vector.nim --- a/semicongine/core/vector.nim Fri Aug 09 23:32:08 2024 +0700 +++ b/semicongine/core/vector.nim Sat Aug 10 16:29:22 2024 +0700 @@ -146,6 +146,11 @@ func length*(vec: TVec4[SomeFloat]): auto = sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]) func length*(vec: TVec4[SomeInteger]): auto = sqrt(float(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * 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]) +func manhattan*(vec: TVec4): auto = abs(vec[0]) + abs(vec[1]) + abs(vec[2]) + abs(vec[3]) + func normal*[T: SomeFloat](vec: TVec2[T]): auto = TVec2[T]([vec[1], -vec[0]])