vpmat3x3

package
v0.0.0-...-bf055c7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vpmat3x3 contains 3x3 matrix utilities.

Index

Constants

View Source
const (
	// Col0Row0 is the index of column 0 row 0 in a 3x3 column-major matrix.
	Col0Row0 = iota
	// Col0Row1 is the index of column 0 row 1 in a 3x3 column-major matrix.
	Col0Row1
	// Col0Row2 is the index of column 0 row 2 in a 3x3 column-major matrix.
	Col0Row2
	// Col1Row0 is the index of column 1 row 0 in a 3x3 column-major matrix.
	Col1Row0
	// Col1Row1 is the index of column 1 row 1 in a 3x3 column-major matrix.
	Col1Row1
	// Col1Row2 is the index of column 1 row 2 in a 3x3 column-major matrix.
	Col1Row2
	// Col2Row0 is the index of column 2 row 0 in a 3x3 column-major matrix.
	Col2Row0
	// Col2Row1 is the index of column 2 row 1 in a 3x3 column-major matrix.
	Col2Row1
	// Col2Row2 is the index of column 2 row 2 in a 3x3 column-major matrix.
	Col2Row2
	// Size is the number of elements in a 3x3 matrix.
	Size
	// Width is the width a 3x3 matrix (max column index is Width-1).
	Width = 3
	// Height is the width a 3x3 matrix (max row index is Height-1).
	Height = 3
)
View Source
const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

View Source
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

View Source
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

View Source
const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

View Source
const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

View Source
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

View Source
const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

View Source
const VersionMinor = 3 // VersionMinor set by version.sh

VersionMinor is the project minor version.

View Source
const VersionStamp = "c6a4298" // VersionStamp set by version.sh

VersionStamp is the project stamp, possibly changes for each build.

Variables

This section is empty.

Functions

This section is empty.

Types

type F32

type F32 [Size]float32

F32 is a matrix containing 3x3 float32 values. Can hold the values of a point in space.

func F32Add

func F32Add(mata, matb *F32) *F32

F32Add adds two matrices. Args are left untouched, a pointer on a new object is returned.

func F32DivScale

func F32DivScale(mat *F32, factor float32) *F32

F32DivScale divides all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func F32Identity

func F32Identity() *F32

F32Identity creates a new identity matrix.

func F32Inv

func F32Inv(mat *F32) *F32

F32Inv inverts a matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. Args is left untouched, a pointer on a new object is returned.

func F32MulComp

func F32MulComp(a, b *F32) *F32

F32MulComp multiplies two matrices (composition). Args are left untouched, a pointer on a new object is returned.

func F32MulScale

func F32MulScale(mat *F32, factor float32) *F32

F32MulScale multiplies all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func F32New

func F32New(f1, f2, f3, f4, f5, f6, f7, f8, f9 float32) *F32

F32New creates a new matrix containing 3x3 float32 values. The column-major (OpenGL notation) mode is used, first elements fill first column.

func F32RebaseOXY

func F32RebaseOXY(Origin, PosX, PosY *vpvec2.F32) *F32

F32RebaseOXY creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1) basis to the given basis. It assumes f(a+b) equals f(a)+f(b).

func F32RebaseOXYP

func F32RebaseOXYP(Origin, PosX, PosY, PosP *vpvec2.F32) *F32

F32RebaseOXYP creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1), P=(1,1) basis to the given basis. Note that there can be a projection, so f(a+b) is not f(a)+f(b).

func F32Rot

func F32Rot(r float32) *F32

F32Rot creates a new rotation matrix. The rotation is done in 2D over a virtual z axis, such as z = cross(x,y). Angle is given in radians.

func F32Scale

func F32Scale(vec *vpvec2.F32) *F32

F32Scale creates a new scale matrix.

func F32Sub

func F32Sub(mata, matb *F32) *F32

F32Sub substracts matrix b from matrix a. Args are left untouched, a pointer on a new object is returned.

func F32Translation

func F32Translation(vec *vpvec2.F32) *F32

F32Translation creates a new translation matrix.

func F32Transpose

func F32Transpose(mat *F32) *F32

F32Transpose inverts rows and columns (matrix transposition). Args is left untouched, a pointer on a new object is returned.

func (*F32) Add

