Created
August 12, 2012 00:17
-
-
Save hellertime/3328080 to your computer and use it in GitHub Desktop.
Basic angle types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Degree = Degree Float | |
newtype Radian = Radian Float | |
toRadian :: Degree -> Radian | |
toRadian deg = Radian $ (fromDegree deg) * (pi / 180) | |
fromRadian :: Radian -> Float | |
fromRadian (Radian x) = x | |
toDegree :: Radian -> Degree | |
toDegree rad = Degree $ (fromRadian rad) * (180 / pi) | |
fromDegree :: Degree -> Float | |
fromDegree (Degree x) = x | |
arclen :: Float -> Radian -> Float | |
arclen radius rad = (fromRadian rad / tau) * (tau / radius | |
where | |
tau = 2 * pi | |
sectorArea :: Float -> Radian -> Float | |
secrorArea radius rad = (fromRadian rad / tau) * (pi * $ radius ^ 2) | |
where | |
tau = 2 * pi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment