plane

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 1 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plane is a box as a Space holds it: a geom.AABB that knows its own size and how far it runs past the far edges of a wrapping world, so that its wrapped pieces follow from it. It is the public face of the geometry a Space normalises; the normalising itself is done by the Space.

AABB

An AABB embeds a geom.AABB and adds a Size, which survives clamping at an edge, and an Overhang: how far the box reaches past the right and bottom edge of the world once its top-left corner has been folded inside. A box with no Overhang lies whole in the world. NewAABB builds one not yet folded by any Space; Space.WrapAABB, Space.Place and Space.Move of package aabbworld fold it.

Fragments

A box straddling a wrapping seam is its main piece plus up to three wrapped pieces, named by FragPosition: FRAG_RIGHT for what came back through the left edge, FRAG_BOTTOM for what came back through the top, FRAG_BOTTOM_RIGHT for the corner that did both. AABB.VisitFragments hands each wrapped piece to a FragVisitor until it says stop; the main piece is the embedded geom.AABB itself.

Overlap

AABB.DeepestOverlapWith compares every piece of one box with every piece of another and returns the deepest Overlap: the two pieces that meet and the penetration between them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AABB

type AABB struct {
	geom.AABB
	Size     geom.Vec
	Overhang geom.Vec
}

AABB is a box kept canonical within a Space: its corners, its size, and its Overhang — how far it runs past the world's far edges, from which its wrapped pieces follow.

func NewAABB

func NewAABB(pos geom.Vec, width, height float64) AABB

NewAABB builds a AABB at pos with the given size, not yet wrapped by any Space.

func (*AABB) DeepestOverlapWith

func (ab *AABB) DeepestOverlapWith(other *AABB) (Overlap, bool)

DeepestOverlapWith is the deepest overlap of ab and other, wrapped images included, if any.

func (AABB) Equals

func (ab AABB) Equals(other AABB) bool

Equals reports whether ab and other share the same corners.

func (AABB) String

func (ab AABB) String() string

String formats the aabb using its top-left and bottom-right corners.

func (*AABB) VisitFragments

func (ab *AABB) VisitFragments(fn FragVisitor)

VisitFragments calls fn for each piece the box wraps into, until fn returns false.

type FragPosition

type FragPosition int

FragPosition names a wrapped piece of a box by the edge of the parent it lies past.

const (
	FRAG_MAIN FragPosition = iota
	// FRAG_RIGHT is the fragment that spans the parent's right edge.
	FRAG_RIGHT
	// FRAG_BOTTOM is the fragment along the parent's bottom edge.
	FRAG_BOTTOM
	// FRAG_BOTTOM_RIGHT is the fragment covering the parent's bottom-right quadrant.
	FRAG_BOTTOM_RIGHT
)

type FragVisitor

type FragVisitor func(pos FragPosition, box geom.AABB) bool

FragVisitor is handed each wrapped piece of a box and says whether to go on to the next.

type Overlap

type Overlap struct {
	BoxA, BoxB  geom.AABB
	Penetration geom.Vec
}

Overlap is where two wrapped boxes meet: which image of each was involved, and how deeply they interpenetrate.

Jump to

Keyboard shortcuts

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