func (mat *F32) Add(op *F32) *F32

Add adds operand to the matrix. It modifies the matrix, and returns a pointer on it.

func (*F32) Det

func (mat *F32) Det() float32

Det returns the matrix determinant.

func (*F32) DivScale

func (mat *F32) DivScale(factor float32) *F32

DivScale divides all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*F32) Get

func (mat *F32) Get(col, row int) float32

Get gets the value of the matrix for a given column and row.

func (*F32) GetCol

func (mat *F32) GetCol(col int) *vpvec3.F32

GetCol gets a column and returns it in a vector.

func (*F32) GetRow

func (mat *F32) GetRow(row int) *vpvec3.F32

GetRow gets a row and returns it in a vector.

func (*F32) Inv

func (mat *F32) Inv() *F32

Inv inverts the matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. It modifies the matrix, and returns a pointer on it.

func (*F32) IsSimilar

func (mat *F32) IsSimilar(op *F32) bool

IsSimilar returns true if matrices are approximatively the same. This is a workarround to ignore rounding errors.

func (*F32) MarshalJSON

func (mat *F32) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*F32) MulComp

func (mat *F32) MulComp(op *F32) *F32

MulComp multiplies the matrix by another matrix (composition). It modifies the matrix, and returns a pointer on it.

func (*F32) MulScale

func (mat *F32) MulScale(factor float32) *F32

MulScale multiplies all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*F32) MulVec

func (mat *F32) MulVec(vec *vpvec3.F32) *vpvec3.F32

MulVec performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right).

func (*F32) MulVecDir

func (mat *F32) MulVecDir(vec *vpvec2.F32) *vpvec2.F32

MulVecDir performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 0, so in practice a direction vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations to be accumulated within the matrix and then performed at once.

func (*F32) MulVecPos

func (mat *F32) MulVecPos(vec *vpvec2.F32) *vpvec2.F32

MulVecPos performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 1, so in practice a position vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations and translations to be accumulated within the matrix and then performed at once.

func (*F32) Set

func (mat *F32) Set(col, row int, val float32)

Set sets the value of the matrix for a given column and row.

func (*F32) SetCol

func (mat *F32) SetCol(col int, vec *vpvec3.F32)

SetCol sets a column to the values contained in a vector.

func (*F32) SetRow

func (mat *F32) SetRow(row int, vec *vpvec3.F32)

SetRow sets a row to the values contained in a vector.

func (*F32) String

func (mat *F32) String() string

String returns a readable form of the matrix.

func (*F32) Sub

func (mat *F32) Sub(op *F32) *F32

Sub substracts operand from the matrix. It modifies the matrix, and returns a pointer on it.

func (*F32) ToF64

func (mat *F32) ToF64() *F64

ToF64 converts the matrix to a float64 matrix.

func (*F32) ToX32

func (mat *F32) ToX32() *X32

ToX32 converts the matrix to a fixed point number matrix on 32 bits.

func (*F32) ToX64

func (mat *F32) ToX64() *X64

ToX64 converts the matrix to a fixed point number matrix on 64 bits.

func (*F32) Transpose

func (mat *F32) Transpose(op *F32) *F32

Transpose inverts rows and columns (matrix transposition). It modifies the matrix, and returns a pointer on it.

func (*F32) UnmarshalJSON

func (mat *F32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type F64

type F64 [Size]float64

F64 is a matrix containing 3x3 float64 values. Can hold the values of a point in space.

func F64Add

func F64Add(mata, matb *F64) *F64

F64Add adds two matrices. Args are left untouched, a pointer on a new object is returned.

func F64DivScale

func F64DivScale(mat *F64, factor float64) *F64

F64DivScale divides all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func F64Identity

func F64Identity() *F64

F64Identity creates a new identity matrix.

func F64Inv

func F64Inv(mat *F64) *F64

F64Inv inverts a matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. Args is left untouched, a pointer on a new object is returned.

func F64MulComp

func F64MulComp(a, b *F64) *F64

F64MulComp multiplies two matrices (composition). Args are left untouched, a pointer on a new object is returned.

func F64MulScale

func F64MulScale(mat *F64, factor float64) *F64

F64MulScale multiplies all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func F64New

func F64New(f1, f2, f3, f4, f5, f6, f7, f8, f9 float64) *F64

F64New creates a new matrix containing 3x3 float64 values. The column-major (OpenGL notation) mode is used, first elements fill first column.

func F64RebaseOXY

func F64RebaseOXY(Origin, PosX, PosY *vpvec2.F64) *F64

F64RebaseOXY creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1) basis to the given basis. It assumes f(a+b) equals f(a)+f(b).

