physics

package
v0.0.0-...-a8a18e3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistorySize = 16

	UnitsPerMeter = 512
	UnitsPerQuat  = 1024

	PositionUnit = 1.0 / UnitsPerMeter
	QuatUnit     = 1.0 / UnitsPerQuat
)

Variables

This section is empty.

Functions

func BoolsStr

func BoolsStr(a []bool) string

func DeltaProps

func DeltaProps(hist, base []Cube) func(i int) int

func ExtraProps

func ExtraProps(hist, base, cur []Cube) func(i int) int

func IndexProps

func IndexProps(index []int, N int) []int

func Props

func Props(base []Cube) func(i int) int

func SameBools

func SameBools(a, b []bool)

func SetDeltaProps

func SetDeltaProps(base, cur []Cube) func(i int, v int)

func SetExtraProps

func SetExtraProps(hist, base, cur []Cube) func(i int, v int)

func SetProps

func SetProps(cur []Cube) func(i int, v int)

func SortByZ

func SortByZ(items []int, get func(i int) int)

func SortByZCount

func SortByZCount(items []int, get func(i int) int)

Types

type Cube

type Cube struct {
	Pos Position
	Rot Rotation

	Interacting bool
}

func (*Cube) ReadFrom

func (cube *Cube) ReadFrom(r io.Reader) error

Cube utilities

func (*Cube) WriteTo

func (cube *Cube) WriteTo(w io.Writer) error

type Frame

type Frame struct {
	Cubes []Cube
}

func NewFrame

func NewFrame(size int) *Frame

func (*Frame) Assign

func (frame *Frame) Assign(other *Frame)

func (*Frame) Equals

func (a *Frame) Equals(b *Frame) bool

func (*Frame) ReadFrom

func (frame *Frame) ReadFrom(r io.Reader) error

func (*Frame) WriteTo

func (frame *Frame) WriteTo(w io.Writer) error

type Position

type Position struct{ X, Y, Z float32 }

func (Position) Equals

func (a Position) Equals(b Position) bool

func (Position) Len

func (p Position) Len() float32

func (Position) Sub

func (a Position) Sub(b Position) Position

type Rotation

type Rotation struct{ X, Y, Z, W float32 }

func (Rotation) Equals

func (a Rotation) Equals(b Rotation) bool

type State

type State struct {
	History    [HistorySize]*Frame
	FrameIndex int
}

func NewState

func NewState(size int) *State

func (*State) Baseline

func (s *State) Baseline() *Frame

func (*State) Current

func (s *State) Current() *Frame

func (*State) Decode

func (s *State) Decode(snapshot []byte)

func (*State) Encode

func (s *State) Encode() []byte

func (*State) Historic

func (s *State) Historic() *Frame

func (*State) IncFrame

func (s *State) IncFrame()

func (*State) Prev

func (s *State) Prev(i int) *Frame

func (*State) ReadNext

func (s *State) ReadNext(r io.Reader) error

Jump to

Keyboard shortcuts

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