mat4

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package mat4 contains a 4x4 float64 matrix type T and functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Zero holds a zero matrix.
	Zero = T{}

	// Ident holds an ident matrix.
	Ident = T{
		vec4.T{1, 0, 0, 0},
		vec4.T{0, 1, 0, 0},
		vec4.T{0, 0, 1, 0},
		vec4.T{0, 0, 0, 1},
	}
)

Functions

This section is empty.

Types

type T

type T [4]vec4.T

T represents a 4x4 matrix.

func From

func From(other generic.T) T

From copies a T from a generic.T implementation.

func Parse

func Parse(s string) (r T, err error)

Parse parses T from a string. See also String()

func (*T) Array

func (mat *T) Array() *[16]float64

Array returns the elements of the matrix as array pointer. The data may be a copy depending on the platform implementation.

func (*T) AssignCoordinateSystem

func (mat *T) AssignCoordinateSystem(x, y, z *vec3.T) *T

AssignCoordinateSystem assigns the rotation of a orthogonal coordinates system to the rotation part of the matrix and sets the remaining elements to their ident value.

func (*T) AssignEulerRotation

func (mat *T) AssignEulerRotation(yHead, xPitch, zRoll float64) *T

AssignEulerRotation assigns Euler angle rotations to the rotation part of the matrix and sets the remaining elements to their ident value.

func (*T) AssignMat2x2

func (mat *T) AssignMat2x2(m *mat2.T) *T

AssignMat2x2 assigns a 2x2 sub-matrix and sets the rest of the matrix to the ident value.

func (*T) AssignMat3x3

func (mat *T) AssignMat3x3(m *mat3.T) *T

AssignMat3x3 assigns a 3x3 sub-matrix and sets the rest of the matrix to the ident value.

func (*T) AssignMul

func (mat *T) AssignMul(a, b *T) *T

AssignMul multiplies a and b and assigns the result to T.

func (*T) AssignOrthogonalProjection

func (mat *T) AssignOrthogonalProjection(left, right, bottom, top, znear, zfar float64) *T

AssignOrthogonalProjection assigns an orthogonal projection transformation.

func (*T) AssignPerspectiveProjection

func (mat *T) AssignPerspectiveProjection(left, right, bottom, top, znear, zfar float64) *T

AssignPerspectiveProjection assigns a perspective projection transformation.

func (*T) AssignQuaternion

func (mat *T) AssignQuaternion(q *quaternion.T) *T

AssignQuaternion assigns a quaternion to the rotations part of the matrix and sets the other elements to their ident value.

func (*T) AssignXRotation

func (mat *T) AssignXRotation(angle float64) *T

AssignXRotation assigns a rotation around the x axis to the rotation part of the matrix and sets the remaining elements to their ident value.

func (*T) AssignYRotation

func (mat *T) AssignYRotation(angle float64) *T

AssignYRotation assigns a rotation around the y axis to the rotation part of the matrix and sets the remaining elements to their ident value.

func (*T) AssignZRotation

func (mat *T) AssignZRotation(angle float64) *T

AssignZRotation assigns a rotation around the z axis to the rotation part of the matrix and sets the remaining elements to their ident value.

func (*T) Cols

func (mat *T) Cols() int

Cols returns the number of columns of the matrix.

func (*T) Determinant3x3

func (mat *T) Determinant3x3() float64

Determinant3x3 returns the determinant of the 3x3 sub-matrix.

func (*T) ExtractEulerAngles

func (mat *T) ExtractEulerAngles() (yHead, xPitch, zRoll float64)

ExtractEulerAngles extracts the rotation part of the matrix as Euler angle rotation values.

func (*T) Get

func (mat *T) Get(col, row int) float64

Get returns one element of the matrix.

func (*T) IsReflective

func (mat *T) IsReflective() bool

IsReflective returns true if the matrix can be reflected by a plane.

func (*T) IsZero

