mat

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Identity3 = Matrix3{
	1, 0, 0,
	0, 1, 0,
	0, 0, 1,
}
View Source
var Identity4 = Matrix4{
	1, 0, 0, 0,
	0, 1, 0, 0,
	0, 0, 1, 0,
	0, 0, 0, 1,
}

Functions

func FovToY

func FovToY(fov, n float64) float64

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)

func Normalize

func Normalize(x, y, z float64) (xn, yn, zn float64)

Normalize returns normalized vector of length 1.

Types

type Matrix3

type Matrix3 [9]float64

Matrix3 is 3x3 matrix for 2D transformations.

func Matrix3Rotate

func Matrix3Rotate(angle float64) Matrix3

Matrix3Rotate creates rotation 3x3 matrix that rotates point by provided angle in degrees.

func Matrix3Scale

func Matrix3Scale(x, y float64) Matrix3

Matrix3Scale creates scaling 2x2 matrix that scales points with provided scale factors.

func Matrix3Translate

func Matrix3Translate(x, y float64) Matrix3

Matrix3Translate creates translation 3x3 matrix that translates points along axes.

func (*Matrix3) DotMatrix

func (m *Matrix3) DotMatrix(o *Matrix3)

DotMatrix calculates dot product of m·o. The result is stored in m.

func (*Matrix3) Rotate

func (m *Matrix3) Rotate(angle float64)

Rotate applies rotation transformation that rotates point by the provided angle in degrees.

func (*Matrix3) Scale

func (m *Matrix3) Scale(x, y float64)

Scale applies scaling transformation that scales points with provided scale factors.

func (*Matrix3) Translate

func (m *Matrix3) Translate(x, y float64)

Translate applies translation transformation that translates points along axes.

type Matrix4

type Matrix4 [16]float64

Matrix4 is 4x4 matrix for 3D transformations.

func Matrix4Frustum

func Matrix4Frustum(l, r, t, b, n, f float64) Matrix4

Matrix4Frustum creates frustrum projection 4x4 matrix.

func Matrix4Ortho

func Matrix4Ortho(l, r, t, b, n, f float64) Matrix4

Matrix4Ortho creates orthographic projection 4x4 matrix.

func Matrix4Rotate

func Matrix4Rotate(angle, x, y, z float64) Matrix4

Matrix4Rotate creates rotation 4x4 matrix that rotates point around unit vector (x, y, z) by the provided angle in degrees. Vector must be normalized.

func Matrix4Scale

func Matrix4Scale(x, y, z float64) Matrix4

Matrix4Scale creates scaling 4x4 matrix that scales points with provided scale factors.

func Matrix4Translate

func Matrix4Translate(x, y, z float64) Matrix4

Matrix4Translate creates translation 4x4 matrix that translates points along axes.

func (*Matrix4) DotMatrix

func (m *Matrix4) DotMatrix(o *Matrix4)

DotMatrix calculates dot product of m·o. The result is stored in m.

func (*Matrix4) Rotate

func (m *Matrix4) Rotate(angle, x, y, z float64)

Rotate applies rotation transformation that rotates point around unit vector (x, y, z) by the provided angle in degrees. Vector must be normalized.

func (*Matrix4) Scale

func (m *Matrix4) Scale(x, y, z float64)

Scale applies scaling transformation that scales points with provided scale factors.

func (*Matrix4) Translate

func (m *Matrix4) Translate(x, y, z float64)

Translate applies translation transformation that translates points along axes.

type Vector3

type Vector3 [3]float64

Vector3 is 1x3 matrix for 2D transformations and coordinate representation.

func (*Vector3) MatrixDot

func (v *Vector3) MatrixDot(m *Matrix3)

MatrixDot calculates dot product of m·v where v is a column vector. The result is stored in v.

type Vector4

type Vector4 [4]float64

Vector4 is 1x4 matrix for 3D transformations and coordinate representation.

func (*Vector4) MatrixDot

func (v *Vector4) MatrixDot(m *Matrix4)

MatrixDot calculates dot product of m·v where v is a column vector. The result is stored in v.

func (*Vector4) ViewportProject

func (v *Vector4) ViewportProject(vp *Viewport)

func (*Vector4) WDiv

func (v *Vector4) WDiv()

type Viewport

type Viewport struct {
	Left   float64
	Top    float64
	Width  float64
	Height float64
	Near   float64
	Far    float64
	// contains filtered or unexported fields
}

func NewViewport

func NewViewport(l, t, w, h, n, f float64) Viewport

Jump to

Keyboard shortcuts

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