Documentation
¶
Index ¶
- Constants
- func Det2(a Mat) float32
- func Dim(M Mat) int
- func Map(i int, j int, mat_size int) int
- func MatEqual(a Mat, e Mat) bool
- type Mat
- func Mat2(v float32) Mat
- func Mat2V(v0 vector.Vec, v1 vector.Vec) Mat
- func Mat3(v float32) Mat
- func Mat3T4(a Mat) Mat
- func Mat3V(v0 vector.Vec, v1 vector.Vec, v2 vector.Vec) Mat
- func Mat4(v float32) Mat
- func Mat4V(v0 vector.Vec, v1 vector.Vec, v2 vector.Vec, v3 vector.Vec) Mat
- func MatN(dim int, v float32) Mat
- func MulM(a Mat, b Mat) Mat
- func ProjectionMat(l float32, r float32, t float32, b float32, n float32, f float32) Mat
- func ProjectionMatF(fov float32, aspect float32, n float32, f float32) Mat
- func (m Mat) Copy() Mat
- func (a Mat) CrossVec(b vector.Vec) vector.Vec
- func (a Mat) Det() float32
- func (a Mat) Det2() float32
- func (m Mat) Det3() float32
- func (m Mat) Det4() float32
- func (M Mat) Dim() int
- func (m Mat) Get(row int) vector.Vec
- func (m Mat) Inv() Mat
- func (m Mat) Inv2() Mat
- func (m Mat) Inv3() Mat
- func (m1 Mat) Mul(c float32) Mat
- func (a Mat) MulM(b Mat) Mat
- func (M Mat) Normalize() Mat
- func (m Mat) Set(row int, v vector.Vec)
- func (a Mat) String() string
- func (a Mat) Transpose() Mat
Constants ¶
const MAT2 = 2
const MAT2_SIZE = 4
const MAT3 = 3
const MAT3_SIZE = 9
const MAT4 = 4
const MAT4_SIZE = 16
Variables ¶
This section is empty.
Functions ¶
func Dim ¶
Dim Returns Dimensionality of Square Matrix Based on Size...If size not recognized Then Dim returns non nil error
Types ¶
type Mat ¶
type Mat []float32
func ProjectionMat ¶
Projection Mat creates a projection Mat
func ProjectionMatF ¶
Projection Mat creates a projection Mat
func (Mat) CrossVec ¶
Crossvector.Vec crosses a matrix with a vector by summing the Matrix Row (Row Major) With the associative column vector. Assuming matrices are all MxM in this LIBRARY vector.Vector is returned length M
func (Mat) Det3 ¶
Det calcs the 3x3 Determinant return m[0][0] *(m[1][1]M[2][2] - m[1][2]M[2][1]) - m[0][1]*(m[1][0]M[2][2] - m[1][2]M[2][0]) - m[0][2]*(m[1][0]M[2][1]-m[1][1]M[2][0])
func (Mat) Dim ¶
Dim Returns Dimensionality of Square Matrix Based on Size...If size not recognized Then Dim returns non nil error
func (Mat) Get ¶
Get obtains the Row vector.Vector from the parameter row copies vector value into a new vector and returns.
func (Mat) Inv ¶
Inv computes the inverse of a square Mat. An inverse is a square Mat such that when multiplied by the original, yields the identity.
M_inv * M = M * M_inv = I
In this library, the math is precomputed, and uses no loops, though the multiplications, additions, determinant calculation, and scaling are still done. This can still be (relatively) expensive for a 4x4.
This function checks the determinant to see if the Mat is invertible. If the determinant is 0.0, this function returns the zero Mat. However, due to floating point errors, it is entirely plausible to get a false positive or negative. In the future, an alternate function may be written which takes in a pre-computed determinant. Tries to simplify main call for matrixes of different dimensions by delgating to other calls if the dimension aren't equal
func (Mat) Inv2 ¶
Inverse2() Computes the Matrix Inverse of a 2 Sized Matrix for now all inverse And determinant functinos will be named since they are inmplemented differently Inverse 2 is non mutating and delgates the value of the new matrix
func (Mat) Mul ¶
Mul performs a scalar multiplcation of the Mat. This is equivalent to iterating over every element of the Mat and multiply it by c.
func (Mat) Normalize ¶
Normalize normalizes the current matrix. This operation is a mutating operation WARNING THIS OPERATION IS A MUTATION OF THE CURRENT MATRIX