geom

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

type Line struct {
	Start Point `json:"start" msgpack:"start"` // start point
	End   Point `json:"end" msgpack:"end"`     // end point
}

////////////////////////////////////////////////////////////////////////////////

func (Line) IntersectLine

func (l Line) IntersectLine(m Line) bool

线段是否相交

func (Line) String

func (l Line) String() string

type Point

type Point struct {
	X float64 `json:"x" msgpack:"x"`
	Y float64 `json:"y" msgpack:"y"`
}

////////////////////////////////////////////////////////////

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Angle

func (p Point) Angle(q Point) float64

func (Point) Div

func (p Point) Div(k float64) Point

Div returns the vector p/k.

func (Point) In

func (p Point) In(r Rectangle) bool

In reports whether p is in r.

func (Point) Mul

func (p Point) Mul(k float64) Point

Mul returns the vector p*k.

func (Point) Sec4

func (p Point) Sec4() int

Point in Section.

func (Point) String

func (p Point) String() string

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

type Polygon

type Polygon struct {
	Points []Point `json:"points" msgpack:"points"`
}

//////////////////////////////////////////////////////////////////////////// 多边形

func (Polygon) LineIntersect

func (p Polygon) LineIntersect(line Line) bool

判断线段是否与图形相交

func (Polygon) PointAt

func (p Polygon) PointAt(point Point) bool

判断点在多边形内

func (Polygon) String

func (p Polygon) String() string

type Rectangle

type Rectangle struct {
	Min Point `json:"min" msgpack:"min"`
	Max Point `json:"max" msgpack:"max"`
}

////////////////////////////////////////////////////////////////////////// 矩形

func (Rectangle) BottomLine

func (r Rectangle) BottomLine() Line

获取底部线段

func (Rectangle) CenterPoint

func (r Rectangle) CenterPoint() Point

获取矩形中点坐标

func (Rectangle) LineIn

func (r Rectangle) LineIn(line Line) bool

判断线段在矩形内

func (Rectangle) PointAt

func (r Rectangle) PointAt(point Point) bool

判断点在矩形内

func (Rectangle) String

func (r Rectangle) String() string

Jump to

Keyboard shortcuts

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