simulation

package
v0.0.0-...-4051f3d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const G float64 = 6.674e-11

Variables

View Source
var EarthMoon = [...]Body{
	{
		Mass:     5.972e24,
		Position: r2.Vec{X: 0, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     7.347e22,
		Position: r2.Vec{X: 384.4e6, Y: 0},
		Velocity: r2.Vec{X: 0, Y: -1022.0},
	},
	{
		Mass:     1,
		Position: r2.Vec{X: 1.922e8, Y: 3.329e8},
		Velocity: r2.Vec{X: 1022.0 * math.Cos(30.0*math.Pi/180) * 0.98, Y: -1022.0 * math.Sin(30*math.Pi/180)},
	},
}
View Source
var FourBodySystem = [...]Body{
	{
		Mass:     1e12,
		Position: r2.Vec{X: 0, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     1e11,
		Position: r2.Vec{X: 0, Y: 15},
		Velocity: r2.Vec{X: 2.3, Y: 0},
	},
	{
		Mass:     1e10,
		Position: r2.Vec{X: 0, Y: 13.5},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     1e9,
		Position: r2.Vec{X: 0, Y: 4},
		Velocity: r2.Vec{X: 4, Y: 0},
	},
}
View Source
var GravitySlingshot = [...]Body{
	{
		Mass:     1e13,
		Position: r2.Vec{X: 0, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     1e12,
		Position: r2.Vec{X: 15, Y: 0},
		Velocity: r2.Vec{X: 0, Y: -7},
	},
	{
		Mass:     1e11,
		Position: r2.Vec{X: -15, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 5},
	},
}
View Source
var LagrangeL4L5 = [...]Body{
	{
		Mass:     1e12,
		Position: r2.Vec{X: 0, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     1e10,
		Position: r2.Vec{X: 20, Y: 0},
		Velocity: r2.Vec{X: 0, Y: -1.836},
	},
	{
		Mass:     1,
		Position: r2.Vec{X: 10, Y: 17.32},
		Velocity: r2.Vec{X: 0.965 * 1.836 * math.Cos(30.0*math.Pi/180), Y: -1.836 * math.Sin(30*math.Pi/180)},
	},
}
View Source
var ThreeBodyUnstableSystem = [...]Body{
	{
		Mass:     1e12,
		Position: r2.Vec{X: 0, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 0},
	},
	{
		Mass:     1e12,
		Position: r2.Vec{X: 15, Y: 0},
		Velocity: r2.Vec{X: 0, Y: 3},
	},
	{
		Mass:     1e12,
		Position: r2.Vec{X: 0, Y: 11},
		Velocity: r2.Vec{X: -2, Y: 0},
	},
}

Functions

This section is empty.

Types

type Body

type Body struct {
	Mass float64

	Acceleration r2.Vec
	Position     r2.Vec
	Velocity     r2.Vec
}

type Simulation

type Simulation struct {
	TimeStep       float64
	SimulationStep uint64

	Bodies []Body
}

func NewSimulation

func NewSimulation(timeStep float64) *Simulation

func (*Simulation) CalculateAccelerationAt

func (sim *Simulation) CalculateAccelerationAt(pos r2.Vec) r2.Vec

func (*Simulation) CalculateCenterOfMass

func (sim *Simulation) CalculateCenterOfMass() r2.Vec

func (*Simulation) CalculateTotalEnergy

func (sim *Simulation) CalculateTotalEnergy() float64

func (*Simulation) Step

func (sim *Simulation) Step()

Jump to

Keyboard shortcuts

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