pinpol

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 1 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INF float64 = 10000

INF Define Infinite

Functions

func IsInside

func IsInside(polygon []Point, n int, p Point) bool

IsInside returns true if the point p lies inside the polygon[] with n vertices

Types

type Point

type Point struct {
	X float64
	Y float64
}

Point type for points...

Jump to

Keyboard shortcuts

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