Mercurial > games > semicongine
changeset 1314:4dbb9a0a6930
add: manhatten distance
author | sam <sam@basx.dev> |
---|---|
date | Sat, 10 Aug 2024 16:29:22 +0700 |
parents | f7994a03b802 |
children | 27395a38d882 |
files | semicongine/core/vector.nim |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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]])