systems

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

README

systems

Collection of physics-based systems that implement specialized simulation behaviors using the entity-component architecture.

Notes

  • Implements different physical systems for rocket simulation (physics, aerodynamics, launch rail)
  • Follows entity-component system (ECS) principles for modular design
  • Handles forces calculation and motion updates for simulation entities
  • Defines constraints and rules for entity interactions
  • Manages simulation state transitions during flight phases
  • Includes parallel processing capabilities for performance optimization
  • Provides clean interfaces for integration with the core simulation loop
  • Implements specialized mathematics for aerospace applications

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateInertia

func CalculateInertia(entity *states.PhysicsState) float64

CalculateInertia returns a simplified moment of inertia value for pitch/yaw

Types

type AerodynamicSystem

type AerodynamicSystem struct {
	// contains filtered or unexported fields
}

AerodynamicSystem calculates aerodynamic forces on entities

func NewAerodynamicSystem

func NewAerodynamicSystem(world *ecs.World, isa *atmosphere.ISAModel, log logf.Logger) *AerodynamicSystem

NewAerodynamicSystem creates a new aerodynamic system

func (*AerodynamicSystem) Add

func (a *AerodynamicSystem) Add(entity *states.PhysicsState)

Add implements System interface

func (*AerodynamicSystem) CalculateAerodynamicMoment

func (a *AerodynamicSystem) CalculateAerodynamicMoment(entity states.PhysicsState) types.Vector3

CalculateAerodynamicMoment calculates the aerodynamic moments on the entity

func (*AerodynamicSystem) CalculateDrag

func (a *AerodynamicSystem) CalculateDrag(entity *states.PhysicsState) types.Vector3

CalculateDrag calculates drag force in world frame

func (*AerodynamicSystem) Remove added in v0.8.0

func (a *AerodynamicSystem) Remove(basic ecs.BasicEntity)

Remove implements System interface

func (*AerodynamicSystem) Update

func (a *AerodynamicSystem) Update(dt float32)

Update implements ecs.System interface

func (*AerodynamicSystem) UpdateWithError added in v0.8.0

func (a *AerodynamicSystem) UpdateWithError(dt float64) error

UpdateWithError implements System interface

type EventLog

type EventLog struct {
	Time    float64
	Type    string
	Details string
}

Event represents a significant event during simulation

type LaunchRail

type LaunchRail struct {
	Length      float64
	Angle       float64 // Angle from vertical in degrees
	Orientation float64 // Compass orientation in degrees
}

LaunchRail represents a launch rail

type LaunchRailSystem

type LaunchRailSystem struct {
	// contains filtered or unexported fields
}

LaunchRailSystem constrains entities to a launch rail

func NewLaunchRailSystem

func NewLaunchRailSystem(world *ecs.World, length, angleDegrees, orientationDegrees float64, logger *logf.Logger) *LaunchRailSystem

NewLaunchRailSystem creates a new LaunchRailSystem

func (*LaunchRailSystem) Add

func (s *LaunchRailSystem) Add(pe *states.PhysicsState)

Add adds a physics entity to the launch rail system

func (*LaunchRailSystem) GetEntities

func (s *LaunchRailSystem) GetEntities() []*states.PhysicsState

GetEntities returns the tracked entities

func (*LaunchRailSystem) GetRail

func (s *LaunchRailSystem) GetRail() LaunchRail

GetRail returns the launch rail configuration

func (*LaunchRailSystem) InitializeRocketPosition added in v0.8.0

func (lrs *LaunchRailSystem) InitializeRocketPosition(rocketState *states.PhysicsState)

InitializeRocketPosition sets the initial X and Y position of the rocket based on the launch rail.

func (*LaunchRailSystem) IsOnRail

func (s *LaunchRailSystem) IsOnRail() bool

IsOnRail returns whether the system is still constraining to the rail

func (*LaunchRailSystem) Update

func (s *LaunchRailSystem) Update(dt float32)

Update implements ecs.System interface

func (*LaunchRailSystem) UpdateWithError added in v0.8.0

func (s *LaunchRailSystem) UpdateWithError(dt float64) error

UpdateWithError implements System interface

type LogParasiteSystem

type LogParasiteSystem struct {
	// contains filtered or unexported fields
}

LogParasiteSystem logs rocket state data

func NewLogParasiteSystem

func NewLogParasiteSystem(world *ecs.World, logger logf.Logger) *LogParasiteSystem

