region

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PCInside      PlacementCode = 0x00               // 0000
	PCBottom                    = 0x01               // 0001
	PCTop                       = 0x02               // 0010
	PCRight                     = 0x04               // 0100
	PCLeft                      = 0x08               // 1000
	PCTopRight                  = PCTop | PCRight    // 0110
	PCTopLeft                   = PCTop | PCLeft     // 1010
	PCBottomRight               = PCBottom | PCRight // 0101
	PCBottomLeft                = PCBottom | PCLeft  // 1001

	PCAllAround = PCTop | PCLeft | PCRight | PCBottom // 1111
)

Variables

View Source
var ErrNoDirection = errors.New("Line does not have direction on that coordinate.")

Functions

This section is empty.

Types

type Axis

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

func (*Axis) AsLine

func (a *Axis) AsLine() maths.Line

AsLine returns the Axis as a line.

func (*Axis) GoString

func (a *Axis) GoString() string

func (*Axis) Intersect

func (a *Axis) Intersect(line maths.Line) (pt maths.Pt, doesIntersect bool)

Intersect finds the intersections point if one exists with the line described by pt0,pt1. This point will be clamped to the line of the clipping region.

func (*Axis) IsInward

func (a *Axis) IsInward(line maths.Line) (bool, error)

IsInward returns weather the line described by pt1,pt2 is headed inward with respect to the Axis.

func (*Axis) Next

func (a *Axis) Next() *Axis

Next returns the next Axis, or nil if there aren't anymore.

func (*Axis) Placement

func (a *Axis) Placement(pt maths.Pt) PlacementCode

Placement returns where according to the region axis the point is.

                     0010

	       pt   ______  pt
	           |      |
	    1000   | 0000 |    0100
	           |______|
	       pt           pt
	             0001

func (*Axis) PushInBetween

func (a *Axis) PushInBetween(pt list.ElementerPointer) bool

PushInBetween inserts the pt into the region list on this Axis.

type Intersect

type Intersect struct {
	// Pt is the intersect point.
	Pt maths.Pt
	// Is the vector this point is on heading into the region.
	Inward bool
	// Index of the Axis this point was found on.
	Idx int
	// contains filtered or unexported fields
}

Intersect holds the intersect point and the direction of the vector it's on. Into or out of the clipping region.

type IntersectionCode

type IntersectionCode uint8

IntersectionCode encodes weather the intersect point found has the following points. 1. Is there an intersection point. 2. If the there is an intersection point, is it inward bound for that axises 3. Is it contained within the region.

type IntersectionPt

type IntersectionPt struct {
	Code IntersectionCode
}

type PlacementCode

type PlacementCode uint8

type Region

type Region struct {
	list.List
	// contains filtered or unexported fields
}

A region is made up of axises and a winding order. A region can hold other points along it's axises.

func New

func New(winding maths.WindingOrder, Min, Max maths.Pt) *Region

New creates a new region, initilization paramters as needed.

func (*Region) Axis

func (r *Region) Axis(idx int) *Axis

func (*Region) Contains

func (r *Region) Contains(pt maths.Pt) bool

func (*Region) DebugStringAugmented

func (r *Region) DebugStringAugmented(augmenter func(idx int, e maths.Pt) string) string

func (*Region) FirstAxis

func (r *Region) FirstAxis() *Axis

func (*Region) GoString

func (r *Region) GoString() string

func (*Region) Init

func (r *Region) Init(winding maths.WindingOrder, Min, Max maths.Pt) *Region

Init initilizes the region struct.

func (*Region) Intersections

func (r *Region) Intersections(l maths.Line) (out []Intersect, Pt1Placement, Pt2Placement PlacementCode)

Intersections returns zero to four intersections points. You should remove any duplicate and cancelling intersections points afterwards.

func (*Region) LineString

func (r *Region) LineString() []float64

func (*Region) Max

func (r *Region) Max() maths.Pt

func (*Region) Min

func (r *Region) Min() maths.Pt

func (*Region) SentinalPoints

func (r *Region) SentinalPoints() (pts []maths.Pt)

func (*Region) WindingOrder

func (r *Region) WindingOrder() maths.WindingOrder

Jump to

Keyboard shortcuts

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