func F64RebaseOXYP

func F64RebaseOXYP(Origin, PosX, PosY, PosP *vpvec2.F64) *F64

F64RebaseOXYP creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1), P=(1,1) basis to the given basis. Note that there can be a projection, so f(a+b) is not f(a)+f(b).

func F64Rot

func F64Rot(r float64) *F64

F64Rot creates a new rotation matrix. The rotation is done in 2D over a virtual z axis, such as z = cross(x,y). Angle is given in radians.

func F64Scale

func F64Scale(vec *vpvec2.F64) *F64

F64Scale creates a new scale matrix.

func F64Sub

func F64Sub(mata, matb *F64) *F64

F64Sub substracts matrix b from matrix a. Args are left untouched, a pointer on a new object is returned.

func F64Translation

func F64Translation(vec *vpvec2.F64) *F64

F64Translation creates a new translation matrix.

func F64Transpose

func F64Transpose(mat *F64) *F64

F64Transpose inverts rows and columns (matrix transposition). Args is left untouched, a pointer on a new object is returned.

func (*F64) Add

func (mat *F64) Add(op *F64) *F64

Add adds operand to the matrix. It modifies the matrix, and returns a pointer on it.

func (*F64) Det

func (mat *F64) Det() float64

Det returns the matrix determinant.

func (*F64) DivScale

func (mat *F64) DivScale(factor float64) *F64

DivScale divides all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*F64) Get

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

Get gets the value of the matrix for a given column and row.

func (*F64) GetCol

func (mat *F64) GetCol(col int) *vpvec3.F64

GetCol gets a column and returns it in a vector.

func (*F64) GetRow

func (mat *F64) GetRow(row int) *vpvec3.F64

GetRow gets a row and returns it in a vector.

func (*F64) Inv

func (mat *F64) Inv() *F64

Inv inverts the matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. It modifies the matrix, and returns a pointer on it.

func (*F64) IsSimilar

func (mat *F64) IsSimilar(op *F64) bool

IsSimilar returns true if matrices are approximatively the same. This is a workarround to ignore rounding errors.

func (*F64) MarshalJSON

func (mat *F64) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*F64) MulComp

func (mat *F64) MulComp(op *F64) *F64

MulComp multiplies the matrix by another matrix (composition). It modifies the matrix, and returns a pointer on it.

func (*F64) MulScale

func (mat *F64) MulScale(factor float64) *F64

MulScale multiplies all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*F64) MulVec

func (mat *F64) MulVec(vec *vpvec3.F64) *vpvec3.F64

MulVec performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right).

func (*F64) MulVecDir

func (mat *F64) MulVecDir(vec *vpvec2.F64) *vpvec2.F64

MulVecDir performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 0, so in practice a direction vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations to be accumulated within the matrix and then performed at once.

func (*F64) MulVecPos

func (mat *F64) MulVecPos(vec *vpvec2.F64) *vpvec2.F64

MulVecPos performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 1, so in practice a position vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations and translations to be accumulated within the matrix and then performed at once.

func (*F64) Set

func (mat *F64) Set(col, row int, val float64)

Set sets the value of the matrix for a given column and row.

func (*F64) SetCol

func (mat *F64) SetCol(col int, vec *vpvec3.F64)

SetCol sets a column to the values contained in a vector.

func (*F64) SetRow

func (mat *F64) SetRow(row int, vec *vpvec3.F64)

SetRow sets a row to the values contained in a vector.

func (*F64) String

func (mat *F64) String() string

String returns a readable form of the matrix.

func (*F64) Sub

func (mat *F64) Sub(op *F64) *F64

Sub substracts operand from the matrix. It modifies the matrix, and returns a pointer on it.

func (*F64) ToF32

func (mat *F64) ToF32() *F32

ToF32 converts the matrix to a float32 matrix.

func (*F64) ToX32

func (mat *F64) ToX32() *X32

