PolygonHelper

package
v1.1.47 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

README

PolygonHelper

多边形处理

1. PolygonContains

判断点是否在一个多边形区域内, 支持凸多边形与凹多边形(算法源于QT的QPolygonF)

Example

    var pg PolygonHelper.PolygonContains
	// 凸多边形
	pg.Append(PolygonHelper.Point{-8234.09, 3247.55})
	pg.Append(PolygonHelper.Point{-9207.86, -9216.69})
	pg.Append(PolygonHelper.Point{179.271, -14085.5})
	pg.Append(PolygonHelper.Point{10657, -9995.71})
	pg.Append(PolygonHelper.Point{11903.5, 2234.83})
	pg.Append(PolygonHelper.Point{2360.52, 7376.33})
	pg.Append(PolygonHelper.Point{-8234.09, 3247.55})
	p1In := PolygonHelper.Point{-7212, -7941}
	p1Out := PolygonHelper.Point{-7455, -12956}
	if pg.ContainsPoint(p1In) {
		log.Println("点p1In在多边形区域内")
	} else {
		log.Println("点p1In不在多边形区域内")
	}
	if pg.ContainsPoint(p1Out) {
		log.Println("点p1Out在多边形区域内")
	} else {
		log.Println("点p1Out不在多边形区域内")
	}

Documentation

Index

Constants

View Source
const (
	OddEvenFill = iota
	WindingFill
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	X float64
	Y float64
}

type PolygonContains

type PolygonContains struct {
	// contains filtered or unexported fields
}

* 多边形是否包含点

func (*PolygonContains) Append

func (this *PolygonContains) Append(p Point)

func (*PolygonContains) Clear

func (this *PolygonContains) Clear()

func (*PolygonContains) ContainsPoint

func (this *PolygonContains) ContainsPoint(pt Point) bool

Jump to

Keyboard shortcuts

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