util

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args2Map added in v0.0.8

func Args2Map() map[string]string

Args2Map os.Args除[0]外,以=分切成kv对,无=的v为"true"

func CalRadiansPos

func CalRadiansPos[T Numeric](cx, cy, r, angleDegrees T) (x, y T)

func Contains

func Contains(all []string, zhi ...string) bool

func DistanceSqrV2

func DistanceSqrV2[T Numeric](a Vec2[T], b Vec2[T]) T

求两点间距离平方

func DistanceV2

func DistanceV2[T Numeric](a Vec2[T], b Vec2[T]) T

求两点间距离

func If

func If[T any](b bool, t, f T) T

Types

type Numeric

type Numeric interface {
	constraints.Integer | constraints.Float
}

type Vec2

type Vec2[T Numeric] struct {
	X T `json:"x"`
	Y T `json:"y"`
}

func AddArrayV2

func AddArrayV2[T Numeric](vs []Vec2[T], dv Vec2[T]) []Vec2[T]

func AddV2

func AddV2[T Numeric](a, b Vec2[T]) Vec2[T]

返回:a + b 向量

func LerpUnclampedV2

func LerpUnclampedV2[T Numeric](a, b Vec2[T], t T) Vec2[T]

func LerpV2

func LerpV2[T Numeric](a, b Vec2[T], t T) Vec2[T]

线性插值

func MultiplyV2

func MultiplyV2[T Numeric](v Vec2[T], scalars []T) []Vec2[T]

func NegativeInfinityV2

func NegativeInfinityV2[T Numeric]() Vec2[T]

func NewVec2

func NewVec2[T Numeric](x, y T) Vec2[T]

返回:新向量

func PositiveInfinityV2

func PositiveInfinityV2[T Numeric]() Vec2[T]

func SubV2

func SubV2[T Numeric](a, b Vec2[T]) Vec2[T]

返回:a - b 向量

func XAxisV2

func XAxisV2[T Numeric]() Vec2[T]

X 轴 单位向量

func XYAxisV2

func XYAxisV2[T Numeric]() Vec2[T]

func YAxisV2

func YAxisV2[T Numeric]() Vec2[T]

Y 轴 单位向量

func ZeroV2

func ZeroV2[T Numeric]() Vec2[T]

返回:零向量(0,0,0)

func (*Vec2[T]) Add

func (this *Vec2[T]) Add(v Vec2[T])

func (*Vec2[T]) Clone

func (this *Vec2[T]) Clone() Vec2[T]

func (*Vec2[T]) Divide

func (this *Vec2[T]) Divide(scalar T)

func (*Vec2[T]) Dot

func (this *Vec2[T]) Dot(v Vec2[T]) T

向量:点积

func (*Vec2[T]) Equal

func (this *Vec2[T]) Equal(v Vec2[T]) bool

func (*Vec2[T]) Length

func (this *Vec2[T]) Length() float32

func (*Vec2[T]) Magnitude

func (this *Vec2[T]) Magnitude() T

向量:长度

func (*Vec2[T]) Multiply

func (this *Vec2[T]) Multiply(scalar T)

func (*Vec2[T]) Normalize

func (this *Vec2[T]) Normalize()

向量:单位化 (0向量禁用)

func (*Vec2[T]) Normalized

func (this *Vec2[T]) Normalized() Vec2[T]

向量:单位化值 (0向量禁用)

func (*Vec2[T]) Scale

func (this *Vec2[T]) Scale(v Vec2[T])

向量:分向量乘

func (*Vec2[T]) ScaleToLength

func (this *Vec2[T]) ScaleToLength(newLength T)

朝向不变拉长度

func (*Vec2[T]) ScaledToLength

func (this *Vec2[T]) ScaledToLength(newLength T) Vec2[T]

复制朝向定长

func (*Vec2[T]) Set

func (this *Vec2[T]) Set(x, y T)

func (*Vec2[T]) SqrMagnitude

func (this *Vec2[T]) SqrMagnitude() T

向量:长度平方

func (*Vec2[T]) Sub

func (this *Vec2[T]) Sub(v Vec2[T])

Jump to

Keyboard shortcuts

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