matrix

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Identity = Matrix{
	{1, 0, 0, 0},
	{0, 1, 0, 0},
	{0, 0, 1, 0},
	{0, 0, 0, 1},
}

Identity is a matrix that does a 1:1 scale, no rotation and no translation.

Functions

This section is empty.

Types

type Matrix

type Matrix [4][4]float64

Matrix is a 4x4 homogeneous matrix used to transform an object's points from 'Object Space' to 'Parent Space'. When broken into scale, rotation, and translation components, it is best constructed in the order T * R * S, where transformations are applied from right to left. The object is scaled first, then rotated around its origin in 'Object Space', and finally translated in 'Parent Space' to its final position. This sequence is largely a matter of choice, but it is often considered the most intuitive.

func RotateX

func RotateX(theta float64) Matrix

RotateX applies a rotation about the X axis. `theta` is measured in Radians.

func RotateY

func RotateY(theta float64) Matrix

RotateY applies a rotation about the Y axis. `theta` is measured in Radians.

func RotateZ

func RotateZ(theta float64) Matrix

RotateZ applies a rotation about the Z axis. `theta` is measured in Radians.

func Scale

func Scale(sx, sy, sz float64) Matrix

func Translate

func Translate(tx, ty, tz float64) Matrix

func (Matrix) Determinant

func (m Matrix) Determinant() float64

func (Matrix) Equal

func (l Matrix) Equal(r Matrix) bool

func (Matrix) Invert

func (m Matrix) Invert() (inv Matrix, ok bool)

func (Matrix) Mul

func (l Matrix) Mul(r Matrix) Matrix

Multiply 4x4 matrices. Uses 64 multiplications and 48 additions.

func (Matrix) RotateX

func (m Matrix) RotateX(theta float64) Matrix

RotateX applies a rotation about the X axis. `theta` is measured in Radians.

func (Matrix) RotateY

func (m Matrix) RotateY(theta float64) Matrix

RotateY applies a rotation about the Y axis. `theta` is measured in Radians.

func (Matrix) RotateZ

func (m Matrix) RotateZ(theta float64) Matrix

RotateZ applies a rotation about the Z axis. `theta` is measured in Radians.

func (Matrix) Scale

func (m Matrix) Scale(sx, sy, sz float64) Matrix

func (Matrix) Transform

func (m Matrix) Transform(vx, vy, vz, vw float64) (x, y, z, w float64)

Transform a vector. Uses 16 multiplications and 12 additions.

func (Matrix) Transform3

func (m Matrix) Transform3(vx, vy, vz float64) (x, y, z float64)

Transform a vector. Uses 9 multiplications and 9 additions.

func (Matrix) Translate

func (m Matrix) Translate(tx, ty, tz float64) Matrix

func (Matrix) Transpose

func (m Matrix) Transpose() (t Matrix)

Jump to

Keyboard shortcuts

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