From 23b38fa94a8c3582e211a053e0faaa6dcc19fc96 Mon Sep 17 00:00:00 2001 From: Alex Ozer Date: Tue, 26 Aug 2014 16:25:14 -0400 Subject: [PATCH 1/2] Add Array() method --- float64/mat4/mat4.go | 8 ++++++-- mat4/mat4.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/float64/mat4/mat4.go b/float64/mat4/mat4.go index b28fcfb..18a5577 100644 --- a/float64/mat4/mat4.go +++ b/float64/mat4/mat4.go @@ -76,9 +76,13 @@ func (mat *T) Size() int { return 16 } -// Slice returns the elements of the matrix as slice. func (mat *T) Slice() []float64 { - return []float64{ + return mat.Array()[:] +} + +// Array returns the elements of the matrix as slice. +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..1dc28d7 100644 --- a/mat4/mat4.go +++ b/mat4/mat4.go @@ -76,9 +76,13 @@ func (mat *T) Size() int { return 16 } -// 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 slice. +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], From cb1b069a1a93d0e64080274cff15d3cf2a70edae Mon Sep 17 00:00:00 2001 From: Alex Ozer Date: Tue, 26 Aug 2014 16:28:09 -0400 Subject: [PATCH 2/2] Fix Array() method description --- float64/mat4/mat4.go | 3 ++- mat4/mat4.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/float64/mat4/mat4.go b/float64/mat4/mat4.go index 18a5577..be37583 100644 --- a/float64/mat4/mat4.go +++ b/float64/mat4/mat4.go @@ -76,11 +76,12 @@ func (mat *T) Size() int { return 16 } +// Slice returns the elements of the matrix as a slice. func (mat *T) Slice() []float64 { return mat.Array()[:] } -// Array returns the elements of the matrix as slice. +// 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], diff --git a/mat4/mat4.go b/mat4/mat4.go index 1dc28d7..5edb944 100644 --- a/mat4/mat4.go +++ b/mat4/mat4.go @@ -76,11 +76,12 @@ func (mat *T) Size() int { return 16 } +// Slice returns the elements of the matrix as slice. func (mat *T) Slice() []float32 { return mat.Array()[:] } -// Array returns the elements of the matrix as slice. +// 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],