vec

package
v0.0.0-...-bbb78ca Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistanceFV2

func DistanceFV2(a FixVector2, b FixVector2) Fix64

求两点间距离

func DistanceFV3

func DistanceFV3(a, b *FixVector3) Fix64

func DistanceSqrFV2

func DistanceSqrFV2(a FixVector2, b FixVector2) Fix64

求两点间距离平方

func DistanceSqrFV3

func DistanceSqrFV3(a, b FixVector3) Fix64

func DistanceSqrV2

func DistanceSqrV2(a Vector2, b Vector2) float32

求两点间距离平方

func DistanceSqrV3

func DistanceSqrV3(a, b Vector3) float32

求两点间距离平方

func DistanceV2

func DistanceV2(a Vector2, b Vector2) float32

求两点间距离

func DistanceV3

func DistanceV3(a, b Vector3) float32

求两点间距离

Types

type FixVector2

type FixVector2 struct {
	X Fix64 `json:"x"`
	Y Fix64 `json:"y"`
}

func AddArrayFV2

func AddArrayFV2(vs []FixVector2, dv FixVector2) []FixVector2

func AddFV2

func AddFV2(a, b FixVector2) FixVector2

返回:a + b 向量

func LerpFV2

func LerpFV2(a, b FixVector2, t Fix64) FixVector2

线性插值

func MultiplyFV2

func MultiplyFV2(v FixVector2, scalars []Fix64) []FixVector2

func NegativeInfinityFV2

func NegativeInfinityFV2() FixVector2

func NewFixVector2

func NewFixVector2(x, y Fix64) FixVector2

返回:新向量

func PositiveInfinityFV2

func PositiveInfinityFV2() FixVector2

func ScaleFV2

func ScaleFV2(a, b FixVector2) FixVector2

func SubFV2

func SubFV2(a, b FixVector2) FixVector2

返回:a - b 向量

func XAxisFV2

func XAxisFV2() FixVector2

X 轴 单位向量

func XYAxisFV2

func XYAxisFV2() FixVector2

func YAxisFV2

func YAxisFV2() FixVector2

Y 轴 单位向量

func ZeroFV2

func ZeroFV2() FixVector2

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

func (*FixVector2) Add

func (this *FixVector2) Add(v FixVector2)

func (*FixVector2) Clone

func (this *FixVector2) Clone() FixVector2

func (*FixVector2) Divide

func (this *FixVector2) Divide(scalar Fix64)

func (*FixVector2) Dot

func (this *FixVector2) Dot(v FixVector2) Fix64

向量:点积

func (*FixVector2) Equal

func (this *FixVector2) Equal(v FixVector2) bool

func (*FixVector2) Magnitude

func (this *FixVector2) Magnitude() Fix64

向量:长度

func (*FixVector2) Multiply

func (this *FixVector2) Multiply(scalar Fix64)

func (*FixVector2) Nomalized

func (this *FixVector2) Nomalized() FixVector2

单位化值 (0向量禁用)

func (*FixVector2) Normalize

func (this *FixVector2) Normalize()

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

func (*FixVector2) Scale

func (this *FixVector2) Scale(v FixVector2)

向量:分向量乘

func (*FixVector2) ScaleToLength

func (this *FixVector2) ScaleToLength(newLength Fix64)

朝向不变拉长度

func (*FixVector2) ScaledToLength

func (this *FixVector2) ScaledToLength(newLength Fix64) FixVector2

复制朝向定长

func (*FixVector2) Set

func (this *FixVector2) Set(x, y Fix64)

func (*FixVector2) SqrMagnitude

func (this *FixVector2) SqrMagnitude() Fix64

向量:长度平方

func (*FixVector2) Sub

func (this *FixVector2) Sub(v FixVector2)

func (*FixVector2) Vector2

func (a *FixVector2) Vector2() Vector2

type FixVector3

type FixVector3 struct {
	X Fix64
	Y Fix64
	Z Fix64
}

/ FixVector3

func AddFV3

func AddFV3(a, b FixVector3) FixVector3

func BackFix

func BackFix() FixVector3

func CrossFV3

func CrossFV3(a, b FixVector3) FixVector3

返回:a X b 向量 (X 叉乘)

func DownFix

func DownFix() FixVector3

func ForwardFix

func ForwardFix() FixVector3

func LeftFix

func LeftFix() FixVector3

func LerpFV3

func LerpFV3(from, to FixVector3, factor Fix64) FixVector3

func NewFixVector3

func NewFixVector3(x, y, z Fix64) FixVector3

func NormalizedFV3

func NormalizedFV3(a FixVector3) FixVector3

func RightFix

func RightFix() FixVector3

func ScaleFV3

func ScaleFV3(a, b FixVector3) FixVector3

返回:分向量乘

func SubFV3

func SubFV3(a, b FixVector3) FixVector3

func UpFix

func UpFix() FixVector3

func XAxisFix

func XAxisFix() FixVector3

X 轴 单位向量

func XYAxisFix

func XYAxisFix() FixVector3

func XYZAxisFix

func XYZAxisFix() FixVector3

func XZAxisFix

func XZAxisFix() FixVector3

func YAxisFix

func YAxisFix() FixVector3

YAxisFix Y轴单位向量

func YZAxisFix

func YZAxisFix() FixVector3

func ZAxisFix

func ZAxisFix() FixVector3

ZAxisFix Z轴 单位向量

func ZeroFix

func ZeroFix() FixVector3

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

func (*FixVector3) Add

func (this *FixVector3) Add(b FixVector3)

func (*FixVector3) Clone

func (this *FixVector3) Clone() FixVector3

func (*FixVector3) Cross

func (this *FixVector3) Cross(b FixVector3)

func (*FixVector3) Divide

func (this *FixVector3) Divide(b Fix64)

func (*FixVector3) Dot

func (this *FixVector3) Dot(b FixVector3) Fix64

func (*FixVector3) Equal

func (this *FixVector3) Equal(v FixVector3) bool

func (*FixVector3) Float

func (this *FixVector3) Float() string

func (*FixVector3) FromVector3

func (this *FixVector3) FromVector3(v *Vector3)

func (FixVector3) GetHashCode

func (this FixVector3) GetHashCode() int64

func (*FixVector3) Magnitude

func (this *FixVector3) Magnitude() Fix64

func (*FixVector3) Multiply

func (this *FixVector3) Multiply(b Fix64)

func (*FixVector3) Normalize

func (this *FixVector3) Normalize()

func (*FixVector3) Normalized

func (this *FixVector3) Normalized() FixVector3

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

func (*FixVector3) Scale

func (this *FixVector3) Scale(v FixVector3)

向量:分向量乘

func (*FixVector3) ScaleToLength

func (this *FixVector3) ScaleToLength(newLength Fix64)

朝向不变拉长度

func (*FixVector3) ScaledToLength

func (this *FixVector3) ScaledToLength(newLength Fix64) FixVector3

复制朝向定长

func (*FixVector3) Set

func (this *FixVector3) Set(x, y, z Fix64)

func (*FixVector3) SetVec

func (this *FixVector3) SetVec(v FixVector3)

func (*FixVector3) SqrMagnitude

func (this *FixVector3) SqrMagnitude() Fix64

func (*FixVector3) Sub

func (this *FixVector3) Sub(b FixVector3)

func (*FixVector3) ToString

func (this *FixVector3) ToString() string

func (*FixVector3) Vector2

func (this *FixVector3) Vector2() Vector2

func (*FixVector3) Vector3

func (this *FixVector3) Vector3() Vector3

type POSKEY

type POSKEY int64

type Vec

type Vec[T constraints.Integer | constraints.Float] struct {
	X T `json:"x"`
	Y T `json:"y"`
	Z T `json:"z"`
}

func (*Vec[T]) Add

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

func (*Vec[T]) Clone

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

func (*Vec[T]) Cross

func (this *Vec[T]) Cross(v Vec[T]) Vec[T]

func (*Vec[T]) Divide

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

func (*Vec[T]) Dot

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

func (*Vec[T]) Equal

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

func (*Vec[T]) Lerp

func (this *Vec[T]) Lerp(v Vec[T], t T) Vec[T]

func (*Vec[T]) Magnitude

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

func (*Vec[T]) MagnitudeSqr

func (this *Vec[T]) MagnitudeSqr() T

func (*Vec[T]) Multiply

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

func (*Vec[T]) Normalize

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

func (*Vec[T]) Normalized

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

func (*Vec[T]) Scale

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

func (*Vec[T]) Set

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

func (*Vec[T]) Sub

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

type Vec2

type Vec2[T constraints.Integer | constraints.Float] struct {
	X T `json:"x"`
	Y T `json:"y"`
}

func (*Vec2[T]) Add

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

func (*Vec2[T]) Angle

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

func (*Vec2[T]) AngleDeg

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

func (*Vec2[T]) Clone

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

func (*Vec2[T]) Distance

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

func (*Vec2[T]) DistanceSqr

func (this *Vec2[T]) DistanceSqr(v Vec2[T]) 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]) Magnitude

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

func (*Vec2[T]) MagnitudeSqr

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

func (*Vec2[T]) Multiply

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

func (*Vec2[T]) Normalize

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

func (*Vec2[T]) Normalized

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

func (*Vec2[T]) Rotate

func (this *Vec2[T]) Rotate(angle T)

func (*Vec2[T]) RotateDeg

