data

package
v0.0.0-...-65d0b4a Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	IsStar   bool        // IsStar : Is this the star of the system
	Name     string      // Name : The name of the star/planet
	Radius   float64     // Radius : The radius of the star/planet
	Mass     float64     // Mass : Tha mass of the star/planet
	Position Vector2     // Position : The position of the star/planet
	Velocity Vector2     // Velocity : The velocity of the star/planet
	Color    string      // Color : The color of the star/planet in HEX form
	ColorObj color.Color // ColorObj : The color of the star/planet in RGB form

	DistanceToStar float64   // DistanceToStar : The distance to the star of the system
	Orbit          []Vector2 // Orbit : The orbit of the planet
}

Body : A celestial body, star or planet

func (*Body) Attraction

func (b *Body) Attraction(other *Body) Vector2

Attraction : Calculates the attraction between two bodies

func (*Body) UpdatePosition

func (b *Body) UpdatePosition(solar *SolarSystem, timestamp float64)

UpdatePosition : Update the position each cycle

type SolarSystem

type SolarSystem struct {
	CenterX, CenterY float64
	Bodies           []*Body
}

SolarSystem : A system containing a star and one or more planets

type Vector2

type Vector2 struct {
	X, Y float64
}

Vector2 : A 2-dimensional vector

func (Vector2) Add

func (v Vector2) Add(o Vector2) Vector2

Add : Adds two vectors

func (Vector2) Div

func (v Vector2) Div(d float64) Vector2

Div : Divides a vector with a divisor

func (Vector2) Length

func (v Vector2) Length() float64

Length : Returns the length of a vector

func (Vector2) Mul

func (v Vector2) Mul(m float64) Vector2

Mul : Multiplies a vector with a factor

func (Vector2) Sub

func (v Vector2) Sub(o Vector2) Vector2

Sub : Subtracts to vectors

Jump to

Keyboard shortcuts

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