matrix

package
v0.0.0-...-ddc071b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MAT2 = 2
View Source
const MAT2_SIZE = 4
View Source
const MAT3 = 3
View Source
const MAT3_SIZE = 9
View Source
const MAT4 = 4
View Source
const MAT4_SIZE = 16

Variables

This section is empty.

Functions

func Det2

func Det2(a Mat) float32

Det2() Handles this matrix as size 2 matrix and returns the determinant

func Dim

func Dim(M Mat) int

Dim Returns Dimensionality of Square Matrix Based on Size...If size not recognized Then Dim returns non nil error

func Map

func Map(i int, j int, mat_size int) int

MAPS any 2D Matrix Position to its linear ROW-Major order layout in memory with the returned index being 0 for invalid inputs

func MatEqual

func MatEqual(a Mat, e Mat) bool

MatEqual returns two Matrixes equal by epsilon value comparision

Types

type Mat

type Mat []float32

func Mat2

func Mat2(v float32) Mat

Mat2 Creates new float slice type Mat of length 2 set to identity val

func Mat2V

func Mat2V(v0 vector.Vec, v1 vector.Vec) Mat

Mat2 Constructs Custom 2x2 Mat from construction vectors v0,v1

func Mat3

func Mat3(v float32) Mat

Mat2 Creates new float slice type Mat of length 2 set to identity val

func Mat3T4

func Mat3T4(a Mat) Mat

func Mat3V

func Mat3V(v0 vector.Vec, v1 vector.Vec, v2 vector.Vec) Mat

Mat3 Constructs Custom 3x3 Mat from construction vectors v0,v1, v2

func Mat4

func Mat4(v float32) Mat

Mat2 Creates new float slice type Mat of length 2 set to identity val

func Mat4V

func Mat4V(v0 vector.Vec, v1 vector.Vec, v2 vector.Vec, v3 vector.Vec) Mat

Mat4 Constructs Custom 4x4 Mat from construction vectors v0,v1, v2

func MatN

func MatN(dim int, v float32) Mat

MatN Creates new float slice type Mat of length 2 set to identity val

func MulM

func MulM(a Mat, b Mat) Mat

Multplies two matrices with mutation into left associated A

func ProjectionMat

func ProjectionMat(l float32, r float32, t float32, b float32, n float32, f float32) Mat

Projection Mat creates a projection Mat

func ProjectionMatF

func ProjectionMatF(fov float32, aspect float32, n float32, f float32) Mat

Projection Mat creates a projection Mat

func (Mat) Copy

func (m Mat) Copy() Mat

Copy returns a new matrix copy from the addressed Mat object

func (Mat) CrossVec

func (a Mat) CrossVec(b vector.Vec) vector.Vec

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) Det

func (a Mat) Det() float32

func (Mat) Det2

func (a Mat) Det2() float32

Det2() Handles this matrix as size 2 matrix and returns the determinant

func (Mat) Det3

func (m Mat) Det3() float32

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) Det4

func (m Mat) Det4() float32

Det Solves the 4x4 Mat Determinant

func (Mat) Dim

func (M Mat) Dim() int

Dim Returns Dimensionality of Square Matrix Based on Size...If size not recognized Then Dim returns non nil error

func (Mat) Get

func (m Mat) Get(row int) vector.Vec

Get obtains the Row vector.Vector from the parameter row copies vector value into a new vector and returns.

func (Mat) Inv

func (m Mat) Inv() Mat

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

func (m Mat) Inv2() Mat

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) Inv3

func (m Mat) Inv3() Mat

Inverse solves the 3x3 Mat through determinant

func (Mat) Mul

func (m1 Mat) Mul(c float32) Mat

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) MulM

func (a Mat) MulM(b Mat) Mat

Multplies two matrices with mutation into left associated A

func (Mat) Normalize

func (M Mat) Normalize() Mat

Normalize normalizes the current matrix. This operation is a mutating operation WARNING THIS OPERATION IS A MUTATION OF THE CURRENT MATRIX

func (Mat) Set

func (m Mat) Set(row int, v vector.Vec)

Set(row int, v vector.Vec) sets a matrix row to the specified vector WARNING this is a mutatiing @MUTATE operation that changes the internal Values of the referenced matrix M

func (Mat) String

func (a Mat) String() string

Mat Print Operations

func (Mat) Transpose

func (a Mat) Transpose() Mat

Transpose Matrix reverses matrix index positions for square matrixes only Transpose is a non mutating function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL