matrix

package
v0.0.0-...-bd0de05 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const RATE_DENOMINATOR int32 = 10000

Variables

This section is empty.

Functions

func AbsFloat64

func AbsFloat64(val float64) float64

func AbsI16

func AbsI16(val int16) int16

func AbsI32

func AbsI32(val int32) int32

func Ceil

func Ceil(v float64) int32

func Distance

func Distance(a, b Vector3) float64

求两点间距离

func DistanceSq

func DistanceSq(a, b Vector3) float64

求两点间距离平方

func Floor

func Floor(v float64) int32

func GetAngle

func GetAngle(v1, v2 Vector3) (angel float64)

求两向量夹角

func GetRad

func GetRad(v1, v2 Vector3) (angel float64)

求两向量弧度

func LimitFloat32Min

func LimitFloat32Min(value, min float32) float32

func LimitFloat64

func LimitFloat64(value float64, min float64, max float64) float64

//////////////////--LimitFloat64--/////////////////////////

func LimitFloat64Max

func LimitFloat64Max(value, max float64) float64

func LimitFloat64Min

func LimitFloat64Min(value, min float64) float64

func LimitInt

func LimitInt(value int, min int, max int) int

//////////////////--LimitInt--/////////////////////////

func LimitInt16

func LimitInt16(value int16, min int16, max int16) int16

//////////////////--LimitInt16--/////////////////////////

func LimitInt16Max

func LimitInt16Max(value int16, max int16) int16

func LimitInt16Min

func LimitInt16Min(value int16, min int16) int16

func LimitInt32

func LimitInt32(value int32, min int32, max int32) int32

//////////////////--LimitInt32--/////////////////////////

func LimitInt32Max

func LimitInt32Max(value int32, max int32) int32

func LimitInt32Min

func LimitInt32Min(value int32, min int32) int32

func LimitInt64

func LimitInt64(value int64, min int64, max int64) int64

//////////////////--LimitInt64--/////////////////////////

func LimitInt64Max

func LimitInt64Max(value int64, max int64) int64

func LimitInt64Min

func LimitInt64Min(value int64, min int64) int64

func LimitIntMax

func LimitIntMax(value int, max int) int

func LimitIntMin

func LimitIntMin(value int, min int) int

func MaxFloat64

func MaxFloat64(a, b float64) float64

func MaxInt16

func MaxInt16(a, b int16) int16

func MaxInt32

func MaxInt32(a, b int32) int32

func MinFloat64

func MinFloat64(a, b float64) float64

func MinInt16

func MinInt16(a, b int16) int16

func MinInt32

func MinInt32(a, b int32) int32

func Random

func Random(min int, max int) int

[min, max]

func Random16

func Random16(min int16, max int16) int16

[min, max]

func Random32

func Random32(min int32, max int32) int32

[min, max]

func Random64

func Random64(min int64, max int64) int64

[min, max]

func RandomMatched

func RandomMatched(rate int32) bool

概率为Rate的随机,是否随到。 范围为RATE_DENOMINATOR(10000)

func RandomMatchedPercent

func RandomMatchedPercent(rate int32) bool

百分比 概率为Rate的随机,是否随到

func RandomRate

func RandomRate() int32

计算随机数

func RandomU32

func RandomU32(min uint32, max uint32) uint32

[min, max]

func Round

func Round(f float64, n int) float64

func RoundInt32

func RoundInt32(v float64) int32

Types

type RotateAxis

type RotateAxis uint
const (
	ROTATE_AXIS_X RotateAxis = 0
	ROTATE_AXIS_Y RotateAxis = 1
	ROTATE_AXIS_Z RotateAxis = 2
)

type Vector2D

type Vector2D struct {
	X float32
	Y float32
}
var NormLeftX *Vector2D = &Vector2D{X: -1.0}
var NormLeftY *Vector2D = &Vector2D{Y: -1.0}
var NormRightX *Vector2D = &Vector2D{X: 1.0}
var NormRightY *Vector2D = &Vector2D{Y: 1.0}

func (*Vector2D) Add

func (this *Vector2D) Add(v *Vector2D) *Vector2D

func (*Vector2D) Angle

func (this *Vector2D) Angle(v *Vector2D) float64

func (*Vector2D) Clear

func (this *Vector2D) Clear()

func (*Vector2D) ContainInRange

func (this *Vector2D) ContainInRange(v *Vector2D, r float32) bool

