module Data.Astro.Coordinate
(
DecimalDegrees(..)
, DecimalHours(..)
, HorizonCoordinates(..)
, EquatorialCoordinates1(..)
, EquatorialCoordinates2(..)
, EclipticCoordinates(..)
, GalacticCoordinates(..)
, raToHA
, haToRA
, equatorialToHorizon
, horizonToEquatorial
, ec1ToHC
, hcToEC1
, ecHCConv
, obliquity
, eclipticToEquatorial
, equatorialToEcliptic
, galacticToEquatorial
, equatorialToGalactic
)
where
import Data.Astro.Time (utToLST)
import Data.Astro.Time.JulianDate (JulianDate(..), numberOfCenturies, splitToDayAndTime)
import Data.Astro.Time.Epoch (j2000)
import Data.Astro.Time.Sidereal (LocalSiderealTime(..), lstToDH)
import Data.Astro.Types (DecimalDegrees(..), DecimalHours(..)
, fromDecimalHours, toDecimalHours
, toRadians, fromRadians, fromDMS
, GeographicCoordinates(..))
import Data.Astro.Utils (fromFixed)
import Data.Astro.Effects.Nutation (nutationObliquity)
data HorizonCoordinates = HC {
HorizonCoordinates -> DecimalDegrees
hAltitude :: DecimalDegrees
, HorizonCoordinates -> DecimalDegrees
hAzimuth :: DecimalDegrees
} deriving (Int -> HorizonCoordinates -> ShowS
[HorizonCoordinates] -> ShowS
HorizonCoordinates -> String
(Int -> HorizonCoordinates -> ShowS)
-> (HorizonCoordinates -> String)
-> ([HorizonCoordinates] -> ShowS)
-> Show HorizonCoordinates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HorizonCoordinates] -> ShowS
$cshowList :: [HorizonCoordinates] -> ShowS
show :: HorizonCoordinates -> String
$cshow :: HorizonCoordinates -> String
showsPrec :: Int -> HorizonCoordinates -> ShowS
$cshowsPrec :: Int -> HorizonCoordinates -> ShowS
Show, HorizonCoordinates -> HorizonCoordinates -> Bool
(HorizonCoordinates -> HorizonCoordinates -> Bool)
-> (HorizonCoordinates -> HorizonCoordinates -> Bool)
-> Eq HorizonCoordinates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HorizonCoordinates -> HorizonCoordinates -> Bool
$c/= :: HorizonCoordinates -> HorizonCoordinates -> Bool
== :: HorizonCoordinates -> HorizonCoordinates -> Bool
$c== :: HorizonCoordinates -> HorizonCoordinates -> Bool
Eq)
data EquatorialCoordinates1 = EC1 {
EquatorialCoordinates1 -> DecimalDegrees
e1Declination :: DecimalDegrees
, EquatorialCoordinates1 -> DecimalHours
e1RightAscension :: DecimalHours
} deriving (Int -> EquatorialCoordinates1 -> ShowS
[EquatorialCoordinates1] -> ShowS
EquatorialCoordinates1 -> String
(Int -> EquatorialCoordinates1 -> ShowS)
-> (EquatorialCoordinates1 -> String)
-> ([EquatorialCoordinates1] -> ShowS)
-> Show EquatorialCoordinates1
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EquatorialCoordinates1] -> ShowS
$cshowList :: [EquatorialCoordinates1] -> ShowS
show :: EquatorialCoordinates1 -> String
$cshow :: EquatorialCoordinates1 -> String
showsPrec :: Int -> EquatorialCoordinates1 -> ShowS
$cshowsPrec :: Int -> EquatorialCoordinates1 -> ShowS
Show, EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool
(EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool)
-> (EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool)
-> Eq EquatorialCoordinates1
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool
$c/= :: EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool
== :: EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool
$c== :: EquatorialCoordinates1 -> EquatorialCoordinates1 -> Bool
Eq)
data EquatorialCoordinates2 = EC2 {
EquatorialCoordinates2 -> DecimalDegrees
e2Declination :: DecimalDegrees
, EquatorialCoordinates2 -> DecimalHours
e2HoursAngle :: DecimalHours
} deriving (Int -> EquatorialCoordinates2 -> ShowS
[EquatorialCoordinates2] -> ShowS
EquatorialCoordinates2 -> String
(Int -> EquatorialCoordinates2 -> ShowS)
-> (EquatorialCoordinates2 -> String)
-> ([EquatorialCoordinates2] -> ShowS)
-> Show EquatorialCoordinates2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EquatorialCoordinates2] -> ShowS
$cshowList :: [EquatorialCoordinates2] -> ShowS
show :: EquatorialCoordinates2 -> String
$cshow :: EquatorialCoordinates2 -> String
showsPrec :: Int -> EquatorialCoordinates2 -> ShowS
$cshowsPrec :: Int -> EquatorialCoordinates2 -> ShowS
Show, EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool
(EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool)
-> (EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool)
-> Eq EquatorialCoordinates2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool
$c/= :: EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool
== :: EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool
$c== :: EquatorialCoordinates2 -> EquatorialCoordinates2 -> Bool
Eq)
data EclipticCoordinates = EcC {
EclipticCoordinates -> DecimalDegrees
ecLatitude :: DecimalDegrees
, EclipticCoordinates -> DecimalDegrees
ecLongitude :: DecimalDegrees
} deriving (Int -> EclipticCoordinates -> ShowS
[EclipticCoordinates] -> ShowS
EclipticCoordinates -> String
(Int -> EclipticCoordinates -> ShowS)
-> (EclipticCoordinates -> String)
-> ([EclipticCoordinates] -> ShowS)
-> Show EclipticCoordinates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EclipticCoordinates] -> ShowS
$cshowList :: [EclipticCoordinates] -> ShowS
show :: EclipticCoordinates -> String
$cshow :: EclipticCoordinates -> String
showsPrec :: Int -> EclipticCoordinates -> ShowS
$cshowsPrec :: Int -> EclipticCoordinates -> ShowS
Show, EclipticCoordinates -> EclipticCoordinates -> Bool
(EclipticCoordinates -> EclipticCoordinates -> Bool)
-> (EclipticCoordinates -> EclipticCoordinates -> Bool)
-> Eq EclipticCoordinates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EclipticCoordinates -> EclipticCoordinates -> Bool
$c/= :: EclipticCoordinates -> EclipticCoordinates -> Bool
== :: EclipticCoordinates -> EclipticCoordinates -> Bool
$c== :: EclipticCoordinates -> EclipticCoordinates -> Bool
Eq)
data GalacticCoordinates = GC {
GalacticCoordinates -> DecimalDegrees
gLatitude :: DecimalDegrees
, GalacticCoordinates -> DecimalDegrees
gLongitude :: DecimalDegrees
} deriving (Int -> GalacticCoordinates -> ShowS
[GalacticCoordinates] -> ShowS
GalacticCoordinates -> String
(Int -> GalacticCoordinates -> ShowS)
-> (GalacticCoordinates -> String)
-> ([GalacticCoordinates] -> ShowS)
-> Show GalacticCoordinates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GalacticCoordinates] -> ShowS
$cshowList :: [GalacticCoordinates] -> ShowS
show :: GalacticCoordinates -> String
$cshow :: GalacticCoordinates -> String
showsPrec :: Int -> GalacticCoordinates -> ShowS
$cshowsPrec :: Int -> GalacticCoordinates -> ShowS
Show, GalacticCoordinates -> GalacticCoordinates -> Bool
(GalacticCoordinates -> GalacticCoordinates -> Bool)
-> (GalacticCoordinates -> GalacticCoordinates -> Bool)
-> Eq GalacticCoordinates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GalacticCoordinates -> GalacticCoordinates -> Bool
$c/= :: GalacticCoordinates -> GalacticCoordinates -> Bool
== :: GalacticCoordinates -> GalacticCoordinates -> Bool
$c== :: GalacticCoordinates -> GalacticCoordinates -> Bool
Eq)
raToHA :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
raToHA :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
raToHA = DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haRAConv
haToRA :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haToRA :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haToRA = DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haRAConv
haRAConv :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haRAConv :: DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haRAConv DecimalHours
dh DecimalDegrees
longitude JulianDate
ut =
let lst :: LocalSiderealTime
lst = DecimalDegrees -> JulianDate -> LocalSiderealTime
utToLST DecimalDegrees
longitude JulianDate
ut
DH Double
hourAngle = (LocalSiderealTime -> DecimalHours
lstToDH LocalSiderealTime
lst) DecimalHours -> DecimalHours -> DecimalHours
forall a. Num a => a -> a -> a
- DecimalHours
dh
in if Double
hourAngle Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
0 then (Double -> DecimalHours
DH (Double -> DecimalHours) -> Double -> DecimalHours
forall a b. (a -> b) -> a -> b
$ Double
hourAngleDouble -> Double -> Double
forall a. Num a => a -> a -> a
+Double
24) else (Double -> DecimalHours
DH Double
hourAngle)
equatorialToHorizon :: DecimalDegrees -> EquatorialCoordinates2 -> HorizonCoordinates
equatorialToHorizon :: DecimalDegrees -> EquatorialCoordinates2 -> HorizonCoordinates
equatorialToHorizon DecimalDegrees
latitude (EC2 DecimalDegrees
dec DecimalHours
hourAngle) =
let hourAngle' :: DecimalDegrees
hourAngle' = DecimalHours -> DecimalDegrees
fromDecimalHours DecimalHours
hourAngle
(DecimalDegrees
altitude, DecimalDegrees
azimuth) = DecimalDegrees
-> (DecimalDegrees, DecimalDegrees)
-> (DecimalDegrees, DecimalDegrees)
ecHCConv DecimalDegrees
latitude (DecimalDegrees
dec, DecimalDegrees
hourAngle')
in DecimalDegrees -> DecimalDegrees -> HorizonCoordinates
HC DecimalDegrees
altitude DecimalDegrees
azimuth
horizonToEquatorial :: DecimalDegrees -> HorizonCoordinates -> EquatorialCoordinates2
horizonToEquatorial :: DecimalDegrees -> HorizonCoordinates -> EquatorialCoordinates2
horizonToEquatorial DecimalDegrees
latitude (HC DecimalDegrees
altitude DecimalDegrees
azimuth) =
let (DecimalDegrees
dec, DecimalDegrees
hourAngle) = DecimalDegrees
-> (DecimalDegrees, DecimalDegrees)
-> (DecimalDegrees, DecimalDegrees)
ecHCConv DecimalDegrees
latitude (DecimalDegrees
altitude, DecimalDegrees
azimuth)
in DecimalDegrees -> DecimalHours -> EquatorialCoordinates2
EC2 DecimalDegrees
dec (DecimalHours -> EquatorialCoordinates2)
-> DecimalHours -> EquatorialCoordinates2
forall a b. (a -> b) -> a -> b
$ DecimalDegrees -> DecimalHours
toDecimalHours DecimalDegrees
hourAngle
ec1ToHC :: GeographicCoordinates -> JulianDate -> EquatorialCoordinates1 -> HorizonCoordinates
ec1ToHC :: GeographicCoordinates
-> JulianDate -> EquatorialCoordinates1 -> HorizonCoordinates
ec1ToHC (GeoC DecimalDegrees
latitude DecimalDegrees
longitude) JulianDate
jd (EC1 DecimalDegrees
delta DecimalHours
alpha) =
let ec2 :: EquatorialCoordinates2
ec2 = DecimalDegrees -> DecimalHours -> EquatorialCoordinates2
EC2 DecimalDegrees
delta (DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
raToHA DecimalHours
alpha DecimalDegrees
longitude JulianDate
jd)
in DecimalDegrees -> EquatorialCoordinates2 -> HorizonCoordinates
equatorialToHorizon DecimalDegrees
latitude EquatorialCoordinates2
ec2
hcToEC1 :: GeographicCoordinates -> JulianDate -> HorizonCoordinates -> EquatorialCoordinates1
hcToEC1 :: GeographicCoordinates
-> JulianDate -> HorizonCoordinates -> EquatorialCoordinates1
hcToEC1 (GeoC DecimalDegrees
latitude DecimalDegrees
longitude) JulianDate
jd HorizonCoordinates
hc =
let (EC2 DecimalDegrees
dec DecimalHours
hourAngle) = DecimalDegrees -> HorizonCoordinates -> EquatorialCoordinates2
horizonToEquatorial DecimalDegrees
latitude HorizonCoordinates
hc
in DecimalDegrees -> DecimalHours -> EquatorialCoordinates1
EC1 DecimalDegrees
dec (DecimalHours -> DecimalDegrees -> JulianDate -> DecimalHours
haToRA DecimalHours
hourAngle DecimalDegrees
longitude JulianDate
jd)
ecHCConv :: DecimalDegrees -> (DecimalDegrees, DecimalDegrees) -> (DecimalDegrees, DecimalDegrees)
ecHCConv :: DecimalDegrees
-> (DecimalDegrees, DecimalDegrees)
-> (DecimalDegrees, DecimalDegrees)
ecHCConv DecimalDegrees
latitude (DecimalDegrees
up, DecimalDegrees
round) =
let latitude' :: Double
latitude' = DecimalDegrees -> Double
toRadians DecimalDegrees
latitude
up' :: Double
up' = DecimalDegrees -> Double
toRadians DecimalDegrees
up
round' :: Double
round' = DecimalDegrees -> Double
toRadians DecimalDegrees
round
sinUpResult :: Double
sinUpResult = (Double -> Double
forall a. Floating a => a -> a
sin Double
up')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
latitude') Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double -> Double
forall a. Floating a => a -> a
cos Double
up')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
latitude')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
round')
upResult :: Double
upResult = Double -> Double
forall a. Floating a => a -> a
asin Double
sinUpResult
roundResult :: Double
roundResult = Double -> Double
forall a. Floating a => a -> a
acos (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ ((Double -> Double
forall a. Floating a => a -> a
sin Double
up') Double -> Double -> Double
forall a. Num a => a -> a -> a
- (Double -> Double
forall a. Floating a => a -> a
sin Double
latitude')Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
sinUpResult) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ ((Double -> Double
forall a. Floating a => a -> a
cos Double
latitude') Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double -> Double
forall a. Floating a => a -> a
cos Double
upResult))
roundResult' :: Double
roundResult' = if (Double -> Double
forall a. Floating a => a -> a
sin Double
round') Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
0 then Double
roundResult else (Double
2Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
forall a. Floating a => a
pi Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
roundResult)
in ((Double -> DecimalDegrees
fromRadians Double
upResult), (Double -> DecimalDegrees
fromRadians Double
roundResult'))
obliquity :: JulianDate -> DecimalDegrees
obliquity :: JulianDate -> DecimalDegrees
obliquity JulianDate
jd =
let DD Double
baseObliquity = Int -> Int -> Double -> DecimalDegrees
forall a. RealFrac a => Int -> Int -> a -> DecimalDegrees
fromDMS Int
23 Int
26 Double
21.45
t :: Double
t = JulianDate -> JulianDate -> Double
numberOfCenturies JulianDate
j2000 JulianDate
jd
de :: Double
de = (Double
46.815Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
0.0006Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
tDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
0.00181Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
tDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
tDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
t) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
3600
in (Double -> DecimalDegrees
DD (Double -> DecimalDegrees) -> Double -> DecimalDegrees
forall a b. (a -> b) -> a -> b
$ Double
baseObliquity Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
de) DecimalDegrees -> DecimalDegrees -> DecimalDegrees
forall a. Num a => a -> a -> a
+ (JulianDate -> DecimalDegrees
nutationObliquity JulianDate
jd)
eclipticToEquatorial :: EclipticCoordinates -> JulianDate -> EquatorialCoordinates1
eclipticToEquatorial :: EclipticCoordinates -> JulianDate -> EquatorialCoordinates1
eclipticToEquatorial (EcC DecimalDegrees
beta DecimalDegrees
gamma) JulianDate
jd =
let epsilon' :: Double
epsilon' = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ JulianDate -> DecimalDegrees
obliquity JulianDate
jd
beta' :: Double
beta' = DecimalDegrees -> Double
toRadians DecimalDegrees
beta
gamma' :: Double
gamma' = DecimalDegrees -> Double
toRadians DecimalDegrees
gamma
delta :: Double
delta = Double -> Double
forall a. Floating a => a -> a
asin (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ (Double -> Double
forall a. Floating a => a -> a
sin Double
beta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
epsilon') Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double -> Double
forall a. Floating a => a -> a
cos Double
beta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
epsilon')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
gamma')
y :: Double
y = (Double -> Double
forall a. Floating a => a -> a
sin Double
gamma')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
epsilon') Double -> Double -> Double
forall a. Num a => a -> a -> a
- (Double -> Double
forall a. Floating a => a -> a
tan Double
beta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
epsilon')
x :: Double
x = Double -> Double
forall a. Floating a => a -> a
cos Double
gamma'
alpha :: Double
alpha = Double -> Double
forall a. (Floating a, Ord a) => a -> a
reduceToZero2PI (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall a. RealFloat a => a -> a -> a
atan2 Double
y Double
x
in DecimalDegrees -> DecimalHours -> EquatorialCoordinates1
EC1 (Double -> DecimalDegrees
fromRadians Double
delta) (DecimalDegrees -> DecimalHours
toDecimalHours (DecimalDegrees -> DecimalHours) -> DecimalDegrees -> DecimalHours
forall a b. (a -> b) -> a -> b
$ Double -> DecimalDegrees
fromRadians Double
alpha)
equatorialToEcliptic :: EquatorialCoordinates1 -> JulianDate -> EclipticCoordinates
equatorialToEcliptic :: EquatorialCoordinates1 -> JulianDate -> EclipticCoordinates
equatorialToEcliptic (EC1 DecimalDegrees
delta DecimalHours
alpha) JulianDate
jd =
let epsilon' :: Double
epsilon' = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ JulianDate -> DecimalDegrees
obliquity JulianDate
jd
delta' :: Double
delta' = DecimalDegrees -> Double
toRadians DecimalDegrees
delta
alpha' :: Double
alpha' = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ DecimalHours -> DecimalDegrees
fromDecimalHours DecimalHours
alpha
beta :: Double
beta = Double -> Double
forall a. Floating a => a -> a
asin (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ (Double -> Double
forall a. Floating a => a -> a
sin Double
delta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
epsilon') Double -> Double -> Double
forall a. Num a => a -> a -> a
- (Double -> Double
forall a. Floating a => a -> a
cos Double
delta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
epsilon')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
alpha')
y :: Double
y = (Double -> Double
forall a. Floating a => a -> a
sin Double
alpha')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
epsilon') Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double -> Double
forall a. Floating a => a -> a
tan Double
delta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
epsilon')
x :: Double
x = Double -> Double
forall a. Floating a => a -> a
cos Double
alpha'
gamma :: Double
gamma = Double -> Double
forall a. (Floating a, Ord a) => a -> a
reduceToZero2PI (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ Double -> Double -> Double
forall a. RealFloat a => a -> a -> a
atan2 Double
y Double
x
in DecimalDegrees -> DecimalDegrees -> EclipticCoordinates
EcC (Double -> DecimalDegrees
fromRadians Double
beta) (Double -> DecimalDegrees
fromRadians Double
gamma)
galacticPole :: EquatorialCoordinates1
galacticPole :: EquatorialCoordinates1
galacticPole = DecimalDegrees -> DecimalHours -> EquatorialCoordinates1
EC1 (Double -> DecimalDegrees
DD Double
27.4) (DecimalDegrees -> DecimalHours
toDecimalHours (DecimalDegrees -> DecimalHours) -> DecimalDegrees -> DecimalHours
forall a b. (a -> b) -> a -> b
$ Double -> DecimalDegrees
DD Double
192.25)
galacticPoleInRadians :: (Double, Double)
galacticPoleInRadians = (Double
delta, Double
alpha)
where delta :: Double
delta = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ EquatorialCoordinates1 -> DecimalDegrees
e1Declination EquatorialCoordinates1
galacticPole
alpha :: Double
alpha = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ DecimalHours -> DecimalDegrees
fromDecimalHours (DecimalHours -> DecimalDegrees) -> DecimalHours -> DecimalDegrees
forall a b. (a -> b) -> a -> b
$ EquatorialCoordinates1 -> DecimalHours
e1RightAscension EquatorialCoordinates1
galacticPole
ascendingNode :: DecimalDegrees
ascendingNode :: DecimalDegrees
ascendingNode = Double -> DecimalDegrees
DD Double
33
galacticToEquatorial :: GalacticCoordinates -> EquatorialCoordinates1
galacticToEquatorial :: GalacticCoordinates -> EquatorialCoordinates1
galacticToEquatorial (GC DecimalDegrees
b DecimalDegrees
l) =
let b' :: Double
b' = DecimalDegrees -> Double
toRadians DecimalDegrees
b
l' :: Double
l' = DecimalDegrees -> Double
toRadians DecimalDegrees
l
(Double
poleDelta, Double
poleAlpha) = (Double, Double)
galacticPoleInRadians
an :: Double
an = DecimalDegrees -> Double
toRadians DecimalDegrees
ascendingNode
delta :: Double
delta = Double -> Double
forall a. Floating a => a -> a
asin (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ (Double -> Double
forall a. Floating a => a -> a
cos Double
b')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
poleDelta)Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin (Double
l'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
an)) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double -> Double
forall a. Floating a => a -> a
sin Double
b')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
poleDelta)
y :: Double
y = (Double -> Double
forall a. Floating a => a -> a
cos Double
b')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos (Double
l'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
an))
x :: Double
x = (Double -> Double
forall a. Floating a => a -> a
sin Double
b')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
poleDelta) Double -> Double -> Double
forall a. Num a => a -> a -> a
- (Double -> Double
forall a. Floating a => a -> a
cos Double
b')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
poleDelta)Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin (Double
l'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
an))
alpha :: Double
alpha = Double -> Double
forall a. (Floating a, Ord a) => a -> a
reduceToZero2PI (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ (Double -> Double -> Double
forall a. RealFloat a => a -> a -> a
atan2 Double
y Double
x) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
poleAlpha
in DecimalDegrees -> DecimalHours -> EquatorialCoordinates1
EC1 (Double -> DecimalDegrees
fromRadians Double
delta) (DecimalDegrees -> DecimalHours
toDecimalHours (DecimalDegrees -> DecimalHours) -> DecimalDegrees -> DecimalHours
forall a b. (a -> b) -> a -> b
$ Double -> DecimalDegrees
fromRadians Double
alpha)
equatorialToGalactic :: EquatorialCoordinates1 -> GalacticCoordinates
equatorialToGalactic :: EquatorialCoordinates1 -> GalacticCoordinates
equatorialToGalactic (EC1 DecimalDegrees
delta DecimalHours
alpha) =
let delta' :: Double
delta' = DecimalDegrees -> Double
toRadians DecimalDegrees
delta
alpha' :: Double
alpha' = DecimalDegrees -> Double
toRadians (DecimalDegrees -> Double) -> DecimalDegrees -> Double
forall a b. (a -> b) -> a -> b
$ DecimalHours -> DecimalDegrees
fromDecimalHours DecimalHours
alpha
(Double
poleDelta, Double
poleAlpha) = (Double, Double)
galacticPoleInRadians
sinb :: Double
sinb = (Double -> Double
forall a. Floating a => a -> a
cos Double
delta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
poleDelta)Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos (Double
alpha'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
poleAlpha)) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (Double -> Double
forall a. Floating a => a -> a
sin Double
delta') Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double -> Double
forall a. Floating a => a -> a
sin Double
poleDelta)
y :: Double
y = (Double -> Double
forall a. Floating a => a -> a
sin Double
delta') Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
sinbDouble -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin Double
poleDelta)
x :: Double
x = (Double -> Double
forall a. Floating a => a -> a
cos Double
delta')Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
sin (Double
alpha'Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
poleAlpha))Double -> Double -> Double
forall a. Num a => a -> a -> a
*(Double -> Double
forall a. Floating a => a -> a
cos Double
poleDelta)
b :: Double
b = Double -> Double
forall a. Floating a => a -> a
asin Double
sinb
l :: Double
l = Double -> Double
forall a. (Floating a, Ord a) => a -> a
reduceToZero2PI (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ (Double -> Double -> Double
forall a. RealFloat a => a -> a -> a
atan2 Double
y Double
x) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ (DecimalDegrees -> Double
toRadians DecimalDegrees
ascendingNode)
in DecimalDegrees -> DecimalDegrees -> GalacticCoordinates
GC (Double -> DecimalDegrees
fromRadians Double
b) (Double -> DecimalDegrees
fromRadians Double
l)
reduceToZero2PI :: (Floating a, Ord a) => a -> a
reduceToZero2PI :: a -> a
reduceToZero2PI a
rad = if a
rad a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0 then a
rad a -> a -> a
forall a. Num a => a -> a -> a
+ a
2a -> a -> a
forall a. Num a => a -> a -> a
*a
forall a. Floating a => a
pi else a
rad