matrixalgo.nim 597 B

1234567891011121314151617181920212223242526272829
  1. import typetraits
  2. type
  3. AnyMatrix*[R, C: static[int]; T] = concept m, var mvar, type M
  4. M.ValueType is T
  5. M.Rows == R
  6. M.Cols == C
  7. m[int, int] is T
  8. mvar[int, int] = T
  9. type TransposedType = stripGenericParams(M)[C, R, T]
  10. AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T]
  11. AnyTransform3D* = AnyMatrix[4, 4, float]
  12. proc transposed*(m: AnyMatrix): m.TransposedType =
  13. for r in 0 .. <m.R:
  14. for c in 0 .. <m.C:
  15. result[r, c] = m[c, r]
  16. proc determinant*(m: AnySquareMatrix): int =
  17. return 0
  18. proc setPerspectiveProjection*(m: AnyTransform3D) =
  19. discard