Commit 6ab527db by Ben Gamari 🐢

### real/fulsom: Detabify

parent 364be2cc
 ... @@ -195,19 +195,19 @@ calc (Geom a (RotZ rad)) rgb xyz ... @@ -195,19 +195,19 @@ calc (Geom a (RotZ rad)) rgb xyz -- conflate matrices together and into planes planes... -- conflate matrices together and into planes planes... reduceM (Object X) mata reduceM (Object X) mata = case (mat1x4 (1,0,0,0) mata) of = case (mat1x4 (1,0,0,0) mata) of (x,y,z,w) -> (Object (Plane x y z w),True) (x,y,z,w) -> (Object (Plane x y z w),True) reduceM (Object Y) mata reduceM (Object Y) mata = case (mat1x4 (0,1,0,0) mata) of = case (mat1x4 (0,1,0,0) mata) of (x,y,z,w) -> (Object (Plane x y z w),True) (x,y,z,w) -> (Object (Plane x y z w),True) reduceM (Object Z) mata reduceM (Object Z) mata = case (mat1x4 (0,0,1,0) mata) of = case (mat1x4 (0,0,1,0) mata) of (x,y,z,w) -> (Object (Plane x y z w),True) (x,y,z,w) -> (Object (Plane x y z w),True) reduceM (Object (Plane a b c d)) mata reduceM (Object (Plane a b c d)) mata = case (mat1x4 (a,b,c,d) mata) of = case (mat1x4 (a,b,c,d) mata) of (x,y,z,w) -> (Object (Plane x y z w),True) (x,y,z,w) -> (Object (Plane x y z w),True) reduceM (Matrix b matb) mata reduceM (Matrix b matb) mata = case (mat4x4 mata matb) of = case (mat4x4 mata matb) of matc -> (Matrix b matc,True) matc -> (Matrix b matc,True) reduceM _ _ = (no,False) reduceM _ _ = (no,False) ... ...
 ... @@ -18,10 +18,10 @@ ... @@ -18,10 +18,10 @@ -} -} module Interval(Interval, (#), pt, sqr, module Interval(Interval, (#), pt, sqr, tophalf, bothalf, topbit, tophalf, bothalf, topbit, lo, hi, mid1, mid2, lo, hi, mid1, mid2, up,down,unpt) up,down,unpt) where where infix 4 #,:#: infix 4 #,:#: ... @@ -46,36 +46,36 @@ instance (Ord a) => Ord (Interval a) where ... @@ -46,36 +46,36 @@ instance (Ord a) => Ord (Interval a) where instance (Num a, Ord a, Eq a, Show a) => Num (Interval a) where instance (Num a, Ord a, Eq a, Show a) => Num (Interval a) where (+) = ivPlus (+) = ivPlus (*) = ivMult (*) = ivMult negate = ivNegate negate = ivNegate abs = ivAbs abs = ivAbs signum = ivSignum signum = ivSignum fromInteger = ivFromInteger fromInteger = ivFromInteger instance (Show a, Num a, Ord a, Fractional a) => Fractional (Interval a) where instance (Show a, Num a, Ord a, Fractional a) => Fractional (Interval a) where (/) = ivDiv (/) = ivDiv fromRational = ivFromRational fromRational = ivFromRational instance (Show a, RealFloat a) => Floating (Interval a) where instance (Show a, RealFloat a) => Floating (Interval a) where pi = Pt pi pi = Pt pi exp = ivExp exp = ivExp log = ivLog log = ivLog sqrt = ivSqrt sqrt = ivSqrt (**) = ivPower (**) = ivPower sin = ivSin sin = ivSin cos = ivCos cos = ivCos tan = ivTan tan = ivTan asin = ivAsin asin = ivAsin acos = ivAcos acos = ivAcos atan = ivAtan atan = ivAtan sinh = ivSinh sinh = ivSinh cosh = ivCosh cosh = ivCosh tanh = ivTanh tanh = ivTanh asinh = ivAsinh asinh = ivAsinh acosh = ivAcosh acosh = ivAcosh atanh = ivAtanh atanh = ivAtanh -- Error functions - un-used. -- Error functions - un-used. ... @@ -139,35 +139,35 @@ ivNegate (a :#: b) = negate b :#: negate a ... @@ -139,35 +139,35 @@ ivNegate (a :#: b) = negate b :#: negate a ivMult (Pt a) (Pt c) = Pt (a*c) ivMult (Pt a) (Pt c) = Pt (a*c) ivMult (a :#: b) (c :#: d) | (min a c) > 0 = a*c :#: b*d ivMult (a :#: b) (c :#: d) | (min a c) > 0 = a*c :#: b*d | (max b d) < 0 = b*d :#: a*c | (max b d) < 0 = b*d :#: a*c | otherwise = minmax [e,f,g,h] | otherwise = minmax [e,f,g,h] where where e = b * c e = b * c f = a * d f = a * d g = a * c g = a * c h = b * d h = b * d ivMult (Pt a) (c :#: d) | a > 0 = a*c :#: a*d ivMult (Pt a) (c :#: d) | a > 0 = a*c :#: a*d | a < 0 = a*d :#: a*c | a < 0 = a*d :#: a*c | otherwise = (Pt 0) | otherwise = (Pt 0) ivMult (c :#: d) (Pt a) | a > 0 = a*c :#: a*d ivMult (c :#: d) (Pt a) | a > 0 = a*c :#: a*d | a < 0 = a*d :#: a*c | a < 0 = a*d :#: a*c | otherwise = (Pt 0) | otherwise = (Pt 0) -- minmax finds the lowest, and highest in a list - used for mult. -- minmax finds the lowest, and highest in a list - used for mult. -- Should use foldl rather than foldr -- Should use foldl rather than foldr minmax [a] = a :#: a minmax [a] = a :#: a minmax (a:as) = case True of minmax (a:as) = case True of True | (a > s) -> f :#: a True | (a > s) -> f :#: a True | (a < f) -> a :#: s True | (a < f) -> a :#: s otherwise -> f :#: s otherwise -> f :#: s where where (f :#: s) = minmax as (f :#: s) = minmax as ivAbs (Pt a) = Pt (abs a) ivAbs (Pt a) = Pt (abs a) ivAbs (a :#: b) | a<=0 && 0<=b = 0 :#: (max (abs a) (abs b)) ivAbs (a :#: b) | a<=0 && 0<=b = 0 :#: (max (abs a) (abs b)) | a<=b && b<0 = b :#: a | a<=b && b<0 = b :#: a | 0 (Interval a) -> (Interval a) ivSin :: (Floating a) => (Interval a) -> (Interval a) ... ...
This diff is collapsed.
 ... @@ -39,9 +39,9 @@ import NofibUtils ... @@ -39,9 +39,9 @@ import NofibUtils main = replicateM_ 1000 \$ do main = replicateM_ 1000 \$ do argv <- getArgs argv <- getArgs let let n = case argv of n = case argv of [a] -> read a [a] -> read a _ -> 7 _ -> 7 hSetBinaryMode stdout True hSetBinaryMode stdout True print (hash (picture n)) print (hash (picture n)) ... ...
 ... @@ -33,10 +33,10 @@ dorow :: (Fractional a) => Row -> R3 a -> a ... @@ -33,10 +33,10 @@ dorow :: (Fractional a) => Row -> R3 a -> a dorow (m11,m12,m13,m14) (x,y,z) dorow (m11,m12,m13,m14) (x,y,z) = case (m1 * x) + (m2 * y) + (m3 * z) + m4 of n -> n = case (m1 * x) + (m2 * y) + (m3 * z) + m4 of n -> n where where m1 = realToFrac m11 m1 = realToFrac m11 m2 = realToFrac m12 m2 = realToFrac m12 m3 = realToFrac m13 m3 = realToFrac m13 m4 = realToFrac m14 m4 = realToFrac m14 mat4x1' :: (Fractional a) => Arr -> R3 a -> R3 a mat4x1' :: (Fractional a) => Arr -> R3 a -> R3 a mat4x1' (r1,r2,r3) xyz = (x,y,z) mat4x1' (r1,r2,r3) xyz = (x,y,z) ... @@ -49,9 +49,9 @@ dorow' :: (Fractional a) => Row -> R3 a -> a ... @@ -49,9 +49,9 @@ dorow' :: (Fractional a) => Row -> R3 a -> a dorow' (m11,m12,m13,m14) (x,y,z) dorow' (m11,m12,m13,m14) (x,y,z) = case (m1 * x) + (m2 * y) + (m3 * z) of n -> n = case (m1 * x) + (m2 * y) + (m3 * z) of n -> n where where m1 = realToFrac m11 m1 = realToFrac m11 m2 = realToFrac m12 m2 = realToFrac m12 m3 = realToFrac m13 m3 = realToFrac m13 mat1x4 :: Row -> Arr -> Row mat1x4 :: Row -> Arr -> Row mat1x4 a (b1,b2,b3) = (c1,c2,c3,c4) mat1x4 a (b1,b2,b3) = (c1,c2,c3,c4) ... ...
 ... @@ -46,7 +46,7 @@ makeoct csg = octer 1 csg xyz ... @@ -46,7 +46,7 @@ makeoct csg = octer 1 csg xyz -- octer :: Int -> Csg -> (R3 BI) -> Oct -- octer :: Int -> Csg -> (R3 BI) -> Oct octer nn csg xyz octer nn csg xyz = case (calc csg white xyz) of = case (calc csg white xyz) of (res,newc',rgb,new) -> (res,newc',rgb,new) -> let let newc = if new then newc' else csg newc = if new then newc' else csg c = light rgb (calcn newc xyz) c = light rgb (calcn newc xyz) ... @@ -54,35 +54,35 @@ octer nn csg xyz ... @@ -54,35 +54,35 @@ octer nn csg xyz bhx = bothalf x ; thx = tophalf x bhx = bothalf x ; thx = tophalf x bhy = bothalf y ; thy = tophalf y bhy = bothalf y ; thy = tophalf y tbz = topbit z ; bhz = bothalf z tbz = topbit z ; bhz = bothalf z os = if nn == 1 then osb else osa os = if nn == 1 then osb else osa n1 = nn + 1 n1 = nn + 1 osa = map (octer n1 newc) osa = map (octer n1 newc) [ (bhx,bhy,tbz) , (bhx,bhy,bhz) , [ (bhx,bhy,tbz) , (bhx,bhy,bhz) , (thx,bhy,tbz) , (thx,bhy,bhz) , (thx,bhy,tbz) , (thx,bhy,bhz) , (bhx,thy,tbz) , (bhx,thy,bhz) , (bhx,thy,tbz) , (bhx,thy,bhz) , (thx,thy,tbz) , (thx,thy,bhz) ] (thx,thy,tbz) , (thx,thy,bhz) ] osb = [(octer n1 newc (bhx,bhy,tbz)) , osb = [(octer n1 newc (bhx,bhy,tbz)) , (octer n1 newc (bhx,bhy,bhz)) , (octer n1 newc (bhx,bhy,bhz)) , (octer n1 newc (thx,bhy,tbz)) , (octer n1 newc (thx,bhy,tbz)) , (octer n1 newc (thx,bhy,bhz)) , (octer n1 newc (thx,bhy,bhz)) , (octer n1 newc (bhx,thy,tbz)) , (octer n1 newc (bhx,thy,tbz)) , (octer n1 newc (bhx,thy,bhz)) , (octer n1 newc (bhx,thy,bhz)) , (octer n1 newc (thx,thy,tbz)) , (octer n1 newc (thx,thy,tbz)) , (octer n1 newc (thx,thy,bhz)) ] (octer n1 newc (thx,thy,bhz)) ] in in if res < (pt 0) then if res < (pt 0) then O_Full c O_Full c else if res > (pt 0) then else if res > (pt 0) then O_Empty O_Empty else else O_Sub c os O_Sub c os {- {- os = map (octer newc) os = map (octer newc) [ (bhx,bhy,tbz) , (bhx,bhy,bhz) , [ (bhx,bhy,tbz) , (bhx,bhy,bhz) , (thx,bhy,tbz) , (thx,bhy,bhz) , (thx,bhy,tbz) , (thx,bhy,bhz) , (bhx,thy,tbz) , (bhx,thy,bhz) , (bhx,thy,tbz) , (bhx,thy,bhz) , (thx,thy,tbz) , (thx,thy,bhz) ] (thx,thy,tbz) , (thx,thy,bhz) ] -} -} calcn csg xyz = normalise (makevector f0 f1 f2 f3) calcn csg xyz = normalise (makevector f0 f1 f2 f3) ... ...
 ... @@ -34,7 +34,7 @@ qo (O_Sub s l) (Q_Empty ) = Q_Sub s z ... @@ -34,7 +34,7 @@ qo (O_Sub s l) (Q_Empty ) = Q_Sub s z (l2:ll3) = ll2 ; (l3:ll4) = ll3 (l2:ll3) = ll2 ; (l3:ll4) = ll3 (l4:ll5) = ll4 ; (l5:ll6) = ll5 (l4:ll5) = ll4 ; (l5:ll6) = ll5 (l6:ll7) = ll6 ; (l7:ll8) = ll7 (l6:ll7) = ll6 ; (l7:ll8) = ll7 z = [ qo (l1) (qo (l0) Q_Empty) , z = [ qo (l1) (qo (l0) Q_Empty) , qo (l3) (qo (l2) Q_Empty) , qo (l3) (qo (l2) Q_Empty) , qo (l5) (qo (l4) Q_Empty) , qo (l5) (qo (l4) Q_Empty) , qo (l7) (qo (l6) Q_Empty) ] qo (l7) (qo (l6) Q_Empty) ] ... @@ -46,7 +46,7 @@ qo (O_Sub s l) (Q_Sub t k) = Q_Sub t z ... @@ -46,7 +46,7 @@ qo (O_Sub s l) (Q_Sub t k) = Q_Sub t z (l6:ll7) = ll6 ; (l7:ll8) = ll7 (l6:ll7) = ll6 ; (l7:ll8) = ll7 (k0:kk1) = k ; (k1:kk2) = kk1 (k0:kk1) = k ; (k1:kk2) = kk1 (k2:kk3) = kk2 ; (k3:kk4) = kk3 (k2:kk3) = kk2 ; (k3:kk4) = kk3 z = [ qo (l1) (qo (l0) (k0)) , z = [ qo (l1) (qo (l0) (k0)) , qo (l3) (qo (l2) (k1)) , qo (l3) (qo (l2) (k1)) , qo (l5) (qo (l4) (k2)) , qo (l5) (qo (l4) (k2)) , qo (l7) (qo (l6) (k3)) ] qo (l7) (qo (l6) (k3)) ] ... @@ -54,7 +54,7 @@ qo o@(O_Full s) (Q_Sub t k) = Q_Sub t z ... @@ -54,7 +54,7 @@ qo o@(O_Full s) (Q_Sub t k) = Q_Sub t z where where (k0:kk1) = k ; (k1:kk2) = kk1 (k0:kk1) = k ; (k1:kk2) = kk1 (k2:kk3) = kk2 ; (k3:kk4) = kk3 (k2:kk3) = kk2 ; (k3:kk4) = kk3 z = [ qo o (k0) , qo o (k1) , z = [ qo o (k0) , qo o (k1) , qo o (k2) , qo o (k3) ] qo o (k2) , qo o (k3) ] qo (O_Full s ) (q ) = Q_Full s qo (O_Full s ) (q ) = Q_Full s
 ... @@ -37,14 +37,14 @@ data Prim = Sphere FType FType FType FType ... @@ -37,14 +37,14 @@ data Prim = Sphere FType FType FType FType | Cube FType FType FType FType | Cube FType FType FType FType | Plane FType FType FType FType | Plane FType FType FType FType | X | Y | Z | X | Y | Z deriving Show{-was:Text-} deriving Show{-was:Text-} data Ops = RotX FType data Ops = RotX FType | RotY FType | RotY FType | RotZ FType | RotZ FType | Scale FType FType FType | Scale FType FType FType | Trans FType FType FType | Trans FType FType FType deriving Show{-was:Text-} deriving Show{-was:Text-} data Csg = Object Prim data Csg = Object Prim | Geom Csg Ops | Geom Csg Ops ... @@ -55,7 +55,7 @@ data Csg = Object Prim ... @@ -55,7 +55,7 @@ data Csg = Object Prim | Inter Csg Csg | Inter Csg Csg | Sub Csg Csg | Sub Csg Csg | Comp Csg | Comp Csg -- deriving Show{-was:Text-} -- deriving Show{-was:Text-} -- type CsgOut = (R1 BI,Csg,Color,Bool) -- type CsgOut = (R1 BI,Csg,Color,Bool) ... @@ -68,7 +68,7 @@ type Calc = Color -> (R3 BI) -> CsgOut ... @@ -68,7 +68,7 @@ type Calc = Color -> (R3 BI) -> CsgOut ---------------------------------------------------------- ---------------------------------------------------------- data Color = RGB FType FType FType data Color = RGB FType FType FType deriving Show{-was:Text-} deriving Show{-was:Text-} ---------------------------------------------------------- ---------------------------------------------------------- -- Matrix -- Matrix ... @@ -89,7 +89,7 @@ type R1 a = (a,a) ... @@ -89,7 +89,7 @@ type R1 a = (a,a) ---------------------------------------------------------- ---------------------------------------------------------- data Oct = O_Full Color | O_Empty | O_Sub Color [Oct] data Oct = O_Full Color | O_Empty | O_Sub Color [Oct] deriving Show{-was:Text-} deriving Show{-was:Text-} ---------------------------------------------------------- ---------------------------------------------------------- -- Quad -- Quad ... @@ -98,7 +98,7 @@ data Oct = O_Full Color | O_Empty | O_Sub Color [Oct] ... @@ -98,7 +98,7 @@ data Oct = O_Full Color | O_Empty | O_Sub Color [Oct] data Quad = Q_Empty | Q_Full Color data Quad = Q_Empty | Q_Full Color | Q_Sub Color [Quad] | Q_Sub Color [Quad] | Q_NewXY FType FType FType | Q_NewXY FType FType FType deriving Show{-was:Text-} deriving Show{-was:Text-} ---------------------------------------------------------- ---------------------------------------------------------- -- Vector -- Vector ... ...
 ... @@ -38,7 +38,7 @@ len :: Vector -> FType ... @@ -38,7 +38,7 @@ len :: Vector -> FType len (x,y,z) = ans len (x,y,z) = ans where where ans | sqs /= 0.0 = sqrt sqs ans | sqs /= 0.0 = sqrt sqs | True = 1 | True = 1 sqs :: FType sqs :: FType sqs = (x2 + y2 + z2) sqs = (x2 + y2 + z2) x2 = x * x x2 = x * x ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!