func (*Vector2D) ContainInRectRange

func (this *Vector2D) ContainInRectRange(v *Vector2D, r float32) bool

func (*Vector2D) Copy

func (this *Vector2D) Copy() *Vector2D

func (*Vector2D) Cross

func (this *Vector2D) Cross(op *Vector2D) float64

copy from r2.point

func (*Vector2D) Distance

func (this *Vector2D) Distance(v *Vector2D) float64

func (*Vector2D) DistanceSq

func (this *Vector2D) DistanceSq(v *Vector2D) float64

func (*Vector2D) Div

func (this *Vector2D) Div(v float32) *Vector2D

func (*Vector2D) Dot

func (this *Vector2D) Dot(op *Vector2D) float64

func (*Vector2D) Equal

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

func (*Vector2D) IsZero

func (this *Vector2D) IsZero() bool

func (*Vector2D) Length

func (this *Vector2D) Length() float32

func (*Vector2D) LengthSq

func (this *Vector2D) LengthSq() float64

func (*Vector2D) Mul

func (this *Vector2D) Mul(v float32) *Vector2D

func (*Vector2D) Norm

func (this *Vector2D) Norm() *Vector2D

func (*Vector2D) Orth

func (this *Vector2D) Orth() *Vector2D

func (*Vector2D) Radian

func (this *Vector2D) Radian(v *Vector2D) float64

func (*Vector2D) Reverse

func (this *Vector2D) Reverse() *Vector2D

func (*Vector2D) Rotate

func (this *Vector2D) Rotate(alpha float64) *Vector2D

func (*Vector2D) RotateAngle

func (this *Vector2D) RotateAngle(angle float64) *Vector2D

func (*Vector2D) Sub

func (this *Vector2D) Sub(v *Vector2D) *Vector2D

func (*Vector2D) ToAngle

func (this *Vector2D) ToAngle() float64

func (*Vector2D) ToRadian

func (this *Vector2D) ToRadian() float64

type Vector3

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

三维向量:(x,y,z)

func Add3

func Add3(a, b Vector3) Vector3

返回:a + b 向量

func AddArray3

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

func Cross3

func Cross3(a, b Vector3) Vector3

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

func Multiply

func Multiply(v Vector3, scalars float64) Vector3

func Multiply3

func Multiply3(v Vector3, scalars []float64) []Vector3

func NewVector3

func NewVector3(x, y, z float64) Vector3

返回:新向量

func Normalize3

func Normalize3(a Vector3) Vector3

返回:单位化向量

func Sub3

func Sub3(a, b Vector3) Vector3

返回:a - b 向量

func XAxis3

func XAxis3() Vector3

X 轴 单位向量

func XYAxis3

func XYAxis3() Vector3

func XYZAxis3

func XYZAxis3() Vector3

func XZAxis3

func XZAxis3() Vector3

func YAxis3

func YAxis3() Vector3

Y 轴 单位向量

func YZAxis3

func YZAxis3() Vector3

func ZAxis3

func ZAxis3() Vector3

Z 轴 单位向量

func Zero3

func Zero3() 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 float64)

func (*Vector3) Dot

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

三维向量:点积

func (*Vector3) Equal

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

func (*Vector3) FormatFloatFloor

func (this *Vector3) FormatFloatFloor(decimal int)

格式化数据(取小数点后decimal位有效四舍五入后的数据)

func (*Vector3) IsZero

func (this *Vector3) IsZero() bool

func (*Vector3) Length

func (this *Vector3) Length() float64

三维向量:长度

func (*Vector3) LengthSq

func (this *Vector3) LengthSq() float64

三维向量:长度平方

func (*Vector3) Multiply

func (this *Vector3) Multiply(scalar float64)

三维向量:数乘

func (*Vector3) Normalize

func (this *Vector3) Normalize()

三维向量:单位化

func (*Vector3) Rotate

func (this *Vector3) Rotate(axis RotateAxis, alpha float64) (v Vector3)

沿 axis 轴顺时针旋转 alpha 弧度

func (*Vector3) RotateAngle

func (this *Vector3) RotateAngle(axis RotateAxis, angle float64) Vector3

沿 axis 轴顺时针旋转 angle 欧拉角度

func (*Vector3) Set

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

三维向量:设值

func (*Vector3) Sub

func (this *Vector3) Sub(v Vector3)

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

Jump to

Keyboard shortcuts

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