Created
August 4, 2013 16:00
-
-
Save BitPuffin/6150802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
TMatrix[T; R, C: range] = array[C, array[R, T]] # A Column major matrix because that's how GLSL stores them [C][R] | |
proc row*[T; R, C: range](m: TMatrix[T, R, C], row: range[R]): TVector[T, R] {.noSideEffect.} = | |
for i in R: | |
result[i] = m[i][row] | |
template col*[T; R, C: range](m: TMatrix[T, R, C], col: range[C]): TVector[T, C] = | |
m[col].TVector | |
proc mul*[T; R, N, C: range](a: TMatrix[T, R, N], b: TMatrix[T, N, C]): TMatrix[T, R, C] {.noSideEffect.} = | |
for i in R: | |
for j in C: | |
result[j][i] = a.row(i).dot(b.col(j)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment