zbvec

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Absi32

func Absi32(n int32) int32

func Absi64

func Absi64(n int64) int64

func Isqrt32

func Isqrt32(square int32) int32

func Isqrt64

func Isqrt64(square int64) uint32

func Square2

func Square2(p1, p2 []int32) int64

func Square3

func Square3(p1, p2 []int32) int64

Types

type ABRect2

type ABRect2 struct {
	P1, P2 Point2
}

ABRect2 AABB 2d矩形

type ABRect3

type ABRect3 struct {
	P1, P2 Point3
}

ABRect3 AABB 3d矩形

type Circle

type Circle struct {
	Centre Point2
	Radius int32
}

Circle 圆

func (*Circle) AddRadius

func (this *Circle) AddRadius(added int32) *Circle

func (*Circle) CrsLine

func (this *Circle) CrsLine(pt1, pt2 *Point2) bool

CrsLine 判断圆是否交于(Cross)线段

func (*Circle) CrsPoint

func (this *Circle) CrsPoint(pt *Point2) bool

type Convex2

type Convex2 struct {
	Vertex [4]*Point2
}

Convex2 顶点版本的2d凸四边形

func (*Convex2) CrsCircle

func (this *Convex2) CrsCircle(cc *Circle) bool

CrsCircle 判断圆是否交于(Cross)凸四边形

type Dir2

type Dir2 struct {
	Mlongitude uint16 //经度0~359,无效值:999,X轴正方向为0,Y轴正方向90,X轴负方向180,Y负方向270
}

func Arctan2

func Arctan2(src *Point2, dest *Point2) Dir2

------------------------------------

  • func Arctan2/Arctan3,计算src到dest的空间经纬角度

func Invd2

func Invd2() Dir2

func NewDir2

func NewDir2(longitude uint16) *Dir2

func NewDir2p

func NewDir2p(prot uint32) *Dir2

func (Dir2) Add

func (this Dir2) Add(longitude int16) Dir2

func (Dir2) Between

func (this Dir2) Between(dir Dir2, half uint16) bool

角度范围判断

func (Dir2) Dir2Vec

func (dir Dir2) Dir2Vec(veclen int32) *Vector2

Dir2Vec 角度方向Dir与向量的互转

func (Dir2) Marshal

func (this Dir2) Marshal() *uint32

func (*Dir2) Set

func (this *Dir2) Set(longitude uint16)

func (Dir2) To3d

func (this Dir2) To3d(latitude uint8) Dir3

func (*Dir2) UnMarshal

func (this *Dir2) UnMarshal(prot uint32)

type Dir3

type Dir3 struct {
	Dir2
	Mlatitude uint8 //纬度0~180,无效值::199,Z轴正方向为0,负方向为180
}

func Arctan3

func Arctan3(src *Point3, dest *Point3) Dir3

func Invd3

func Invd3() Dir3

func NewDir3

func NewDir3(longitude uint16, latitude uint8) *Dir3

func NewDir3p

func NewDir3p(prot uint32) *Dir3

func (Dir3) Between

func (this Dir3) Between(dir Dir3, half1 uint16, half2 uint8) bool

func (Dir3) Dir2Vec

func (dir Dir3) Dir2Vec(veclen int32) *Vector3

func (Dir3) Marshal

func (this Dir3) Marshal() *uint32

func (*Dir3) Set

func (this *Dir3) Set(longitude uint16, latitude uint8)

func (Dir3) To2d

func (this Dir3) To2d() Dir2

func (*Dir3) UnMarshal

func (this *Dir3) UnMarshal(prot uint32)

type Line2

type Line2 struct {
	Vertex [2]Point2
}

Line2 二维的线段

func (*Line2) CrsCircle

func (this *Line2) CrsCircle(cc *Circle) bool

CrsCircle 判断线段是否交于(Cross)圆

type Point2

type Point2 struct {
	X, Y int32
}

func Invp2

func Invp2() Point2

func Move2p

func Move2p(p Point2, dir Dir2, distance int32) Point2

func MoveBySpd2

