module Data.Geo.Jord.Ellipsoid
( Ellipsoid
, equatorialRadius
, polarRadius
, eccentricity
, flattening
, ellispoid
, sphere
, toSphere
, isSphere
, meanRadius
) where
import Data.Geo.Jord.Length
data Ellipsoid =
Ellipsoid
{ Ellipsoid -> Length
equatorialRadius :: !Length
, Ellipsoid -> Length
polarRadius :: !Length
, Ellipsoid -> Double
eccentricity :: !Double
, Ellipsoid -> Double
flattening :: !Double
}
deriving (Ellipsoid -> Ellipsoid -> Bool
(Ellipsoid -> Ellipsoid -> Bool)
-> (Ellipsoid -> Ellipsoid -> Bool) -> Eq Ellipsoid
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ellipsoid -> Ellipsoid -> Bool
$c/= :: Ellipsoid -> Ellipsoid -> Bool
== :: Ellipsoid -> Ellipsoid -> Bool
$c== :: Ellipsoid -> Ellipsoid -> Bool
Eq, Int -> Ellipsoid -> ShowS
[Ellipsoid] -> ShowS
Ellipsoid -> String
(Int -> Ellipsoid -> ShowS)
-> (Ellipsoid -> String)
-> ([Ellipsoid] -> ShowS)
-> Show Ellipsoid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ellipsoid] -> ShowS
$cshowList :: [Ellipsoid] -> ShowS
show :: Ellipsoid -> String
$cshow :: Ellipsoid -> String
showsPrec :: Int -> Ellipsoid -> ShowS
$cshowsPrec :: Int -> Ellipsoid -> ShowS
Show)
ellispoid :: Length -> Double -> Ellipsoid
ellispoid :: Length -> Double -> Ellipsoid
ellispoid Length
eqr Double
invf = Length -> Length -> Double -> Double -> Ellipsoid
Ellipsoid Length
eqr (Double -> Length
metres Double
b) Double
e Double
f
where
a :: Double
a = Length -> Double
toMetres Length
eqr
f :: Double
f = Double
1.0 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
invf
b :: Double
b = Double
a Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
1.0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
f)
e :: Double
e = Double -> Double
forall a. Floating a => a -> a
sqrt (Double
1.0 Double -> Double -> Double
forall a. Num a => a -> a -> a
- (Double
b Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
b) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Double
a Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
a))
sphere :: Length -> Ellipsoid
sphere :: Length -> Ellipsoid
sphere Length
r = Length -> Length -> Double -> Double -> Ellipsoid
Ellipsoid Length
r Length
r Double
0.0 Double
0.0
toSphere :: Ellipsoid -> Ellipsoid
toSphere :: Ellipsoid -> Ellipsoid
toSphere = Length -> Ellipsoid
sphere (Length -> Ellipsoid)
-> (Ellipsoid -> Length) -> Ellipsoid -> Ellipsoid
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ellipsoid -> Length
meanRadius
isSphere :: Ellipsoid -> Bool
isSphere :: Ellipsoid -> Bool
isSphere Ellipsoid
e = Ellipsoid -> Double
eccentricity Ellipsoid
e Double -> Double -> Bool
forall a. Eq a => a -> a -> Bool
== Double
0.0
meanRadius :: Ellipsoid -> Length
meanRadius :: Ellipsoid -> Length
meanRadius Ellipsoid
e = Double -> Length
metres ((Double
2.0 Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
a Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
b) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
3.0)
where
a :: Double
a = Length -> Double
toMetres (Length -> Double) -> (Ellipsoid -> Length) -> Ellipsoid -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ellipsoid -> Length
equatorialRadius (Ellipsoid -> Double) -> Ellipsoid -> Double
forall a b. (a -> b) -> a -> b
$ Ellipsoid
e
b :: Double
b = Length -> Double
toMetres (Length -> Double) -> (Ellipsoid -> Length) -> Ellipsoid -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ellipsoid -> Length
polarRadius (Ellipsoid -> Double) -> Ellipsoid -> Double
forall a b. (a -> b) -> a -> b
$ Ellipsoid
e