core

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EPSILON = float32(0.00001)

Functions

func Abs

func Abs[D Numeric](v D) D

func Choose

func Choose[D Integer](n D, m D) D

func Clamp

func Clamp[D Numeric](v D, min D, max D) D

func ClampLength

func ClampLength[A Attr[A]](value A, min float32, max float32) A

func Closest

func Closest[A Attr[A]](start A, end A, point A, line bool) A

func Cos

func Cos[D Numeric](rad D) D

func CubicCurve

func CubicCurve[A Attr[A]](delta float32, p0 A, p1 A, p2 A, p3 A, matrix [4][4]float32, inverse bool) A

func Delta

func Delta[A Attr[A]](start A, end A, point A) float32

func DistanceFrom

func DistanceFrom[A Attr[A]](start A, end A, point A, line bool) float32

func Div

func Div[D Numeric](a D, b D) D

func Factorial

func Factorial[D Numeric](x D) D

func Floor

func Floor[D Numeric](v D) D

func Gcd

func Gcd[D Integer](a D, b D) D

func GetTriangleHeight

func GetTriangleHeight(base float32, side1 float32, side2 float32) float32

func InterceptTime

func InterceptTime[A Attr[A]](shooter A, shooterSpeed float32, targetPosition A, targetVelocity A) float32

func IsCircleInView

func IsCircleInView[A Attr[A]](viewOrigin A, viewDirection A, fovTan float32, fovCos float32, circle A, circleRadius float32, entirely bool) bool

func IsCircleInViewType

func IsCircleInViewType[A Attr[A]](viewOrigin A, viewDirection A, fovTan float32, fovCos float32, circle A, circleRadius float32, fovType FieldOfView) bool

func IsNormal

func IsNormal[A Attr[A]](value A) bool

func IsPointInView

func IsPointInView[A Attr[A]](origin A, direction A, fovCos float32, point A) bool

func Lengthen

func Lengthen[A Attr[A]](value A, length float32) A

func Log10

func Log10[D Numeric](v D) D

func Max

func Max[D Numeric](a D, b D) D

func Min

func Min[D Numeric](a D, b D) D

func Normalize

func Normalize[A Attr[A]](value A, normal *A) float32

func ParametricCubicCurve

func ParametricCubicCurve[A Attr[A]](delta float32, points []A, matrix [4][4]float32, weight float32, inverse bool, loop bool) A

func QuadraticFormula

func QuadraticFormula(a, b, c, none float32) float32

func Reflect

func Reflect[A Attr[A]](dir A, normal A) A

func Refract

func Refract[A Attr[A]](dir A, normal A) A

func Sign

func Sign[D Numeric](v D) int

func Sin

func Sin[D Numeric](rad D) D

func Slerp

func Slerp[A Attr[A]](start A, end A, t float32) A

func SlerpAngle

func SlerpAngle[A Attr[A]](start A, end A, angle float32, t float32) A

func SlerpNormal

func SlerpNormal[A Attr[A]](start A, end A, t float32) A

func Sqrt

func Sqrt[D Numeric](v D) D

Types

type Attr

type Attr[V any] interface {
	// distance between this and value
	Distance(value V) float32
	// squared distance between this and value
	DistanceSq(value V) float32
	// distance between this and zero
	Length() float32
	// squared distance between this and zero
	LengthSq() float32
	// dot product between this and value
	Dot(value V) float32
	// the number of float components that make up this attribute
	Components() int
	// gets the float component at the given index
	GetComponent(index int) float32
	// out[index] = value
	SetComponent(index int, value float32, out *V)
	// out[all] = value
	SetComponents(value float32, out *V)
	// out = this
	Set(out *V)
	// out = this + value
	Add(addend V, out *V)
	// out = this + value * scale
	AddScaled(value V, scale float32, out *V)
	// out = this - value
	Sub(subtrahend V, out *V)
	// out = this * value
	Mul(factor V, out *V)
	// out = this / value
	Div(factor V, out *V)
	// out = this * scale
	Scale(scale float32, out *V)
	// out = (end - start) * delta + start
	Interpolate(start V, end V, delta float32, out *V)
}

type FieldOfView

type FieldOfView string
const (
	FieldOfViewIgnore FieldOfView = "ignore"
	FieldOfViewHalf   FieldOfView = "half"
	FieldOfViewFull   FieldOfView = "full"
)

type Integer

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type ListenerEntry

type ListenerEntry[L any] struct {
	// contains filtered or unexported fields
}

func (*ListenerEntry[L]) Off

func (entry *ListenerEntry[L]) Off()

type ListenerOff

type ListenerOff func()

type ListenerOffs

type ListenerOffs []ListenerOff

func (*ListenerOffs) Add

func (offs *ListenerOffs) Add(off ListenerOff)

func (*ListenerOffs) Off

func (offs *ListenerOffs) Off()

type Listeners

type Listeners[L any] struct {
	// contains filtered or unexported fields
}

func NewListeners

func NewListeners[L any]() *Listeners[L]

func (*Listeners[L]) On

func (l *Listeners[L]) On(listener L) ListenerOff

func (*Listeners[L]) OnCount

func (l *Listeners[L]) OnCount(listener L, count int) ListenerOff

func (*Listeners[L]) Once

func (l *Listeners[L]) Once(listener L) ListenerOff

func (*Listeners[L]) Trigger

func (l *Listeners[L]) Trigger(call func(listener L) bool) int

type Numeric

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64
}

Jump to

Keyboard shortcuts

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