func MoveBySpd2(dir Dir2, MOV_SPD_PS int32, timesize_ms int32) (delta *Point2)

MoveBySpd2 MOV_SPD_PS-移动速度(cm/s);timesize_ms移动的毫秒数

func NewPoint2

func NewPoint2(x, y int32) *Point2

func NewPoint2p

func NewPoint2p(prot []int32) *Point2

func (*Point2) Equal

func (this *Point2) Equal(other *Point2) bool

相等判断

func (*Point2) InRect2

func (this *Point2) InRect2(r *ABRect2) bool

func (*Point2) Len

func (this *Point2) Len() int16

func (*Point2) Marshal

func (this *Point2) Marshal() []int32

func (*Point2) Move

func (this *Point2) Move(dir Dir2, distance int32)

func (*Point2) MoveBySpd

func (this *Point2) MoveBySpd(dir Dir2, MOV_SPD_PS int32, timesize_ms int32) *Point2

MoveBySpd MOV_SPD_PS-移动速度(cm/s);timesize_ms移动的毫秒数

func (*Point2) MoveRatio

func (this *Point2) MoveRatio(dst *Point2, molec, denom int64)

MoveRatio molec-分子;denom-分母

func (*Point2) P2pVec

func (src *Point2) P2pVec(dst *Point2) *Vector2

P2pVec 点到点的向量

func (*Point2) Set

func (this *Point2) Set(x, y int32)

func (*Point2) Setidx

func (this *Point2) Setidx(idx int16, v int32)

func (*Point2) Square

func (this *Point2) Square(other *Point2) int64

点点距离平方

func (*Point2) To3d

func (this *Point2) To3d(z int32) *Point3

func (*Point2) UnMarshal

func (this *Point2) UnMarshal(prot []int32)

type Point3

type Point3 struct {
	Point2
	Z int32
}

func Invp3

func Invp3() Point3

func Move3p

func Move3p(p Point3, dir Dir3, distance int32) Point3

func MoveBySpd3

func MoveBySpd3(dir Dir3, MOV_SPD_PS int32, timesize_ms int32) (delta *Point3)

Move3s MOV_SPD_PS-移动速度(cm/s);timesize_ms移动的毫秒数

func NewPoint3

func NewPoint3(x, y, z int32) *Point3

func NewPoint3p

func NewPoint3p(prot []int32) *Point3

func (*Point3) Equal

func (this *Point3) Equal(other *Point3) bool

func (*Point3) InRect3

func (this *Point3) InRect3(r *ABRect3) bool

func (*Point3) Len

func (this *Point3) Len() int16

func (*Point3) Marshal

func (this *Point3) Marshal() []int32

func (*Point3) Move

func (this *Point3) Move(dir Dir3, distance int32)

func (*Point3) MoveBySpd

func (this *Point3) MoveBySpd(dir Dir3, MOV_SPD_PS int32, timesize_ms int32) *Point3

MoveBySpd MOV_SPD_PS-移动速度(cm/s);timesize_ms移动的毫秒数

func (*Point3) MoveRatio

func (this *Point3) MoveRatio(dst *Point3, molec, denom int64)

func (*Point3) P2pVec

func (src *Point3) P2pVec(dst *Point3) *Vector3

func (*Point3) Set

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

func (*Point3) Setidx

func (this *Point3) Setidx(idx int16, v int32)

func (*Point3) Square

func (this *Point3) Square(other *Point3) int64

func (*Point3) To2d

func (this *Point3) To2d() *Point2

func (*Point3) UnMarshal

func (this *Point3) UnMarshal(prot []int32)

type Rect2

type Rect2 struct {
	Centre  Point2
	Length  int32 //dir方向的边长
	Width   int32 //dir垂直方向的边长
	CentDir Dir2
}

Rect2 非AABB型2d矩形

func (*Rect2) CrsCircle

func (this *Rect2) CrsCircle(cc *Circle) bool

CrsCircle 判断圆是否交于(Cross)矩形

type Sector

type Sector struct {
	Centre    Point2 //扇形圆心
	Radius    int32  //扇形半径
	HalfAngle int16  //扇形夹角半角度
	CentDir   Dir2   //扇形中线方向
}

