Lots of changes
This commit is contained in:
21
lib/Petzval/Calculations.hs
Normal file
21
lib/Petzval/Calculations.hs
Normal file
@@ -0,0 +1,21 @@
|
||||
module Petzval.Calculations where
|
||||
|
||||
import Control.Arrow
|
||||
import Data.Foldable
|
||||
import Linear
|
||||
|
||||
|
||||
|
||||
foldl1' fn (x:xs) = foldl' fn x xs
|
||||
|
||||
bimap2 :: (a -> b -> c) -> (a' -> b' -> c') -> (a,a') -> (b,b') -> (c,c')
|
||||
bimap2 af bf (a,b) (a',b') = (af a a', bf b b')
|
||||
|
||||
rmsSize' :: Floating a => V2 a -> [V2 a] -> a
|
||||
rmsSize' centroid = sqrt . uncurry (/) . foldl1' (bimap2 (+) (+)) . map (quadrance . (^-^ centroid) &&& (const 1))
|
||||
|
||||
rmsSize :: Floating a => [V2 a] -> a
|
||||
rmsSize = centroid >>= rmsSize'
|
||||
|
||||
centroid :: Fractional a => [V2 a] -> V2 a
|
||||
centroid = uncurry (^/) . foldl1' (bimap2 (^+^) (+)) . map (flip (,) 1)
|
||||
Reference in New Issue
Block a user