ToX32 converts the matrix to a fixed point number matrix on 32 bits.

func (*F64) ToX64

func (mat *F64) ToX64() *X64

ToX64 converts the matrix to a fixed point number matrix on 64 bits.

func (*F64) Transpose

func (mat *F64) Transpose(op *F64) *F64

Transpose inverts rows and columns (matrix transposition). It modifies the matrix, and returns a pointer on it.

func (*F64) UnmarshalJSON

func (mat *F64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type X32

type X32 [Size]vpnumber.X32

X32 is a matrix containing 3x3 fixed point 32 bit values. Can hold the values of a point in space.

func X32Add

func X32Add(mata, matb *X32) *X32

X32Add adds two matrices. Args are left untouched, a pointer on a new object is returned.

func X32DivScale

func X32DivScale(mat *X32, factor vpnumber.X32) *X32

X32DivScale divides all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func X32Identity

func X32Identity() *X32

X32Identity creates a new identity matrix.

func X32Inv

func X32Inv(mat *X32) *X32

X32Inv inverts a matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. Args is left untouched, a pointer on a new object is returned.

func X32MulComp

func X32MulComp(a, b *X32) *X32

X32MulComp multiplies two matrices (composition). Args are left untouched, a pointer on a new object is returned.

func X32MulScale

func X32MulScale(mat *X32, factor vpnumber.X32) *X32

X32MulScale multiplies all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func X32New

func X32New(x1, x2, x3, x4, x5, x6, x7, x8, x9 vpnumber.X32) *X32

X32New creates a new matrix containing 3x3 fixed point 32 bit values. The column-major (OpenGL notation) mode is used, first elements fill first column.

func X32RebaseOXY

func X32RebaseOXY(Origin, PosX, PosY *vpvec2.X32) *X32

X32RebaseOXY creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1) basis to the given basis. It assumes f(a+b) equals f(a)+f(b).

func X32RebaseOXYP

func X32RebaseOXYP(Origin, PosX, PosY, PosP *vpvec2.X32) *X32

X32RebaseOXYP creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1), P=(1,1) basis to the given basis. Note that there can be a projection, so f(a+b) is not f(a)+f(b).

func X32Rot

func X32Rot(r vpnumber.X32) *X32

X32Rot creates a new rotation matrix. The rotation is done in 2D over a virtual z axis, such as z = cross(x,y). Angle is given in radians.

func X32Scale

func X32Scale(vec *vpvec2.X32) *X32

X32Scale creates a new scale matrix.

func X32Sub

func X32Sub(mata, matb *X32) *X32

X32Sub substracts matrix b from matrix a. Args are left untouched, a pointer on a new object is returned.

func X32Translation

func X32Translation(vec *vpvec2.X32) *X32

X32Translation creates a new translation matrix.

func X32Transpose

func X32Transpose(mat *X32) *X32

X32Transpose inverts rows and columns (matrix transposition). Args is left untouched, a pointer on a new object is returned.

func (*X32) Add

func (mat *X32) Add(op *X32) *X32

Add adds operand to the matrix. It modifies the matrix, and returns a pointer on it.

func (*X32) Det

func (mat *X32) Det() vpnumber.X32

Det returns the matrix determinant.

func (*X32) DivScale

func (mat *X32) DivScale(factor vpnumber.X32) *X32

DivScale divides all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*X32) Get

func (mat *X32) Get(col, row int) vpnumber.X32

Get gets the value of the matrix for a given column and row.

func (*X32) GetCol

func (mat *X32) GetCol(col int) *vpvec3.X32

GetCol gets a column and returns it in a vector.

func (*X32) GetRow

func (mat *X32) GetRow(row int) *vpvec3.X32

GetRow gets a row and returns it in a vector.

func (*X32) Inv

func (mat *X32) Inv() *X32

Inv inverts the matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. It modifies the matrix, and returns a pointer on it.

func (*X32) IsSimilar

func (mat *X32) IsSimilar(op *X32) bool

IsSimilar returns true if matrices are approximatively the same. This is a workarround to ignore rounding errors.

func (*X32) MarshalJSON

func (mat *X32) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*X32) MulComp

func (mat *X32) MulComp(op *X32) *X32

