motion

package
v0.0.0-...-876d3e7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Components = components{
	Dynamics: warehouse.FactoryNewComponent[Dynamics](),
}
View Source
var Forces forcesHandler

Forces is the global forces handler instance

View Source
var Resolver resolver

Resolver is the global collision resolver instance

View Source
var VerticalResolver verticalResolver

VerticalResolver is the Global vertical collision resolver instance

Functions

func ApplyImpulse

func ApplyImpulse(dyn *Dynamics, linearImpulse, torqueArm vector.Two)

ApplyImpulse applies both linear and angular impulse to a dynamics object

func Integrate

func Integrate(dyn *Dynamics, position vector.TwoReader, rotation, dt float64) (newPosition vector.Two, newRotation float64)

Integrate updates position and rotation based on dynamics over the given time step

func IntegrateAngular

func IntegrateAngular(dyn *Dynamics, rotation float64, dt float64) (newRotation float64)

IntegrateAngular calculates new rotation based on torque, angular acceleration and velocity

func IntegrateLinear

func IntegrateLinear(dyn *Dynamics, pos vector.TwoReader, dt float64) (newPos vector.Two)

IntegrateLinear calculates new position based on forces, acceleration and velocity

Types

type Dynamics

type Dynamics struct {
	UnstoppableLinear, UnstoppableAngular bool
	Accel, Vel, SumForces                 vector.Two
	InverseMass                           float64
	AngularVel, AngularAccel, SumTorque   float64
	InverseAngularMass                    float64
	Friction, Elasticity                  float64
}

Dynamics represents the physical properties and state of a movable entity

func NewDynamics

func NewDynamics(mass float64) Dynamics

NewDynamics creates a new Dynamics component with the specified mass

func (*Dynamics) SetAngularMass

func (dyn *Dynamics) SetAngularMass(angularMass float64)

SetAngularMass updates the inverse angular mass based on the provided angular mass

func (*Dynamics) SetDefaultAngularMass

func (dyn *Dynamics) SetDefaultAngularMass(shape spatial.Shape) error

SetDefaultAngularMass calculates and sets appropriate angular mass based on shape type

func (*Dynamics) SetMass

func (dyn *Dynamics) SetMass(mass float64)

SetMass updates the inverse mass based on the provided mass

Jump to

Keyboard shortcuts

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