func (this *Vec2[T]) RotateDeg(angle T)

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]) Set

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

func (*Vec2[T]) Sub

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

type Vector2

type Vector2 struct {
	X float32 `json:"x"`
	Y float32 `json:"y"`
}

func AddArrayV2

func AddArrayV2(vs []Vector2, dv Vector2) []Vector2

func AddV2

func AddV2(a, b Vector2) Vector2

返回:a + b 向量

func LerpUnclampedV2

func LerpUnclampedV2(a, b Vector2, t float32) Vector2

func LerpV2

func LerpV2(a, b Vector2, t float32) Vector2

线性插值

func MultiplyV2

func MultiplyV2(v Vector2, scalars []float32) []Vector2

func NegativeInfinityV2

func NegativeInfinityV2() Vector2

func NewVector2

func NewVector2(x, y float32) Vector2

返回:新向量

func PositiveInfinityV2

func PositiveInfinityV2() Vector2

func ScaleV2

func ScaleV2(a, b Vector3) Vector2

func SubV2

func SubV2(a, b Vector2) Vector2

返回:a - b 向量

func XAxisV2

func XAxisV2() Vector2

X 轴 单位向量

func XYAxisV2

func XYAxisV2() Vector2

func YAxisV2

func YAxisV2() Vector2

Y 轴 单位向量

func ZeroV2

func ZeroV2() Vector2

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

func (*Vector2) Add

func (this *Vector2) Add(v1 Vector2)

func (*Vector2) Clone

func (this *Vector2) Clone() Vector2

func (*Vector2) Divide

func (this *Vector2) Divide(scalar float32)

func (*Vector2) Dot

func (this *Vector2) Dot(v Vector2) float32

向量:点积

func (*Vector2) Equal

func (this *Vector2) Equal(v1 Vector2) bool

func (*Vector2) Length

func (this *Vector2) Length() float32

func (*Vector2) Magnitude

func (this *Vector2) Magnitude() float32

向量:长度

func (*Vector2) Multiply

func (this *Vector2) Multiply(scalar float32)

func (*Vector2) Normalize

func (this *Vector2) Normalize()

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

func (*Vector2) Normalized

func (this *Vector2) Normalized() Vector2

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

func (*Vector2) Scale

func (this *Vector2) Scale(v Vector2)

向量:分向量乘

func (*Vector2) ScaleToLength

func (this *Vector2) ScaleToLength(newLength float32)

朝向不变拉长度

func (*Vector2) ScaledToLength

func (this *Vector2) ScaledToLength(newLength float32) Vector2

复制朝向定长

func (*Vector2) Set

func (this *Vector2) Set(x, y float32)

func (*Vector2) SqrMagnitude

func (this *Vector2) SqrMagnitude() float32

向量:长度平方

func (*Vector2) Sub

func (this *Vector2) Sub(v1 Vector2)

type Vector2Int

type Vector2Int struct {
	X int32 `json:"x"`
	Y int32 `json:"y"`
}

func (*Vector2Int) Add

func (this *Vector2Int) Add(v Vector2Int)

func (*Vector2Int) Clone

func (this *Vector2Int) Clone() Vector2Int

func (*Vector2Int) Equal

func (this *Vector2Int) Equal(v Vector2Int) bool

func (*Vector2Int) Key

func (this *Vector2Int) Key() uint32

func (*Vector2Int) Sub

func (this *Vector2Int) Sub(v Vector2Int)

func (*Vector2Int) ToVector3Int

func (this *Vector2Int) ToVector3Int() Vector3Int

type Vector3

type Vector3 struct {
	X float32 `json:"x"`
	Y float32 `json:"y"`
	Z float32 `json:"z"`
}

func AddArrayV3

func AddArrayV3(vs []Vector3, dv Vector3) []Vector3

func AddV3

func AddV3(a, b Vector3) Vector3

返回:a + b 向量

func BackV3

func BackV3() Vector3

func CrossV3

func CrossV3(a, b Vector3) Vector3

返回:a X b 向量 (X 叉乘)

func DownV3

func DownV3() Vector3

func ForwardV3

func ForwardV3() Vector3

func LeftV3

func LeftV3() Vector3

func LerpUnclampedV3

func LerpUnclampedV3(a, b Vector3, t float32) Vector3

func LerpV3

func LerpV3(a, b Vector3, t float32) Vector3

LerpV3 线性插值

func Max

func Max(a, b Vector3) Vector3

Max 返回由两个向量的最大分量组成的向量。

func Min

func Min(a, b Vector3) Vector3

Min 返回由两个向量的最小分量组成的向量。

func MultiplyV3

func MultiplyV3(v Vector3, scalars []float32) []Vector3

func NegativeInfinityV3

func NegativeInfinityV3() Vector3

func NewVector3

func NewVector3(x, y, z float32) Vector3