MulComp multiplies the matrix by another matrix (composition). It modifies the matrix, and returns a pointer on it.

func (*X32) MulScale

func (mat *X32) MulScale(factor vpnumber.X32) *X32

MulScale multiplies all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*X32) MulVec

func (mat *X32) MulVec(vec *vpvec3.X32) *vpvec3.X32

MulVec performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right).

func (*X32) MulVecDir

func (mat *X32) MulVecDir(vec *vpvec2.X32) *vpvec2.X32

MulVecDir performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 0, so in practice a direction vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations to be accumulated within the matrix and then performed at once.

func (*X32) MulVecPos

func (mat *X32) MulVecPos(vec *vpvec2.X32) *vpvec2.X32

MulVecPos performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 1, so in practice a position vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations and translations to be accumulated within the matrix and then performed at once.

func (*X32) Set

func (mat *X32) Set(col, row int, val vpnumber.X32)

Set sets the value of the matrix for a given column and row.

func (*X32) SetCol

func (mat *X32) SetCol(col int, vec *vpvec3.X32)

SetCol sets a column to the values contained in a vector.

func (*X32) SetRow

func (mat *X32) SetRow(row int, vec *vpvec3.X32)

SetRow sets a row to the values contained in a vector.

func (*X32) String

func (mat *X32) String() string

String returns a readable form of the matrix.

func (*X32) Sub

func (mat *X32) Sub(op *X32) *X32

Sub substracts operand from the matrix. It modifies the matrix, and returns a pointer on it.

func (*X32) ToF32

func (mat *X32) ToF32() *F32

ToF32 converts the matrix to a float32 matrix.

func (*X32) ToF64

func (mat *X32) ToF64() *F64

ToF64 converts the matrix to a float64 matrix.

func (*X32) ToX64

func (mat *X32) ToX64() *X64

ToX64 converts the matrix to a fixed point number matrix on 64 bits.

func (*X32) Transpose

func (mat *X32) Transpose(op *X32) *X32

Transpose inverts rows and columns (matrix transposition). It modifies the matrix, and returns a pointer on it.

func (*X32) UnmarshalJSON

func (mat *X32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type X64

type X64 [Size]vpnumber.X64

X64 is a matrix containing 3x3 fixed point 64 bit values. Can hold the values of a point in space.

func X64Add

func X64Add(mata, matb *X64) *X64

X64Add adds two matrices. Args are left untouched, a pointer on a new object is returned.

func X64DivScale

func X64DivScale(mat *X64, factor vpnumber.X64) *X64

X64DivScale divides all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func X64Identity

func X64Identity() *X64

X64Identity creates a new identity matrix.

func X64Inv

func X64Inv(mat *X64) *X64

X64Inv inverts a matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. Args is left untouched, a pointer on a new object is returned.

func X64MulComp

func X64MulComp(a, b *X64) *X64

X64MulComp multiplies two matrices (composition). Args are left untouched, a pointer on a new object is returned.

func X64MulScale

func X64MulScale(mat *X64, factor vpnumber.X64) *X64

X64MulScale multiplies all values of a matrix by a scalar. Args are left untouched, a pointer on a new object is returned.

func X64New

func X64New(x1, x2, x3, x4, x5, x6, x7, x8, x9 vpnumber.X64) *X64

X64New creates a new matrix containing 3x3 fixed point 64 bit values. The column-major (OpenGL notation) mode is used, first elements fill first column.

func X64RebaseOXY

func X64RebaseOXY(Origin, PosX, PosY *vpvec2.X64) *X64

X64RebaseOXY creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1) basis to the given basis. It assumes f(a+b) equals f(a)+f(b).

func X64RebaseOXYP

func X64RebaseOXYP(Origin, PosX, PosY, PosP *vpvec2.X64) *X64

X64RebaseOXYP creates a matrix that translates from the default O=(0,0), X=(1,0), Y=(0,1), P=(1,1) basis to the given basis. Note that there can be a projection, so f(a+b) is not f(a)+f(b).

func X64Rot

func X64Rot(r vpnumber.X64) *X64

X64Rot creates a new rotation matrix. The rotation is done in 2D over a virtual z axis, such as z = cross(x,y). Angle is given in radians.

func X64Scale

func X64Scale(vec *vpvec2.X64) *X64

