winding

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package winding provides primitives for determining the winding order of a set of points

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Orient

func Orient(pts ...[2]float64) int8

Orient will take the points and calculate the Orientation of the points. by summing the normal vectors. It will return 0 of the given points are colinear or 1, or -1 for clockwise and counter clockwise depending on the direction of the y axis. If the y axis increase as you go up on the graph then clockwise will be -1, otherwise it will be 1; vice versa for counter-clockwise.

Types

type Order

type Order struct {
	YPositiveDown bool
}

Order configures how the orientation of a set of points is determined

func (Order) Clockwise

func (Order) Clockwise() Winding

Clockwise returns a clockwise winding

func (Order) Colinear

func (Order) Colinear() Winding

Colinear returns a colinear winding

func (Order) Collinear

func (Order) Collinear() Winding

Collinear is a alias for colinear

func (Order) CounterClockwise

func (Order) CounterClockwise() Winding

CounterClockwise returns a counter clockwise winding

func (Order) OfGeomPoints

func (order Order) OfGeomPoints(points ...geom.Point) Winding

OfGeomPoints returns the winding of the given geom points

func (Order) OfInt64Points

func (order Order) OfInt64Points(ipts ...[2]int64) Winding

OfInt64Points returns the winding of the given int64 points

func (Order) OfPoints

func (order Order) OfPoints(pts ...[2]float64) Winding

OfPoints returns the winding of the given points

func (Order) RectifyPolygon

func (order Order) RectifyPolygon(plyg2r [][][2]float64) [][][2]float64

RectifyPolygon will make sure that the rings are of the correct orientation, if not it will reverse them Colinear rings are dropped

func (Order) ThreePointsAreColinear

func (order Order) ThreePointsAreColinear(pt1, pt2, pt3 geom.Point) bool

type Winding

type Winding int8

Winding is the clockwise direction of a set of points.

const (

	// Clockwise indicates that the winding order is in the clockwise direction
	Clockwise Winding = -1
	// Colinear indicates that the points are colinear to each other
	Colinear Winding = 0
	// CounterClockwise indicates that the winding order is in the counter clockwise direction
	CounterClockwise Winding = 1

	// Collinear alternative spelling of Colinear
	Collinear = Colinear
)

func OfGeomPoints

func OfGeomPoints(points ...geom.Point) Winding

OfGeomPoints is the same as OfPoints, just a convenience to unwrap geom.Point

func OfPoints

func OfPoints(pts ...[2]float64) Winding

OfPoints returns the winding order of the given points

func Orientation

func Orientation(yPositiveDown bool, pts ...[2]float64) Winding

Orientation returns the orientation of the set of the points given the direction of the positive values of the y axis

func (Winding) IsClockwise

func (w Winding) IsClockwise() bool

IsClockwise checks if winding is clockwise

func (Winding) IsColinear

func (w Winding) IsColinear() bool

IsColinear check if the points are colinear

func (Winding) IsCounterClockwise

func (w Winding) IsCounterClockwise() bool

IsCounterClockwise checks if winding is counter clockwise

func (Winding) Not

func (w Winding) Not() Winding

Not returns the inverse of the winding, clockwise <-> counter-clockwise, colinear is it's own inverse

func (Winding) ShortString

func (w Winding) ShortString() string

func (Winding) String

func (w Winding) String() string

String implements the stringer interface

Jump to

Keyboard shortcuts

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