Documentation ¶
Index ¶
- Constants
- Variables
- type Axis
- func (a *Axis) AsLine() maths.Line
- func (a *Axis) GoString() string
- func (a *Axis) Intersect(line maths.Line) (pt maths.Pt, doesIntersect bool)
- func (a *Axis) IsInward(line maths.Line) (bool, error)
- func (a *Axis) Next() *Axis
- func (a *Axis) Placement(pt maths.Pt) PlacementCode
- func (a *Axis) PushInBetween(pt list.ElementerPointer) bool
- type Intersect
- type IntersectionCode
- type IntersectionPt
- type PlacementCode
- type Region
- func (r *Region) Axis(idx int) *Axis
- func (r *Region) Contains(pt maths.Pt) bool
- func (r *Region) DebugStringAugmented(augmenter func(idx int, e maths.Pt) string) string
- func (r *Region) FirstAxis() *Axis
- func (r *Region) GoString() string
- func (r *Region) Init(winding maths.WindingOrder, Min, Max maths.Pt) *Region
- func (r *Region) Intersections(l maths.Line) (out []Intersect, Pt1Placement, Pt2Placement PlacementCode)
- func (r *Region) LineString() []float64
- func (r *Region) Max() maths.Pt
- func (r *Region) Min() maths.Pt
- func (r *Region) SentinalPoints() (pts []maths.Pt)
- func (r *Region) WindingOrder() maths.WindingOrder
Constants ¶
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 ¶
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) Intersect ¶
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 ¶
IsInward returns weather the line described by pt1,pt2 is headed inward with respect to the Axis.
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 ¶
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 parameters as needed.
func (*Region) DebugStringAugmented ¶
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 (*Region) SentinalPoints ¶
func (*Region) WindingOrder ¶
func (r *Region) WindingOrder() maths.WindingOrder