shape

package
v0.0.0-...-7b43bce Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDistance

func CalculateDistance(x1, y1, x2, y2 float64) float64

计算两点之间的距离

func GetAngle

func GetAngle(baseX, baseY, targetX, targetY float64) float64

*

  • 获得从基准点到目标点的角度
  • @param baseX
  • @param baseY
  • @param targetX
  • @param targetY
  • @return

func GetRadians

func GetRadians(baseX, baseY, targetX, targetY float64) float64

*

  • 获得从基准点到目标点的弧度
  • @param baseX
  • @param baseY
  • @param targetX
  • @param targetY
  • @return

func IsInsideCircle

func IsInsideCircle(cx, cy, radius, x, y float64) bool

判断点是否在圆内 (cx, cy) 是圆心的坐标,radius 是圆的半径,(x, y) 是点的坐标

func RadiansToDegrees

func RadiansToDegrees(radians float64) float64

* 将弧度转换为度数

Types

type Coord

type Coord int

Coord is the of coordinations entity position (x, y, z)

type Rect

type Rect struct {
	X, Y, Width, Height int64
}

左上角坐标系

func (Rect) Contains

func (r Rect) Contains(x, y int64) bool

Contains 判断点是否在矩形内

func (Rect) ContainsRect

func (r Rect) ContainsRect(rect2 Rect) bool

Contains 判断点是否在矩形内

type Vector3

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

Vector3 is type of entity position

func (Vector3) Add

func (p Vector3) Add(o Vector3) Vector3

func (*Vector3) Copy

func (p *Vector3) Copy(o Vector3)

func (Vector3) DirToYaw

func (p Vector3) DirToYaw() float32

DirToYaw convert direction represented by Vector3 to Yaw

func (Vector3) DistanceTo

func (p Vector3) DistanceTo(o Vector3) Coord

DistanceTo calculates distance between two positions

func (Vector3) Mul

func (p Vector3) Mul(m Coord) Vector3

Mul calculates Vector3 p * m

func (*Vector3) Normalize

func (p *Vector3) Normalize()

func (Vector3) Normalized

func (p Vector3) Normalized() Vector3

func (Vector3) String

func (p Vector3) String() string

func (Vector3) Sub

func (p Vector3) Sub(o Vector3) Vector3

Sub calculates Vector3 p - Vector3 o

Jump to

Keyboard shortcuts

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