返回:新向量

func PositiveInfinityV3

func PositiveInfinityV3() Vector3

func RightV3

func RightV3() Vector3

func ScaleV3

func ScaleV3(a, b Vector3) Vector3

ScaleV3 返回:分向量乘

func SubV3

func SubV3(a, b Vector3) Vector3

返回:a - b 向量

func UpV3

func UpV3() Vector3

func XAxisV3

func XAxisV3() Vector3

X 轴 单位向量

func XYAxisV3

func XYAxisV3() Vector3

func XYZAxisV3

func XYZAxisV3() Vector3

func XZAxisV3

func XZAxisV3() Vector3

func YAxisV3

func YAxisV3() Vector3

Y 轴 单位向量

func YZAxisV3

func YZAxisV3() Vector3

func ZAxisV3

func ZAxisV3() Vector3

Z 轴 单位向量

func ZeroV3

func ZeroV3() Vector3

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

func (*Vector3) Add

func (this *Vector3) Add(v Vector3)

三维向量:加上 this = this + v

func (*Vector3) Clone

func (this *Vector3) Clone() Vector3

三维向量:拷贝

func (*Vector3) Cross

func (this *Vector3) Cross(v Vector3)

三维向量:叉积

func (*Vector3) Divide

func (this *Vector3) Divide(scalar float32)

三维向量:数除

func (*Vector3) Dot

func (this *Vector3) Dot(v Vector3) float32

三维向量:点积

func (*Vector3) Equal

func (this *Vector3) Equal(v Vector3) bool

func (*Vector3) Magnitude

func (this *Vector3) Magnitude() float32

三维向量:长度

func (*Vector3) Multiply

func (this *Vector3) Multiply(scalar float32)

三维向量:数乘 func (this *Vector3) Mul(scalar float32) {

func (*Vector3) Normalize

func (this *Vector3) Normalize()

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

func (*Vector3) Normalized

func (this *Vector3) Normalized() Vector3

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

func (*Vector3) RotateYAnticlockwise

func (this *Vector3) RotateYAnticlockwise(center Vector3, angle int) Vector3

绕(X,Z)平面绕center点逆时针旋转 anticlockwise

func (*Vector3) RotateYClockwise

func (this *Vector3) RotateYClockwise(center Vector3, angle int) Vector3

绕(X,Z)平面绕center点顺时针旋转 clockwise 与前端unity一致

func (*Vector3) Scale

func (this *Vector3) Scale(v Vector3)

三维向量:分向量乘

func (*Vector3) ScaleToLength

func (this *Vector3) ScaleToLength(newLength float32)

朝向不变拉长度

func (*Vector3) ScaledToLength

func (this *Vector3) ScaledToLength(newLength float32) Vector3

复制朝向定长

func (*Vector3) Set

func (this *Vector3) Set(x, y, z float32)

三维向量:设值

func (*Vector3) SetVec

func (this *Vector3) SetVec(v Vector3)

func (*Vector3) SqrMagnitude

func (this *Vector3) SqrMagnitude() float32

三维向量:长度平方

func (*Vector3) Sub

func (this *Vector3) Sub(v Vector3)

三维向量:减去 this = this - v

func (*Vector3) Vector2

func (this *Vector3) Vector2() Vector2

type Vector3Int

type Vector3Int struct {
	X int32
	Y int32
	Z int32
}

func ZeroV3Int

func ZeroV3Int() Vector3Int

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

func (*Vector3Int) Add

func (this *Vector3Int) Add(v Vector3Int)

func (*Vector3Int) AddVal

func (this *Vector3Int) AddVal(v Vector3Int) Vector3Int

func (Vector3Int) Clone

func (this Vector3Int) Clone() Vector3Int

func (*Vector3Int) Equal

func (this *Vector3Int) Equal(v Vector3Int) bool

func (*Vector3Int) IsZero

func (this *Vector3Int) IsZero() bool

func (*Vector3Int) Key

func (this *Vector3Int) Key() POSKEY

func (*Vector3Int) ManhattanDistance

func (this *Vector3Int) ManhattanDistance(v Vector3Int) int32

func (*Vector3Int) RotateX

func (this *Vector3Int) RotateX(angle int) Vector3Int

func (*Vector3Int) Set

func (this *Vector3Int) Set(x, y, z int32)

func (*Vector3Int) ShortKey

func (this *Vector3Int) ShortKey() uint32

func (*Vector3Int) Sub

func (this *Vector3Int) Sub(v Vector3Int)

func (*Vector3Int) SubVal

func (this *Vector3Int) SubVal(v Vector3Int) Vector3Int

func (Vector3Int) ToVector2Int

func (this Vector3Int) ToVector2Int() Vector2Int

Jump to

Keyboard shortcuts

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