doc
stringlengths
10
26.3k
code
stringlengths
52
3.87M
// Mul performs a scalar multiplcation of the matrix. This is equivalent to iterating // over every element of the matrix and multiply it by c.
func (m1 Mat2x3) Mul(c float64) Mat2x3 { return Mat2x3{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c} }
// At returns the matrix element at the given row and column. // This is equivalent to mat[col * numRow + row] where numRow is constant // (E.G. for a Mat3x2 it's equal to 3) // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // At(5,0) will work just like At(1,1). Or it may panic if it's o...
func (m Mat2x3) At(row, col int) float64 { return m[col*2+row] }
// Set sets the corresponding matrix element at the given row and column. // This has a pointer receiver because it mutates the matrix. // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // Set(5,0,val) will work just like Set(1,1,val). Or it may panic if it's out of bounds.
func (m *Mat2x3) Set(row, col int, value float64) { m[col*2+row] = value }
// Mul performs a scalar multiplcation of the matrix. This is equivalent to iterating // over every element of the matrix and multiply it by c.
func (m1 Mat2x4) Mul(c float64) Mat2x4 { return Mat2x4{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c, m1[6] * c, m1[7] * c} }
// At returns the matrix element at the given row and column. // This is equivalent to mat[col * numRow + row] where numRow is constant // (E.G. for a Mat3x2 it's equal to 3) // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // At(5,0) will work just like At(1,1). Or it may panic if it's o...
func (m Mat2x4) At(row, col int) float64 { return m[col*2+row] }
// Set sets the corresponding matrix element at the given row and column. // This has a pointer receiver because it mutates the matrix. // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // Set(5,0,val) will work just like Set(1,1,val). Or it may panic if it's out of bounds.
func (m *Mat2x4) Set(row, col int, value float64) { m[col*2+row] = value }
// Mul performs a scalar multiplcation of the matrix. This is equivalent to iterating // over every element of the matrix and multiply it by c.
func (m1 Mat3x2) Mul(c float64) Mat3x2 { return Mat3x2{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c} }
// At returns the matrix element at the given row and column. // This is equivalent to mat[col * numRow + row] where numRow is constant // (E.G. for a Mat3x2 it's equal to 3) // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // At(5,0) will work just like At(1,1). Or it may panic if it's o...
func (m Mat3x2) At(row, col int) float64 { return m[col*3+row] }
// Set sets the corresponding matrix element at the given row and column. // This has a pointer receiver because it mutates the matrix. // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // Set(5,0,val) will work just like Set(1,1,val). Or it may panic if it's out of bounds.
func (m *Mat3x2) Set(row, col int, value float64) { m[col*3+row] = value }
// Mul performs a scalar multiplcation of the matrix. This is equivalent to iterating // over every element of the matrix and multiply it by c.
func (m1 Mat3) Mul(c float64) Mat3 { return Mat3{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c, m1[6] * c, m1[7] * c, m1[8] * c} }
// Det returns the determinant of a matrix. It is a measure of a square matrix's // singularity and invertability, among other things. In this library, the // determinant is hard coded based on pre-computed cofactor expansion, and uses // no loops. Of course, the addition and multiplication must still be done.
func (m Mat3) Det() float64 { return m[0]*m[4]*m[8] + m[3]*m[7]*m[2] + m[6]*m[1]*m[5] - m[6]*m[4]*m[2] - m[3]*m[1]*m[8] - m[0]*m[7]*m[5] }
// At returns the matrix element at the given row and column. // This is equivalent to mat[col * numRow + row] where numRow is constant // (E.G. for a Mat3x2 it's equal to 3) // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // At(5,0) will work just like At(1,1). Or it may panic if it's o...
func (m Mat3) At(row, col int) float64 { return m[col*3+row] }
// Set sets the corresponding matrix element at the given row and column. // This has a pointer receiver because it mutates the matrix. // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // Set(5,0,val) will work just like Set(1,1,val). Or it may panic if it's out of bounds.
func (m *Mat3) Set(row, col int, value float64) { m[col*3+row] = value }
// Mul performs a scalar multiplcation of the matrix. This is equivalent to iterating // over every element of the matrix and multiply it by c.
func (m1 Mat3x4) Mul(c float64) Mat3x4 { return Mat3x4{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c, m1[6] * c, m1[7] * c, m1[8] * c, m1[9] * c, m1[10] * c, m1[11] * c} }
// At returns the matrix element at the given row and column. // This is equivalent to mat[col * numRow + row] where numRow is constant // (E.G. for a Mat3x2 it's equal to 3) // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // At(5,0) will work just like At(1,1). Or it may panic if it's o...
func (m Mat3x4) At(row, col int) float64 { return m[col*3+row] }
// Set sets the corresponding matrix element at the given row and column. // This has a pointer receiver because it mutates the matrix. // // This method is garbage-in garbage-out. For instance, on a Mat4 asking for // Set(5,0,val) will work just like Set(1,1,val). Or it may panic if it's out of bounds.
func (m *Mat3x4) Set(row, col int, value float64) { m[col*3+row] = value }