X64Scale creates a new scale matrix.

func X64Sub

func X64Sub(mata, matb *X64) *X64

X64Sub substracts matrix b from matrix a. Args are left untouched, a pointer on a new object is returned.

func X64Translation

func X64Translation(vec *vpvec2.X64) *X64

X64Translation creates a new translation matrix.

func X64Transpose

func X64Transpose(mat *X64) *X64

X64Transpose inverts rows and columns (matrix transposition). Args is left untouched, a pointer on a new object is returned.

func (*X64) Add

func (mat *X64) Add(op *X64) *X64

Add adds operand to the matrix. It modifies the matrix, and returns a pointer on it.

func (*X64) Det

func (mat *X64) Det() vpnumber.X64

Det returns the matrix determinant.

func (*X64) DivScale

func (mat *X64) DivScale(factor vpnumber.X64) *X64

DivScale divides all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*X64) Get

func (mat *X64) Get(col, row int) vpnumber.X64

Get gets the value of the matrix for a given column and row.

func (*X64) GetCol

func (mat *X64) GetCol(col int) *vpvec3.X64

GetCol gets a column and returns it in a vector.

func (*X64) GetRow

func (mat *X64) GetRow(row int) *vpvec3.X64

GetRow gets a row and returns it in a vector.

func (*X64) Inv

func (mat *X64) Inv() *X64

Inv inverts the matrix. Never fails (no division by zero error, never) but if the matrix can't be inverted, result does not make sense. It modifies the matrix, and returns a pointer on it.

func (*X64) IsSimilar

func (mat *X64) IsSimilar(op *X64) bool

IsSimilar returns true if matrices are approximatively the same. This is a workarround to ignore rounding errors.

func (*X64) MarshalJSON

func (mat *X64) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*X64) MulComp

func (mat *X64) MulComp(op *X64) *X64

MulComp multiplies the matrix by another matrix (composition). It modifies the matrix, and returns a pointer on it.

func (*X64) MulScale

func (mat *X64) MulScale(factor vpnumber.X64) *X64

MulScale multiplies all values of the matrix by factor. It modifies the matrix, and returns a pointer on it.

func (*X64) MulVec

func (mat *X64) MulVec(vec *vpvec3.X64) *vpvec3.X64

MulVec performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right).

func (*X64) MulVecDir

func (mat *X64) MulVecDir(vec *vpvec2.X64) *vpvec2.X64

MulVecDir performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 0, so in practice a direction vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations to be accumulated within the matrix and then performed at once.

func (*X64) MulVecPos

func (mat *X64) MulVecPos(vec *vpvec2.X64) *vpvec2.X64

MulVecPos performs a multiplication of a vector by a 3x3 matrix, considering the vector is a column vector (matrix left, vector right). The last member of the vector is assumed to be 1, so in practice a position vector of length 2 (a point in a plane) is passed. This allow geometric transformations such as rotations and translations to be accumulated within the matrix and then performed at once.

func (*X64) Set

func (mat *X64) Set(col, row int, val vpnumber.X64)

Set sets the value of the matrix for a given column and row.

func (*X64) SetCol

func (mat *X64) SetCol(col int, vec *vpvec3.X64)

SetCol sets a column to the values contained in a vector.

func (*X64) SetRow

func (mat *X64) SetRow(row int, vec *vpvec3.X64)

SetRow sets a row to the values contained in a vector.

func (*X64) String

func (mat *X64) String() string

String returns a readable form of the matrix.

func (*X64) Sub

func (mat *X64) Sub(op *X64) *X64

Sub substracts operand from the matrix. It modifies the matrix, and returns a pointer on it.

func (*X64) ToF32

func (mat *X64) ToF32() *F32

ToF32 converts the matrix to a float32 matrix.

func (*X64) ToF64

func (mat *X64) ToF64() *F64

ToF64 converts the matrix to a float64 matrix.

func (*X64) ToX32

func (mat *X64) ToX32() *X32

ToX32 converts the matrix to a fixed point number matrix on 64 bits.

func (*X64) Transpose

func (mat *X64) Transpose(op *X64) *X64

Transpose inverts rows and columns (matrix transposition). It modifies the matrix, and returns a pointer on it.

func (*X64) UnmarshalJSON

func (mat *X64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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