Discover Packages
github.com/gremour/n-bit
pkg
mat
package
Version:
v0.1.4
Opens a new window with list of versions in this module.
Published: Jan 7, 2022
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Jump to ...
Documentation
Index
Constants
Variables
Functions
Types
type Matrix3
type Matrix4
Matrix4Frustum(l, r, t, b, n, f)
Matrix4Ortho(l, r, t, b, n, f)
Matrix4Rotate(angle, x, y, z)
Matrix4Scale(x, y, z)
Matrix4Translate(x, y, z)
(m) DotMatrix(o)
(m) Rotate(angle, x, y, z)
(m) Scale(x, y, z)
(m) Translate(x, y, z)
type Vector3
type Vector4
type Viewport
Source Files
Documentation
Documentation
¶
Variables
func FovToY(fov, n float64) float64
func Normalize(x, y, z float64) (xn, yn, zn float64)
type Matrix3
type Matrix4
func Matrix4Frustum(l, r, t, b, n, f float64) Matrix4
func Matrix4Ortho(l, r, t, b, n, f float64) Matrix4
func Matrix4Rotate(angle, x, y, z float64) Matrix4
func Matrix4Scale(x, y, z float64) Matrix4
func Matrix4Translate(x, y, z float64) Matrix4
type Vector3
type Vector4
type Viewport
View Source
var Identity4 = Matrix4 {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
}
FovToY returns y coordinate to pass to Matrix4Frustum as
(-y, y, -y, y) for given field of view (in degrees) and near coordinate.
Example usage:
near := 1
far := 10
fov := 120
y := FovToY(fov, near)
m := Matrix4Frustum(-y, y, -y, y, near, far)
Normalize returns normalized vector of length 1.
Matrix3 is 3x3 matrix for 2D transformations.
Matrix3Rotate creates rotation 3x3 matrix that rotates point by provided angle in degrees.
Matrix3Scale creates scaling 2x2 matrix that
scales points with provided scale factors.
Matrix3Translate creates translation 3x3 matrix that
translates points along axes.
DotMatrix calculates dot product of m·o.
The result is stored in m.
Rotate applies rotation transformation that rotates point
by the provided angle in degrees.
Scale applies scaling transformation that
scales points with provided scale factors.
Translate applies translation transformation that
translates points along axes.
Matrix4 is 4x4 matrix for 3D transformations.
Matrix4Frustum creates frustrum projection 4x4 matrix.
Matrix4Ortho creates orthographic projection 4x4 matrix.
Matrix4Rotate creates rotation 4x4 matrix that rotates point around unit
vector (x, y, z) by the provided angle in degrees.
Vector must be normalized.
Matrix4Scale creates scaling 4x4 matrix that
scales points with provided scale factors.
Matrix4Translate creates translation 4x4 matrix that
translates points along axes.
DotMatrix calculates dot product of m·o.
The result is stored in m.
Rotate applies rotation transformation that rotates point around unit
vector (x, y, z) by the provided angle in degrees.
Vector must be normalized.
Scale applies scaling transformation that
scales points with provided scale factors.
Translate applies translation transformation that
translates points along axes.
Vector3 is 1x3 matrix for 2D transformations and coordinate representation.
MatrixDot calculates dot product of m·v where v is a column vector.
The result is stored in v.
Vector4 is 1x4 matrix for 3D transformations and coordinate representation.
MatrixDot calculates dot product of m·v where v is a column vector.
The result is stored in v.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.