-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
import linagl/vector
import math
type
TMatrix*[T; R, C: static[int]] = array[0..R-1, array[0..C-1, T]] ## Row major matrix type.
TMat4* = TMatrix[float32, 4, 4]
template row*[T; R, C: static[int]](m: TMatrix[T, R, C], rowidx: range[0..R-1]): TVector[T, R] =
m[rowidx]
proc col*[T; R, C: static[int]](m: TMatrix[T, R, C], colidx: range[0..C-1]): TVector[T, C] {.noSideEffect.} =
for i in low(m)..high(m):
result[i] = m[i][colidx]
proc `*`*[T; R, N, C: static[int]](a: TMatrix[T, R, N], b: TMatrix[T, N, C]): TMatrix[T, R, C] {.noSideEffect.} =
for i in low(a)..high(a):
for j in low(a[i])..high(a[i]):
result[i][j] = a.row(i) *. b.col(j)
proc translate*(v: TVec4): TMat4 {.noSideEffect.} =
result = [[1f32, 0f32, 0f32, 0f32],
[0f32, 1f32, 0f32, 0f32],
[0f32, 0f32, 1f32, 0f32],
[v[0], v[1], v[2], 1f32]]
proc rotatex*(angle: float): TMat4 =
result = [[1f32, 0f32, 0f32, 0f32],
[0f32, cos(angle).float32, sin(angle).float32, 0f32],
[0f32, -sin(angle).float32, cos(angle).float32, 0f32],
[0f32, 0f32, 0f32, 1f32]]
proc orbitxAround(point: TVec4, angle: float): TMat4 =
result = translate(-point)*rotatex(angle)*translate(point)Error:
matrix.nim(34, 20) Info: instantiation from here
matrix.nim(34, 20) Info: instantiation from here
matrix.nim(16, 49) Error: internal error: cannot generate code for: R
No stack traceback available
It appears that it doesn't know ho to map the R and C of TMat4 to TMatrix. The instantiation is in orbitxAround