physics

package
v0.0.0-...-79996cc Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lerp

func Lerp(a, b, t float64) float64

Lerp performs linear interpolation between two numbers.

a and b are the two bounds of the number, and t is a fraction between 0 and 1 that will return a number between a and b. If t=0, returns a; if t=1, returns b.

func LerpInt

func LerpInt(a, b int, t float64) float64

LerpInt runs lerp using integers.

Types

type Mover

type Mover struct {
	Acceleration float64
	Friction     float64

	// // Position and previous frame's position.
	// Position    render.Point
	// OldPosition render.Point
	//
	// // Speed and previous frame's speed.
	// Speed    render.Point
	// OldSpeed render.Point
	MaxSpeed Vector
}

Mover is a moving object.

func NewMover

func NewMover() *Mover

NewMover initializes state for a moving object.

type Vector

type Vector struct {
	X float64
	Y float64
}

Vector holds floating point values on an X and Y coordinate.

func NewVector

func NewVector(x, y float64) Vector

NewVector creates a Vector from X and Y values.

func VectorFromPoint

func VectorFromPoint(p render.Point) Vector

VectorFromPoint converts a render.Point into a vector.

func (*Vector) Add

func (v *Vector) Add(other Vector)

Add to the vector.

func (Vector) IsZero

func (v Vector) IsZero() bool

IsZero returns if the vector is zero.

func (Vector) String

func (v Vector) String() string

String encoding of the vector.

func (Vector) ToPoint

func (v Vector) ToPoint() render.Point

ToPoint converts the vector into a render.Point with integer coordinates.

Jump to

Keyboard shortcuts

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