NewLogParasiteSystem creates a new LogParasiteSystem

func (*LogParasiteSystem) Add

Add adds entities to the system

func (*LogParasiteSystem) Start

func (s *LogParasiteSystem) Start(dataChan chan *states.PhysicsState)

Start the LogParasiteSystem

func (*LogParasiteSystem) Stop

func (s *LogParasiteSystem) Stop()

Stop the LogParasiteSystem

func (*LogParasiteSystem) Update

func (s *LogParasiteSystem) Update(dt float32)

Update implements ecs.System interface

func (*LogParasiteSystem) UpdateWithError added in v0.8.0

func (s *LogParasiteSystem) UpdateWithError(dt float64) error

UpdateWithError implements System interface

type ParasiteSystem

type ParasiteSystem interface {
	ecs.System
	Start(dataChan chan *states.PhysicsState)
	Stop()
}

ParasiteSystem extends the base System interface

type PhysicsSystem

type PhysicsSystem struct {
	// contains filtered or unexported fields
}

PhysicsSystem calculates forces on entities

func NewPhysicsSystem

func NewPhysicsSystem(world *ecs.World, cfg *config.Engine, logger logf.Logger, workers int) *PhysicsSystem

NewPhysicsSystem creates a new PhysicsSystem

func (*PhysicsSystem) Add

func (s *PhysicsSystem) Add(pe *states.PhysicsState)

Add adds an entity to the system

func (*PhysicsSystem) Remove

func (s *PhysicsSystem) Remove(basic ecs.BasicEntity)

Remove removes an entity from the system

func (*PhysicsSystem) String

func (s *PhysicsSystem) String() string

String returns the system name

func (*PhysicsSystem) Update

func (s *PhysicsSystem) Update(dt float32)

Update implements ecs.System interface

func (*PhysicsSystem) UpdateWithError added in v0.8.0

func (s *PhysicsSystem) UpdateWithError(dt float64) error

UpdateWithError implements System interface

type Result added in v0.8.0

type Result struct {
	// contains filtered or unexported fields
}

Result represents the outcome of a physics calculation

type RulesSystem

type RulesSystem struct {
	// contains filtered or unexported fields
}

RulesSystem enforces rules of flight

func NewRulesSystem

func NewRulesSystem(world *ecs.World, config *config.Engine, logger logf.Logger) *RulesSystem

NewRulesSystem creates a new RulesSystem

func (*RulesSystem) Add

func (s *RulesSystem) Add(entity *states.PhysicsState)

Add adds a physics entity to the rules system

func (*RulesSystem) DetectApogee

func (s *RulesSystem) DetectApogee(entity *states.PhysicsState) bool

func (*RulesSystem) GetLastEvent

func (s *RulesSystem) GetLastEvent() types.Event

GetLastEvent returns the last event detected by the rules system

func (*RulesSystem) ProcessRules

func (s *RulesSystem) ProcessRules(entity *states.PhysicsState) types.Event

func (*RulesSystem) Update

func (s *RulesSystem) Update(dt float32)

Update implements ecs.System interface

func (*RulesSystem) UpdateWithError added in v0.8.0

func (s *RulesSystem) UpdateWithError(dt float64) error

UpdateWithError implements System interface

type StorageParasiteSystem

type StorageParasiteSystem struct {
	// contains filtered or unexported fields
}

StorageParasiteSystem logs rocket state data to storage

func NewStorageParasiteSystem

func NewStorageParasiteSystem(world *ecs.World, storage storage.StorageInterface, storeType storage.SimStorageType) *StorageParasiteSystem

NewStorageParasiteSystem creates a new StorageParasiteSystem

func (*StorageParasiteSystem) Add

Add adds entities to the system

func (*StorageParasiteSystem) Start

func (s *StorageParasiteSystem) Start(dataChan chan *states.PhysicsState) error

Start the StorageParasiteSystem

func (*StorageParasiteSystem) Stop

func (s *StorageParasiteSystem) Stop()

Stop the StorageParasiteSystem

func (*StorageParasiteSystem) Update

func (s *StorageParasiteSystem) Update(dt float64) error

Update the StorageParasiteSystem

type System

type System interface {
	// UpdateWithError updates the system state
	UpdateWithError(dt float64) error

	// Add adds entities to the system
	Add(pe *states.PhysicsState)
}

System defines the interface that all systems must implement

Jump to

Keyboard shortcuts

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