瀏覽代碼

Added get row and get column for matrix4

Christian Wolfgang 5 年之前
父節點
當前提交
555c99bb81
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      math32/matrix4.go

+ 20 - 0
math32/matrix4.go

@@ -753,3 +753,23 @@ func (m *Matrix4) Clone() *Matrix4 {
 	cloned = *m
 	return &cloned
 }
+
+// GetColumn returns the ith column.
+func (m *Matrix4) GetColumn(i int) *Vector4 {
+	return NewVector4(m[i*4], m[i*4+1], m[i*4+2], m[i*4+3])
+}
+
+// GetRow returns the ith row.
+func (m *Matrix4) GetRow(i int) *Vector4 {
+	return NewVector4(m[i], m[i*4], m[i+8], m[i+12])
+}
+
+// GetColumn returns the ith column.
+func (m *Matrix4) GetColumnVector3(i int) *Vector3 {
+	return NewVector3(m[i*4], m[i*4+1], m[i*4+2])
+}
+
+// GetRow returns the ith row.
+func (m *Matrix4) GetRowVector3(i int) *Vector3 {
+	return NewVector3(m[i], m[i*4], m[i+8])
+}