xmath

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const JSMAXSAFE = 1342177

Variables

This section is empty.

Functions

func Abs added in v0.2.5

func Abs[T Signed](a T) T

func Ceil added in v0.3.1

func Ceil[T Float](v T) T

func Clamp

func Clamp[T Number](v T, min T, max T) T

func Floor added in v0.2.1

func Floor[T Float](v T) T

func Fract

func Fract[T Float](v T) T

func GetOne

func GetOne[T any](arr []T, seed ...uint64) T

func Lerp

func Lerp[T Number, T1 Float](t T1, a, b T) T

func Max added in v0.2.1

func Max[T Number](x, y T) T

func MaxArr added in v0.2.30

func MaxArr[T Number](v []T) T

func Min added in v0.2.1

func Min[T Number](x, y T) T

func MinArr added in v0.2.30

func MinArr[T Number](v []T) T

func OneIn

func OneIn[T Number](chance T, seed ...uint64) bool

func PickOne

func PickOne[T any](arr []T, seed ...uint64) (T, []T)

func PickOneWeightSelect added in v0.3.4

func PickOneWeightSelect[T WeightAble](weightList []T, seed ...uint64) (int, T, []T)

func PickSome

func PickSome[T any](arr []T, num int, seed ...uint64) ([]T, []T)

func PickSomeWeightSelect added in v0.3.4

func PickSomeWeightSelect[T WeightAble](weightList []T, num int, seed ...uint64) (results []T, remain []T)

func Porn

func Porn(seed ...uint64) float64

func PornInt

func PornInt(seed ...uint64) int

func Pow added in v0.2.1

func Pow[T Number](x, y T) T

func Range

func Range[T Number](start, end T) []T

func Rng

func Rng[T Number](val1, val2 T, seed ...uint64) T

func SRandom

func SRandom(seed ...uint64) float64

func Shuffle

func Shuffle[T any](arr []T, seed ...uint64) []T

func Sign

func Sign[T Signed](v T) T

func Step

func Step[T Number](edge T, x T) T

func Ternary added in v0.2.2

func Ternary[T any](cond bool, a T, b T) T

func WeightList

func WeightList(list []int) int

func WeightSelect

func WeightSelect[T WeightAble](weightList []T, seed ...uint64) (int, T)

func XInY

func XInY[T Number](x T, y T, seed ...uint64) bool

Types

type Float added in v0.2.1

type Float interface {
	float32 | float64
}

type Number added in v0.2.1

type Number interface {
	Signed | UnSigned
}

type Signed added in v0.2.1

type Signed interface {
	SignedInt | Float
}

type SignedInt added in v0.2.5

type SignedInt interface {
	int8 | int16 | int32 | int64 | int
}

type UnSigned added in v0.2.5

type UnSigned interface {
	uint8 | uint16 | uint32 | uint64 | uint
}

type WeightAble

type WeightAble interface {
	Weight() float64
}

Jump to

Keyboard shortcuts

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