binpack

package
v0.0.0-...-7972720 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis int
const (
	AxisX Axis = iota
	AxisY
	AxisZ
)

type Box

type Box struct {
	Origin Vector
	Size   Vector
}

func (Box) Cut

func (box Box) Cut(axis Axis, offset int) (Box, Box)

func (Box) Cuts

func (box Box) Cuts(a1, a2, a3 Axis, s1, s2, s3 int) (Box, Box, Box)

type Item

type Item struct {
	ID    int
	Score int
	Size  Vector
}

type Placement

type Placement struct {
	Item     Item
	Position Vector
}

type Result

type Result struct {
	Score      int
	Placements []Placement
}

func MakeResult

func MakeResult(r0, r1, r2 Result, item Item, position Vector) Result

func Pack

func Pack(items []Item, box Box) Result

func (Result) Translate

func (result Result) Translate(offset Vector) Result

type SpatialHash

type SpatialHash struct {
	CellSize int
	Cells    map[SpatialKey][]*SpatialValue
}

func NewSpatialHash

func NewSpatialHash(cellSize int) *SpatialHash

func (*SpatialHash) Add

func (h *SpatialHash) Add(min, max Vector, result Result)

func (*SpatialHash) Get

func (h *SpatialHash) Get(v Vector) (Result, bool)

func (*SpatialHash) KeyForVector

func (h *SpatialHash) KeyForVector(v Vector) SpatialKey

type SpatialKey

type SpatialKey struct {
	X, Y, Z int
}

type SpatialValue

type SpatialValue struct {
	Min, Max Vector
	Result   Result
}

type Vector

type Vector struct {
	X, Y, Z int
}

func (Vector) Add

func (a Vector) Add(b Vector) Vector

func (Vector) Fits

func (a Vector) Fits(b Vector) bool

func (Vector) GreaterThanOrEqual

func (a Vector) GreaterThanOrEqual(b Vector) bool

func (Vector) LessThanOrEqual

func (a Vector) LessThanOrEqual(b Vector) bool

func (Vector) Max

func (a Vector) Max(b Vector) Vector

func (Vector) Min

func (a Vector) Min(b Vector) Vector

func (Vector) Negate

func (a Vector) Negate() Vector

func (Vector) Sort

func (a Vector) Sort() Vector

func (Vector) Sub

func (a Vector) Sub(b Vector) Vector

Jump to

Keyboard shortcuts

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