Sector 扇形

func (*Sector) CrsCircle

func (this *Sector) CrsCircle(cc *Circle) bool

扇形相较于圆

func (*Sector) CrsPoint

func (this *Sector) CrsPoint(pt *Point2) bool

Crs为Cross的简写,意为相交判断 扇形相较于点

type Triangle2

type Triangle2 struct {
	Vertex [3]Point2
}

Triangle2 平面三角形

func (*Triangle2) CrsCircle

func (this *Triangle2) CrsCircle(cc *Circle) bool

CrsCircle 判断圆是否交于(Cross)三角形

func (*Triangle2) CrsPoint

func (this *Triangle2) CrsPoint(pt *Point2) bool

CrsPoint 判断点是不是在三角形中(Cross)

type Vector2

type Vector2 Point2 //2d向量

func (*Vector2) Add

func (this *Vector2) Add(o *Vector2) *Vector2

Add 向量加

func (*Vector2) AngleVs180

func (this *Vector2) AngleVs180(o *Vector2) int

AngleVs180 向量的夹角判断,向量this往向量o逆时针旋转的角度比较于180°: [<180°ret -1][=180°ret 0][>180°ret 1]

func (*Vector2) AngleVs90

func (this *Vector2) AngleVs90(o *Vector2) int

AngleVs90 向量的夹角判断,向量this与向量夹角比较于90°: [<90°ret -1][=90°ret 0][>90°ret 1]

func (*Vector2) CrsMult

func (this *Vector2) CrsMult() *Vector2

CrsMult 叉乘、外积、矢量积、向量积(2d求顺时针垂直向量,3d返回法线向量)

func (*Vector2) DotMult

func (this *Vector2) DotMult(o *Vector2) int64

DotMult 点积、内积、标量积、数量积

func (*Vector2) Move

func (this *Vector2) Move(duration_ms int64, MOV_SPD_PS int64) (delta *Vector2)

func (*Vector2) NumMult

func (this *Vector2) NumMult(n, m int32) *Vector2

--------------------------------------------------------------------------------------------------------- NumMult 向量坐标缩放n/m系数

func (*Vector2) RevsDir

func (this *Vector2) RevsDir() *Vector2

RevsDir 逆向等长向量

func (*Vector2) Scale

func (this *Vector2) Scale(newlen int32) *Vector2

Scale 方向不变,缩放向量到新长度

func (*Vector2) Square

func (this *Vector2) Square() int64

Square 向量长度的平方

func (*Vector2) Sub

func (this *Vector2) Sub(o *Vector2) *Vector2

Sub 向量减

func (*Vector2) To3d

func (this *Vector2) To3d(z int32) *Vector3

func (*Vector2) Vec2Dir

func (this *Vector2) Vec2Dir() Dir2

type Vector3

type Vector3 Point3 //3d向量

func (*Vector3) Add

func (this *Vector3) Add(o *Vector3) *Vector3

func (*Vector3) AngleVs90

func (this *Vector3) AngleVs90(o *Vector3) int

func (*Vector3) CrsMult

func (this *Vector3) CrsMult(o *Vector3) *Vector3

func (*Vector3) DotMult

func (this *Vector3) DotMult(o *Vector3) int64

func (*Vector3) Move

func (this *Vector3) Move(duration_ms int64, MOV_SPD_PS int64) (delta *Vector3)

func (*Vector3) NumMult

func (this *Vector3) NumMult(n, m int32) *Vector3

func (*Vector3) RevsDir

func (this *Vector3) RevsDir() *Vector3

func (*Vector3) Scale

func (this *Vector3) Scale(newlen int32) *Vector3

func (*Vector3) Square

func (this *Vector3) Square() int64

func (*Vector3) Sub

func (this *Vector3) Sub(o *Vector3) *Vector3

func (*Vector3) To2d

func (this *Vector3) To2d() *Vector2

func (*Vector3) Vec2Dir

func (this *Vector3) Vec2Dir() Dir3

Jump to

Keyboard shortcuts

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