Mercurial > games > semicongine
diff semiconginev2/core/vector.nim @ 1253:c4f98eb4bb05
fix: a few things
author | sam <sam@basx.dev> |
---|---|
date | Fri, 26 Jul 2024 23:39:24 +0700 |
parents | 56781cc0fc7c |
children | b0f4c8ccd49a |
line wrap: on
line diff
--- a/semiconginev2/core/vector.nim Fri Jul 26 23:04:01 2024 +0700 +++ b/semiconginev2/core/vector.nim Fri Jul 26 23:39:24 2024 +0700 @@ -102,16 +102,16 @@ func To*[T](v: TVec3): auto = TVec3([T(v[0]), T(v[1]), T(v[2])]) func To*[T](v: TVec4): auto = TVec4([T(v[0]), T(v[1]), T(v[2]), T(v[3])]) -func toString[T: TVec](value: T): string = +func toVecString[T: TVec](value: T): string = var items: seq[string] for item in value: items.add(&"{item.float:.5f}") & "(" & join(items, " ") & ")" -func `$`*(v: TVec1[SomeNumber]): string = toString[TVec1[SomeNumber]](v) -func `$`*(v: TVec2[SomeNumber]): string = toString[TVec2[SomeNumber]](v) -func `$`*(v: TVec3[SomeNumber]): string = toString[TVec3[SomeNumber]](v) -func `$`*(v: TVec4[SomeNumber]): string = toString[TVec4[SomeNumber]](v) +func `$`*(v: TVec1[SomeNumber]): string = toVecString[TVec1[SomeNumber]](v) +func `$`*(v: TVec2[SomeNumber]): string = toVecString[TVec2[SomeNumber]](v) +func `$`*(v: TVec3[SomeNumber]): string = toVecString[TVec3[SomeNumber]](v) +func `$`*(v: TVec4[SomeNumber]): string = toVecString[TVec4[SomeNumber]](v) func Length*(vec: TVec1): auto = vec[0] func Length*(vec: TVec2[SomeFloat]): auto = sqrt(vec[0] * vec[0] + vec[1] * vec[1])