diff --git a/float64/mat4/mat4.go b/float64/mat4/mat4.go index b28fcfb..be37583 100644 --- a/float64/mat4/mat4.go +++ b/float64/mat4/mat4.go @@ -76,9 +76,14 @@ func (mat *T) Size() int { return 16 } -// Slice returns the elements of the matrix as slice. +// Slice returns the elements of the matrix as a slice. func (mat *T) Slice() []float64 { - return []float64{ + return mat.Array()[:] +} + +// Array returns the elements of the matrix as an array. +func (mat *T) Array() *[16]float64 { + return &[16]float64{ mat[0][0], mat[0][1], mat[0][2], mat[0][3], mat[1][0], mat[1][1], mat[1][2], mat[1][3], mat[2][0], mat[2][1], mat[2][2], mat[2][3], diff --git a/mat4/mat4.go b/mat4/mat4.go index 7234bde..5edb944 100644 --- a/mat4/mat4.go +++ b/mat4/mat4.go @@ -78,7 +78,12 @@ func (mat *T) Size() int { // Slice returns the elements of the matrix as slice. func (mat *T) Slice() []float32 { - return []float32{ + return mat.Array()[:] +} + +// Array returns the elements of the matrix as an array. +func (mat *T) Array() *[16]float32 { + return &[16]float32{ mat[0][0], mat[0][1], mat[0][2], mat[0][3], mat[1][0], mat[1][1], mat[1][2], mat[1][3], mat[2][0], mat[2][1], mat[2][2], mat[2][3],