func (mat *T) IsZero() bool

IsZero checks if all elements of the matrix are zero.

func (*T) MulVec3

func (mat *T) MulVec3(v *vec3.T) vec3.T

MulVec3 multiplies v (converted to a vec4 as (v_1, v_2, v_3, 1)) with mat and divides the result by w. Returns a new vec3.

func (*T) MulVec3W

func (mat *T) MulVec3W(v *vec3.T, w float64) vec3.T

MulVec3W multiplies v with mat with w as fourth component of the vector. Useful to differentiate between vectors (w = 0) and points (w = 1) without transforming them to vec4.

func (*T) MulVec4

func (mat *T) MulVec4(v *vec4.T) vec4.T

MulVec4 multiplies v with mat and returns a new vector v' = M * v.

func (*T) Quaternion

func (mat *T) Quaternion() quaternion.T

Quaternion extracts a quaternion from the rotation part of the matrix.

func (*T) Rows

func (mat *T) Rows() int

Rows returns the number of rows of the matrix.

func (*T) Scale

func (mat *T) Scale(f float64) *T

Scale multiplies the diagonal scale elements by f returns mat.

func (*T) ScaleVec3

func (mat *T) ScaleVec3(s *vec3.T) *T

ScaleVec3 multiplies the scaling diagonal of the matrix by s.

func (*T) Scaled

func (mat *T) Scaled(f float64) T

Scaled returns a copy of the matrix with the diagonal scale elements multiplied by f.

func (*T) Scaling

func (mat *T) Scaling() vec4.T

Scaling returns the scaling diagonal of the matrix.

func (*T) SetScaling

func (mat *T) SetScaling(s *vec4.T) *T

SetScaling sets the scaling diagonal of the matrix.

func (*T) SetTranslation

func (mat *T) SetTranslation(v *vec3.T) *T

SetTranslation sets the translation elements of the matrix.

func (*T) Size

func (mat *T) Size() int

Size returns the number elements of the matrix.

func (*T) Slice

func (mat *T) Slice() []float64

Slice returns the elements of the matrix as slice.

func (*T) String

func (mat *T) String() string

String formats T as string. See also Parse().

func (*T) Trace

func (mat *T) Trace() float64

Trace returns the trace value for the matrix.

func (*T) Trace3

func (mat *T) Trace3() float64

Trace3 returns the trace value for the 3x3 sub-matrix.

func (*T) TransformVec3

func (mat *T) TransformVec3(v *vec3.T)

TransformVec3 multiplies v (converted to a vec4 as (v_1, v_2, v_3, 1)) with mat, divides the result by w and saves the result in v.

func (*T) TransformVec3W

func (mat *T) TransformVec3W(v *vec3.T, w float64)

TransformVec3W multiplies v with mat with w as fourth component of the vector and saves the result in v. Useful to differentiate between vectors (w = 0) and points (w = 1) without transforming them to vec4.

func (*T) TransformVec4

func (mat *T) TransformVec4(v *vec4.T)

MulVec4 multiplies v with mat and saves the result in v.

func (*T) Translate

func (mat *T) Translate(v *vec3.T) *T

Translate adds v to the translation part of the matrix.

func (*T) TranslateX

func (mat *T) TranslateX(dx float64) *T

TranslateX adds dx to the X-translation element of the matrix.

func (*T) TranslateY

func (mat *T) TranslateY(dy float64) *T

TranslateY adds dy to the Y-translation element of the matrix.

func (*T) TranslateZ

func (mat *T) TranslateZ(dz float64) *T

TranslateZ adds dz to the Z-translation element of the matrix.

func (*T) Transpose

func (mat *T) Transpose() *T

Transpose transposes the matrix.

func (*T) Transpose3x3

func (mat *T) Transpose3x3() *T

Transpose3x3 transposes the 3x3 sub-matrix.

Jump to

Keyboard shortcuts

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