Skip to content
/ pinpol Public

Golang package to check if a point is inside a polygon.

License

Notifications You must be signed in to change notification settings

serxoz/pinpol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Point IN POLygon

This package checks if a point is inside a polygon.

Example

package main

import (
	"fmt"

	pin "github.com/serxoz/pinpol"
)

func main() {
	// Point
	p := pin.Point{X: 2, Y: 2}

	// Polygon
	var poly []pin.Point
	poly = append(poly, pin.Point{X: 1, Y: 1})
	poly = append(poly, pin.Point{X: 1, Y: 3})
	poly = append(poly, pin.Point{X: 3, Y: 3})
	poly = append(poly, pin.Point{X: 3, Y: 1})

	// Check if point "p" is inside polygon "poly"
	in := pin.IsInside(poly, len(poly), p)

	fmt.Println(in)
}

Doc

Based in Patrick Prosser Geometric Algorithms saved in doc/ for the future :D

About

Golang package to check if a point is inside a polygon.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages