1 module Hide(hiddenline) where
    2 import Numbers
    3 import Vectors
    4 import EdgePlate
    5 import Geometric
    6 import Comparing
    7 import Memo
    8 import Postscript
    9 import Array    -- 1.3
   10 
   11 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   12 -- section 5: Hiding
   13 
   14 -- The following function does the entire job...
   15 hiddenline :: Vector -> Input -> Output
   16 hiddenline v corners
   17         = (draw . scale factor base . hideObj . makeObject) rotated
   18           where rotated = v `rot` corners
   19                 (base,factor) = getExtremes (concat rotated)
   20 
   21 -- `hide' calculates the leftovers of plate bottom as compared to plates tops
   22 hide :: Array (Triangle Int) Bool -> Object -> Plate -> [Edge]
   23 hide memory obj bottom@(Plt _ ls) =
   24         foldr cmp ls tops
   25         where tops = [top| top <- obj, lazyAbove memory top bottom]
   26 
   27 -- `hideObj' hides edgeparts in an object, with view direction vec[0,0,1]
   28 hideObj :: Object -> [Edge]
   29 hideObj obj = concat [hide (mkmemo above obj) obj plt| plt <- obj]
   30 
   31 
   32 getExtremes :: [Vector] -> (Vector,Number)
   33 getExtremes vs =
   34         (vec [minimum xs, minimum ys, 0], factor)
   35         where
   36         factor = ((400 / ((maximum xs-minimum xs) `max` 1)) `min`
   37                   (640 / ((maximum ys-minimum ys) `max` 1)))
   38         xs = map x vs
   39         ys = map y vs