martinez_rueda

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 7 Imported by: 1

README

Martinez-Rueda polygon boolean operations algorithm

PHP implementation of original algorithm http://www4.ujaen.es/~fmartin/bool_op.html

Algorithm is used for computing Boolean operations on polygons:

  • union
  • difference
  • intersection
  • xor

Usage

Input parameter is a multipolygon - an array of polygons. And each polygon is an array of points x,y.

   TODO

Some visual examples

Let's consider two polygons: green multipolygon of two polygons and yellow polygon.

Snow-white polygon is result of Boolean operation on two polygons.

Union
Difference (green NOT yellow)
Intersection
Xor

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SEID int

Functions

func DestinationPoint

func DestinationPoint(point orb.Point, meters, bearingDegrees float64) orb.Point

DestinationPoint return the destination from a point based on a distance and bearing. Given a start point and a distance d along constant bearing θ, this will calculate the destina­tion point. If you maintain a constant bearing along a rhumb line, you will gradually spiral in towards one of the poles.

Types

type Connector

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

func NewConnector

func NewConnector() Connector

type Contour

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

func NewContour

func NewContour(points []orb.Point) Contour

func (*Contour) Add

func (c *Contour) Add(point orb.Point)

func (*Contour) GetPoint

func (c *Contour) GetPoint(index int) orb.Point

func (*Contour) Nvertices

func (c *Contour) Nvertices() int

type EDGE_TYPE

type EDGE_TYPE uint
const (
	EDGE_NORMAL               EDGE_TYPE = 1
	EDGE_NON_CONTRIBUTING     EDGE_TYPE = 2
	EDGE_SAME_TRANSITION      EDGE_TYPE = 3
	EDGE_DIFFERENT_TRANSITION EDGE_TYPE = 4
)

type Events

type Events []*SweepEvent

type OPERATION

type OPERATION string
const (
	OP_INTERSECTION OPERATION = "INTERSECTION"
	OP_UNION        OPERATION = "UNION"
	OP_DIFFERENCE   OPERATION = "DIFFERENCE"
	OP_XOR          OPERATION = "XOR"
)

type POLYGON_TYPE

type POLYGON_TYPE uint
const (
	POLYGON_TYPE_SUBJECT  POLYGON_TYPE = 1
	POLYGON_TYPE_CLIPPING POLYGON_TYPE = 2
)

type PointChain

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

func NewPointChain

func NewPointChain(initSegment Segment) *PointChain

func (*PointChain) Size added in v1.0.1

func (pc *PointChain) Size() int

type Polygon

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

func Compute

func Compute(subject *Polygon, clipping *Polygon, operation OPERATION) (result *Polygon)

func NewPolygon

func NewPolygon(contours_xy []Contour) *Polygon

Get array of contours (each is array of points and each point is 2-size array)

func (*Polygon) DEBUG

func (p *Polygon) DEBUG()

type PriorityQueue

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

Priority queue that holds sweep-events sorted from left to right.

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

type Segment

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

func NewSegment

func NewSegment(p1 orb.Point, p2 orb.Point) Segment

type SweepEvent

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

func NewSweepEvent

func NewSweepEvent(p orb.Point, isLeft bool, associatedPolygon POLYGON_TYPE, other *SweepEvent, edgeType EDGE_TYPE) *SweepEvent

type SweepLine

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

func NewSweepLine

func NewSweepLine() SweepLine

Jump to

Keyboard shortcuts

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