util

package
v0.0.0-...-cbdf402 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZERO = *NewPoint(0, 0)
)

Functions

func Abs

func Abs[T signedInts](a T) T

func Add

func Add[T any](slice []T, index int, elem T) []T

func AddToSlice

func AddToSlice[T any](slice []*T, pos int, item *T) []*T

func CeilDiv

func CeilDiv(numerator uint32, denominator uint32) uint32

func CeilLog1p

func CeilLog1p[T constraints.Integer](x T) int

func CeilLog2

func CeilLog2[T constraints.Integer](x T) int

func Clamp

func Clamp(v int32, a int32, b int32, c int32) int32

func Clamp3

func Clamp3(v int32, a int32, b int32) int32

func Clamp3Float32

func Clamp3Float32(v float32, a float32, b float32) float32

func CompareMatrix2D

func CompareMatrix2D[T any](a [][]T, b [][]T, compare func(T, T) bool) bool

func CompareMatrix3D

func CompareMatrix3D[T any](a [][][]T, b [][][]T, compare func(T, T) bool) bool

func DeepCopy3

func DeepCopy3[T comparable](a [][][]T) [][][]T

func FillFloat32

func FillFloat32(a []float32, fromIndex uint32, toIndex uint32, val float32)

func FloorLog1p

func FloorLog1p[T constraints.Integer](x T) int64

func ForwardDCT2D

func ForwardDCT2D(src [][]float32, dest [][]float32, startIn Point, startOut Point, length Dimension,
	scratchSpace0 [][]float32, scratchSpace1 [][]float32, b bool) error

func IfThenElse

func IfThenElse[T any](condition bool, a T, b T) T

func InverseDCT2D

func InverseDCT2D(src [][]float32, dest [][]float32, startIn Point, startOut Point, size Dimension, scratchSpace0 [][]float32, scratchSpace1 [][]float32, transposed bool) error

func InvertMatrix3x3

func InvertMatrix3x3(matrix [][]float32) [][]float32

func MakeMatrix2D

func MakeMatrix2D[T any, S constraints.Integer](a S, b S) [][]T

func MakeMatrix3D

func MakeMatrix3D[T any](a int, b int, c int) [][][]T

func MakeMatrix4D

func MakeMatrix4D[T any](a int, b int, c int, d int) [][][][]T

func Matrix3Equal

func Matrix3Equal[T comparable](a [][][]T, b [][][]T) bool

func MatrixIdentity

func MatrixIdentity(i int) [][]float32

func MatrixMatrixMultiply

func MatrixMatrixMultiply(left [][]float32, right [][]float32) ([][]float32, error)

func MatrixMultiply

func MatrixMultiply(matrix ...[][]float32) ([][]float32, error)

multiply any number of matrices

func MatrixVectorMultiply

func MatrixVectorMultiply(matrix [][]float32, columnVector []float32) ([]float32, error)

func Max

func Max[T cmp.Ordered](args ...T) T

func Min

func Min[T cmp.Ordered](args ...T) T

func MirrorCoordinate

func MirrorCoordinate(coordinate int32, size int32) int32

func RangeIterator

func RangeIterator(startX uint32, startY uint32, endX uint32, endY uint32) func() (*Point, error)

COULD try out the new Go 1.23 iter package, but to keep backwards compatibility will just use something basic and simple.

func RangeIteratorWithIntPoint

func RangeIteratorWithIntPoint(ip Point) func() (*Point, error)

func SignedPow

func SignedPow(base float32, exponent float32) float32

func TransposeMatrix

func TransposeMatrix(matrix [][]float32, inSize Point) [][]float32

func TransposeMatrixInto

func TransposeMatrixInto(src [][]float32, dest [][]float32, srcStart Point, destStart Point, srcSize Point)

Types

type Deque

type Deque[T any] struct {
	// contains filtered or unexported fields
}

Deque double ended queue to mimic Java version (or at least the functionality I need).

func NewDeque

func NewDeque[T any]() *Deque[T]

func (*Deque[T]) AddFirst

func (dq *Deque[T]) AddFirst(item T)

func (*Deque[T]) AddLast

func (dq *Deque[T]) AddLast(item T)

func (*Deque[T]) IsEmpty

func (dq *Deque[T]) IsEmpty() bool

func (*Deque[T]) RemoveFirst

func (dq *Deque[T]) RemoveFirst() *T

func (*Deque[T]) RemoveLast

func (dq *Deque[T]) RemoveLast() *T

type Dimension

type Dimension struct {
	Width  uint32
	Height uint32
}

type Point

type Point struct {
	X int32
	Y int32
}

func NewPoint

func NewPoint(y int32, x int32) *Point

type Rectangle

type Rectangle struct {
	Origin Point
	Size   Dimension
}

func (Rectangle) ComputeLowerCorner

func (r Rectangle) ComputeLowerCorner() Point

Jump to

Keyboard shortcuts

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