Mercurial > games > semicongine
comparison semiconginev2/core/matrix.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 |
comparison
equal
deleted
inserted
replaced
1252:01e9f41d35b1 | 1253:c4f98eb4bb05 |
---|---|
101 elif m is TMat34: 12 | 101 elif m is TMat34: 12 |
102 elif m is TMat43: 12 | 102 elif m is TMat43: 12 |
103 elif m is TMat4: 16 | 103 elif m is TMat4: 16 |
104 | 104 |
105 | 105 |
106 func toString[T: TMat](value: T): string = | 106 func toMatString[T: TMat](value: T): string = |
107 var | 107 var |
108 strvalues: seq[string] | 108 strvalues: seq[string] |
109 maxwidth = 0 | 109 maxwidth = 0 |
110 | 110 |
111 for n in value.data: | 111 for n in value.data: |
121 else: | 121 else: |
122 if i mod T.ColumnCount == 0: | 122 if i mod T.ColumnCount == 0: |
123 result &= " " | 123 result &= " " |
124 result &= filler & strvalues[i] & " " | 124 result &= filler & strvalues[i] & " " |
125 | 125 |
126 func `$`*(v: TMat2[SomeNumber]): string = toString[TMat2[SomeNumber]](v) | 126 func `$`*(v: TMat2[SomeNumber]): string = toMatString[TMat2[SomeNumber]](v) |
127 func `$`*(v: TMat23[SomeNumber]): string = toString[TMat23[SomeNumber]](v) | 127 func `$`*(v: TMat23[SomeNumber]): string = toMatString[TMat23[SomeNumber]](v) |
128 func `$`*(v: TMat32[SomeNumber]): string = toString[TMat32[SomeNumber]](v) | 128 func `$`*(v: TMat32[SomeNumber]): string = toMatString[TMat32[SomeNumber]](v) |
129 func `$`*(v: TMat3[SomeNumber]): string = toString[TMat3[SomeNumber]](v) | 129 func `$`*(v: TMat3[SomeNumber]): string = toMatString[TMat3[SomeNumber]](v) |
130 func `$`*(v: TMat34[SomeNumber]): string = toString[TMat34[SomeNumber]](v) | 130 func `$`*(v: TMat34[SomeNumber]): string = toMatString[TMat34[SomeNumber]](v) |
131 func `$`*(v: TMat43[SomeNumber]): string = toString[TMat43[SomeNumber]](v) | 131 func `$`*(v: TMat43[SomeNumber]): string = toMatString[TMat43[SomeNumber]](v) |
132 func `$`*(v: TMat4[SomeNumber]): string = toString[TMat4[SomeNumber]](v) | 132 func `$`*(v: TMat4[SomeNumber]): string = toMatString[TMat4[SomeNumber]](v) |
133 | 133 |
134 func `[]`*[T: TMat](m: T, row, col: int): auto = m.data[col + row * T.ColumnCount] | 134 func `[]`*[T: TMat](m: T, row, col: int): auto = m.data[col + row * T.ColumnCount] |
135 func `[]=`*[T: TMat, U](m: var T, row, col: int, value: U) = m.data[col + row * T.ColumnCount] = value | 135 func `[]=`*[T: TMat, U](m: var T, row, col: int, value: U) = m.data[col + row * T.ColumnCount] = value |
136 func `[]`*[T: TMat](m: T, i: int): auto = m.data[i] | 136 func `[]`*[T: TMat](m: T, i: int): auto = m.data[i] |
137 func `[]=`*[T: TMat, U](m: var T, i: int, value: U) = m.data[i] = value | 137 func `[]=`*[T: TMat, U](m: var T, i: int, value: U) = m.data[i] = value |