Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions for dealing with Kepler orbits.
Synopsis
- data Orbit a = Orbit {
- eccentricity :: !(Unitless a)
- periapsis :: !(Distance a)
- inclinationSpecifier :: !(InclinationSpecifier a)
- periapsisSpecifier :: !(PeriapsisSpecifier a)
- primaryGravitationalParameter :: !(Quantity ((:*) ((:^) Meter (Succ (Succ (Succ Zero)))) ((:^) Second (Pred (Pred Zero)))) a)
- data InclinationSpecifier a
- = Inclined {
- longitudeOfAscendingNode :: !(Angle a)
- inclination :: !(Angle a)
- | NonInclined
- = Inclined {
- data PeriapsisSpecifier a
- = Eccentric {
- argumentOfPeriapsis :: !(Angle a)
- | Circular
- = Eccentric {
- data Classification
- isValid :: (Ord a, Num a) => Orbit a -> Bool
- classify :: (Num a, Ord a) => Orbit a -> Classification
- apoapsis :: (Fractional a, Ord a) => Orbit a -> Maybe (Distance a)
- meanMotion :: (Floating a, Ord a) => Orbit a -> Quantity ((:/) Radian Second) a
- period :: (Floating a, Ord a) => Orbit a -> Maybe (Time a)
- arealVelocity :: (Ord a, Floating a) => Orbit a -> Quantity ((:/) ((:^) Meter (Succ (Succ Zero))) Second) a
- semiMajorAxis :: (Fractional a, Ord a) => Orbit a -> Maybe (Distance a)
- semiMinorAxis :: (Floating a, Ord a) => Orbit a -> Distance a
- semiLatusRectum :: Num a => Orbit a -> Distance a
- hyperbolicApproachAngle :: (Floating a, Ord a) => Orbit a -> Maybe (Angle a)
- hyperbolicDepartureAngle :: (Floating a, Ord a) => Orbit a -> Maybe (Angle a)
- timeAtMeanAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Time a
- timeAtEccentricAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Maybe (Time a)
- timeAtTrueAnomaly :: (Real a, Floating a) => Orbit a -> Angle a -> Maybe (Time a)
- meanAnomalyAtTime :: (Floating a, Ord a) => Orbit a -> Time a -> Angle a
- meanAnomalyAtEccentricAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Maybe (Angle a)
- meanAnomalyAtTrueAnomaly :: (Real a, Floating a) => Orbit a -> Angle a -> Maybe (Angle a)
- eccentricAnomalyAtTime :: (Converge [a], Floating a, Real a) => Orbit a -> Time a -> Maybe (Angle a)
- eccentricAnomalyAtMeanAnomaly :: forall a. (Converge [a], Floating a, Real a) => Orbit a -> Angle a -> Maybe (Angle a)
- eccentricAnomalyAtMeanAnomalyFloat :: Orbit Float -> Angle Float -> Maybe (Angle Float)
- eccentricAnomalyAtTrueAnomaly :: (Floating a, Real a) => Orbit a -> Angle a -> Maybe (Angle a)
- trueAnomalyAtTime :: (Converge [a], RealFloat a) => Orbit a -> Time a -> Maybe (Angle a)
- trueAnomalyAtMeanAnomaly :: (Converge [a], RealFloat a) => Orbit a -> Angle a -> Maybe (Angle a)
- trueAnomalyAtEccentricAnomaly :: RealFloat a => Orbit a -> Angle a -> Maybe (Angle a)
- type Time = Quantity Second
- type Distance = Quantity Meter
- type Speed = Quantity ((:*) Meter ((:^) Second (Pred Zero)))
- type Mass = Quantity ((:@) Kilo Gram)
- type Angle = Quantity Radian
- type Unitless = Quantity Number
- class Converge a
The Orbit data type and dependencies
Data type defining an orbit parameterized by the type used to represent values
Orbit | |
|
data InclinationSpecifier a Source #
Along with PeriapsisSpecifier
the InclinationSpecifier
describes
orbital elements extra to its geometry.
Inclined | The orbit does not lie exactly in the reference plane |
| |
NonInclined | The orbit lies in the reference plane |
Instances
Eq a => Eq (InclinationSpecifier a) Source # | |
Defined in Physics.Orbit (==) :: InclinationSpecifier a -> InclinationSpecifier a -> Bool # (/=) :: InclinationSpecifier a -> InclinationSpecifier a -> Bool # | |
Show a => Show (InclinationSpecifier a) Source # | |
Defined in Physics.Orbit showsPrec :: Int -> InclinationSpecifier a -> ShowS # show :: InclinationSpecifier a -> String # showList :: [InclinationSpecifier a] -> ShowS # |
data PeriapsisSpecifier a Source #
Along with InclinationSpecifier
the PeriapsisSpecifier
describes
orbital elements extra to its geometry.
Eccentric | The orbit is not circular |
| |
Circular | The orbit has an eccentricity of 0 so the
|
Instances
Eq a => Eq (PeriapsisSpecifier a) Source # | |
Defined in Physics.Orbit (==) :: PeriapsisSpecifier a -> PeriapsisSpecifier a -> Bool # (/=) :: PeriapsisSpecifier a -> PeriapsisSpecifier a -> Bool # | |
Show a => Show (PeriapsisSpecifier a) Source # | |
Defined in Physics.Orbit showsPrec :: Int -> PeriapsisSpecifier a -> ShowS # show :: PeriapsisSpecifier a -> String # showList :: [PeriapsisSpecifier a] -> ShowS # |
data Classification Source #
What for the orbit's geometry takes. This is dependant only on the
eccentricity
, e >= 0, of the orbit.
Elliptic | 0 <= e < 1 This includes circular orbits. |
Parabolic | e == 1 |
Hyperbolic | e > 1 |
Instances
Eq Classification Source # | |
Defined in Physics.Orbit (==) :: Classification -> Classification -> Bool # (/=) :: Classification -> Classification -> Bool # | |
Read Classification Source # | |
Defined in Physics.Orbit readsPrec :: Int -> ReadS Classification # readList :: ReadS [Classification] # | |
Show Classification Source # | |
Defined in Physics.Orbit showsPrec :: Int -> Classification -> ShowS # show :: Classification -> String # showList :: [Classification] -> ShowS # |
Functions for dealing with orbits
Utilities
isValid :: (Ord a, Num a) => Orbit a -> Bool Source #
Return true is the orbit is valid and false if it is invalid. The behavior of all the other functions in this module is undefined when given an invalid orbit.
classify :: (Num a, Ord a) => Orbit a -> Classification Source #
classify
is a funciton which returns the orbit's class.
Orbital elements
meanMotion :: (Floating a, Ord a) => Orbit a -> Quantity ((:/) Radian Second) a Source #
Calculate the mean motion, n, of an orbit
This is the rate of change of the mean anomaly with respect to time.
period :: (Floating a, Ord a) => Orbit a -> Maybe (Time a) Source #
Calculate the orbital period, p, of an elliptic orbit.
period
returns Nothing if given a parabolic or hyperbolic orbit.
arealVelocity :: (Ord a, Floating a) => Orbit a -> Quantity ((:/) ((:^) Meter (Succ (Succ Zero))) Second) a Source #
Calculate the areal velocity, A, of the orbit.
The areal velocity is the area swept out by the line between the orbiting body and the primary per second.
Geometry
semiMajorAxis :: (Fractional a, Ord a) => Orbit a -> Maybe (Distance a) Source #
semiMinorAxis :: (Floating a, Ord a) => Orbit a -> Distance a Source #
Calculate the semi-minor axis, b, of the Orbit
. Like semiMajorAxis
'semiMinorAxis' o
is negative when o
is a hyperbolic orbit. In the
case of a parabolic orbit semiMinorAxis
returns 0m.
semiLatusRectum :: Num a => Orbit a -> Distance a Source #
Calculate the semiLatusRectum, l, of the Orbit
hyperbolicApproachAngle :: (Floating a, Ord a) => Orbit a -> Maybe (Angle a) Source #
Calculate the angle at which a body leaves the system when on a hyperbolic trajectory relative to the argument of periapsis. This is the limit of the true anomaly as time tends towards -infinity minus the argument of periapsis. The approach angle is in the closed range (-π..π/2).
This is the negation of the departure angle.
hyperbolicApproachAngle
returns Nothing when given a non-hyperbolic orbit
and -π when given a parabolic orbit.
hyperbolicDepartureAngle :: (Floating a, Ord a) => Orbit a -> Maybe (Angle a) Source #
Calculate the angle at which a body leaves the system when on an escape trajectory relative to the argument of periapsis. This is the limit of the true anomaly as time tends towards infinity minus the argument of periapsis. The departure angle is in the closed range (π/2..π).
This is the negation of the approach angle.
hyperbolicDepartureAngle
returns Nothing when given an elliptic orbit and
π when given a parabolic orbit.
Conversions
To time since periapse
timeAtMeanAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Time a Source #
Calculate the time since periapse, t, when the body has the given mean anomaly, M. M may be negative, indicating that the orbiting body has yet to reach periapse.
The sign of the time at mean anomaly M is the same as the sign of M.
The returned time is unbounded.
timeAtEccentricAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Maybe (Time a) Source #
Calculate the time since periapse, t, of an elliptic orbit when at eccentric anomaly E.
timeAtEccentricAnomaly
returns Nothing if given a parabolic or hyperbolic
orbit.
timeAtTrueAnomaly :: (Real a, Floating a) => Orbit a -> Angle a -> Maybe (Time a) Source #
Calculate the time since periapse given the true anomaly, ν, of an orbiting body.
To mean anomaly
meanAnomalyAtTime :: (Floating a, Ord a) => Orbit a -> Time a -> Angle a Source #
Calculate the mean anomaly, M, at the given time since periapse, t. t may be negative, indicating that the orbiting body has yet to reach periapse.
The sign of the mean anomaly at time t is the same as the sign of t.
The returned mean anomaly is unbounded.
meanAnomalyAtEccentricAnomaly :: (Floating a, Ord a) => Orbit a -> Angle a -> Maybe (Angle a) Source #
Calculate the mean anomaly, M, of an elliptic orbit when at eccentric anomaly E
meanAnomalyAtEccentricAnomaly
returns Nothing if given a parabolic or
hyperbolic orbit.
The number of orbits represented by the anomalies is preserved;
i.e. M div
2π = E div
2π
To eccentric anomaly
eccentricAnomalyAtTime :: (Converge [a], Floating a, Real a) => Orbit a -> Time a -> Maybe (Angle a) Source #
Calculate the eccentric anomaly, E, of an elliptic orbit at time t.
eccentricAnomalyAtTime
returns Nothing when given a parabolic or
hyperbolic orbit.
The number of orbits represented by the time is preserved;
i.e. t div
p = E div
2π
eccentricAnomalyAtMeanAnomaly :: forall a. (Converge [a], Floating a, Real a) => Orbit a -> Angle a -> Maybe (Angle a) Source #
Calculate the eccentric anomaly, E, of an elliptic orbit when at mean anomaly M. This function is considerably slower than most other conversion functions as it uses an iterative method as no closed form solution exists.
The number of orbits represented by the anomalies is preserved;
i.e. M div
2π = E div
2π
eccentricAnomalyAtMeanAnomaly
returns Nothing when given a parabolic or
hyperbolic orbit.
eccentricAnomalyAtMeanAnomalyFloat :: Orbit Float -> Angle Float -> Maybe (Angle Float) Source #
eccentricAnomalyAtMeanAnomaly
specialized to Float
.
This function is used to calculate the initial guess for
eccentricAnomalyAtMeanAnomaly
.
eccentricAnomalyAtTrueAnomaly :: (Floating a, Real a) => Orbit a -> Angle a -> Maybe (Angle a) Source #
To true anomaly
trueAnomalyAtTime :: (Converge [a], RealFloat a) => Orbit a -> Time a -> Maybe (Angle a) Source #
Calculate the true anomaly, ν, of a body at time since periapse, t.
trueAnomalyAtMeanAnomaly :: (Converge [a], RealFloat a) => Orbit a -> Angle a -> Maybe (Angle a) Source #
Calculate the true anomaly, ν, of an orbiting body when it has the given mean anomaly, _M.
Unit synonyms
type Speed = Quantity ((:*) Meter ((:^) Second (Pred Zero))) Source #
A measure in meters per second.
Reexported from CReal
If a type is an instance of Converge then it represents a stream of values which are increasingly accurate approximations of a desired value
Instances
Eq a => Converge [a] | Every list of equatable values is an instance of |
Converge [CReal n] | The overlapping instance for It's important to note when the error function reaches zero this function
behaves like Find where log x = π using Newton's method
|