module Data.Angle where
newtype Radians x = Radians x deriving (Eq, Ord, Show, Num, Fractional)
newtype Degrees x = Degrees x deriving (Eq, Ord, Show, Num, Fractional)
degrees :: (Floating x) => Radians x -> Degrees x
degrees (Radians x) = Degrees (x/pi*180)
radians :: (Floating x) => Degrees x -> Radians x
radians (Degrees x) = Radians (x/180*pi)
class Angle a where
sine :: (Floating x) => a x -> x
cosine :: (Floating x) => a x -> x
tangent :: (Floating x) => a x -> x
arcsine :: (Floating x) => x -> a x
arccosine :: (Floating x) => x -> a x
arctangent :: (Floating x) => x -> a x
instance Angle Radians where
sine (Radians x) = sin x
cosine (Radians x) = cos x
tangent (Radians x) = tan x
arcsine x = Radians (asin x)
arccosine x = Radians (acos x)
arctangent x = Radians (atan x)
instance Angle Degrees where
sine = sine . radians
cosine = cosine . radians
tangent = tangent . radians
arcsine = degrees . arcsine
arccosine = degrees . arccosine
arctangent = degrees . arctangent