Documentation ¶
Overview ¶
Based on code from github.com/go-gl/mathgl: Copyright 2014 The go-gl Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Based on code from github.com/go-gl/mathgl: Copyright 2014 The go-gl Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- type T
- func Ident() T
- func LookAt(eye, center, up vec3.T) T
- func Orthographic(left, right, bottom, top, near, far float32) T
- func OrthographicRZ(left, right, bottom, top, near, far float32) T
- func Perspective(fovy, aspect, near, far float32) T
- func Scale(scale vec3.T) T
- func Translate(translation vec3.T) T
- func (m *T) Abs() T
- func (m *T) Add(m2 *T) T
- func (m *T) ApproxEqual(m2 *T) bool
- func (m *T) ApproxEqualThreshold(m2 *T, threshold float32) bool
- func (m *T) At(row, col int) float32
- func (m *T) Col(col int) vec4.T
- func (m *T) Cols() (col0, col1, col2, col3 vec4.T)
- func (m *T) Det() float32
- func (m *T) Forward() vec3.T
- func (m *T) Index(row, col int) int
- func (m *T) Invert() T
- func (a *T) Mul(b *T) T
- func (m *T) Origin() vec3.T
- func (m *T) Right() vec3.T
- func (m *T) Row(row int) vec4.T
- func (m *T) Rows() (row0, row1, row2, row3 vec4.T)
- func (m T) Scale(c float32) T
- func (m *T) Set(row, col int, value float32)
- func (m T) String() string
- func (m *T) Sub(m2 *T) T
- func (m *T) Trace() float32
- func (m *T) TransformDir(v vec3.T) vec3.T
- func (m *T) TransformPoint(v vec3.T) vec3.T
- func (m *T) Transpose() T
- func (m *T) Up() vec3.T
- func (m *T) VMul(v vec4.T) vec4.T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
T holds a 4x4 float32 matrix
func Orthographic ¶
Orthographic generates a left-handed orthographic projection matrix. Outputs depth values in the range [0, 1]
func OrthographicRZ ¶
OrthographicRZ generates a left-handed orthographic projection matrix. Outputs depth values in the range [1, 0] (reverse Z)
func Perspective ¶
Perspective generates a left-handed perspective projection matrix with reversed depth. Outputs depth values in the range [0, 1]
func Translate ¶
Translate returns a homogeneous (4x4 for 3D-space) Translation matrix that moves a point by Tx units in the x-direction, Ty units in the y-direction, and Tz units in the z-direction
func (*T) Add ¶
Add performs an element-wise addition of two matrices, this is equivalent to iterating over every element of m and adding the corresponding value of m2.
func (*T) ApproxEqual ¶
ApproxEqual performs an element-wise approximate equality test between two matrices, as if FloatEqual had been used.
func (*T) ApproxEqualThreshold ¶
ApproxEqualThreshold performs an element-wise approximate equality test between two matrices with a given epsilon threshold, as if FloatEqualThreshold had been used.
func (*T) At ¶
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 T asking for At(5,0) will work just like At(1,1). Or it may panic if it's out of bounds.
func (*T) Col ¶
Col returns a vector representing the corresponding column (starting at col 0). This package makes no distinction between row and column vectors, so it will be a normal VecN for a MxN matrix.
func (*T) Cols ¶
Cols decomposes a matrix into its corresponding column vectors. This is equivalent to calling mat.Col for each column.
func (*T) Det ¶
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 (*T) Index ¶
Index returns the index of the given row and column, to be used with direct access. E.G. Index(0,0) = 0.
func (*T) Invert ¶
Invert computes the inverse of a square matrix. An inverse is a square matrix 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 matrix is invertible. If the determinant is 0.0, this function returns the zero matrix. 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.
func (*T) Mul ¶
Mul performs a "matrix product" between this matrix and another of the same dimension
func (*T) Row ¶
Row returns a vector representing the corresponding row (starting at row 0). This package makes no distinction between row and column vectors, so it will be a normal VecM for a MxN matrix.
func (*T) Rows ¶
Rows decomposes a matrix into its corresponding row vectors. This is equivalent to calling mat.Row for each row.
func (T) Scale ¶
Scale performs a scalar multiplcation of the matrix. This is equivalent to iterating over every element of the matrix and multiply it by c.
func (*T) Sub ¶
Sub performs an element-wise subtraction of two matrices, this is equivalent to iterating over every element of m and subtracting the corresponding value of m2.
func (*T) Trace ¶
Trace is a basic operation on a square matrix that simply sums up all elements on the main diagonal (meaning all elements such that row==col).
func (*T) TransformDir ¶
TransformDir transforms a direction vector to world space
func (*T) TransformPoint ¶
TransformPoint transforms a point to world space