physics

package
v0.0.0-...-00fdc72 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: BlueOak-1.0.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// C is the speed of light in m/s.
	C = rat.Float(299792458.0)

	// Gee is one standard earth gravitational acceleration in m/s^2.
	Gee = rat.Float(9.800665) // m/s^2

	// NegGee is a negative Gee.
	NegGee = rat.Float(-9.800665) // m/s^2
)

Functions

func AccelerationDistance

func AccelerationDistance(x0, v0, a, t *big.Rat) *big.Rat

AccelerationDistance computes the distance traveled during an acceleration.

func AccelerationVelocity

func AccelerationVelocity(v0, a, t *big.Rat) *big.Rat

AccelerationVelocity computes the final velocity after an acceleration.

func AstronomicalUnit

func AstronomicalUnit(au float64) *big.Rat

AstronomicalUnit return the number of meters for a given number of AU.

func DistanceString

func DistanceString(d *big.Rat) string

DistanceString prints out the distance in a human-readable form.

func LightyearsToMeters

func LightyearsToMeters(ly float64) *big.Rat

LightyearsToMeters convert lightyears to meters.

func MetersToLightyears

func MetersToLightyears(x *big.Rat) float64

MetersToLightyears converts meters to lightyears.

func PercentCToVelocity

func PercentCToVelocity(pct float64) *big.Rat

PercentCToVelocity computes the velocity in m/s from a percent of lightspeed.

func TimeString

func TimeString(dur time.Duration) string

TimeString prints out a time duration in a human-readable form. The Go stdlib version stops at seconds, but for printing clock drift, we'll need to go further.

func ToAstronomicalUnit

func ToAstronomicalUnit(x *big.Rat) *big.Rat

ToAstronomicalUnit converts a distance in meters to AU.

func VelocityToPercentC

func VelocityToPercentC(v *big.Rat) float64

VelocityToPercentC returns the percent lightspeed for a given velocity.

Types

type Clock

type Clock struct {
	Launch   time.Time
	Observer *clock.Mock
	Relative *clock.Mock
}

func Now

func Now() *Clock

Now returns a new Clock initialized to realtime now.

func (*Clock) Drift

func (c *Clock) Drift() time.Duration

func (*Clock) Sync

func (c *Clock) Sync()

Sync sets the observer clock to the system time.

func (*Clock) Update

func (c *Clock) Update(seconds float64, v *big.Rat)

type State

type State struct {
	X *big.Rat
	V *big.Rat
}

State tracks an object's velocity and position.

func (State) Accelerate

func (s State) Accelerate(a *big.Rat, seconds float64) State

Accelerate computes the state after an acceleration period.

func (State) Coast

func (s State) Coast(seconds float64) State

Coast computes the state after a period of coasting.

Jump to

Keyboard shortcuts

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