plane

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 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 defines 2D spaces (cartesian and torus) plus plane-aware boxes and metrics. It wraps geometry primitives with boundary-aware behaviours, handling clamping/wrapping, fragmentation across edges, translations, and distance calculations reused by higher-level modules.

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