Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nofib/real/hidden/Hide.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module Hide(hiddenline) where
import Numbers
import Vectors
import EdgePlate
import Geometric
import Comparing
import Memo
import Postscript
import Array    -- 1.3

-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- section 5: Hiding

-- The following function does the entire job...
hiddenline :: Vector -> Input -> Output
hiddenline v corners
	= (draw . scale factor base . hideObj . makeObject) rotated
	  where rotated = v `rot` corners
		(base,factor) = getExtremes (concat rotated)

-- `hide' calculates the leftovers of plate bottom as compared to plates tops
hide :: Array (Triangle Int) Bool -> Object -> Plate -> [Edge]
hide memory obj bottom@(Plt _ ls) =
	foldr cmp ls tops
	where tops = [top| top <- obj, lazyAbove memory top bottom]

-- `hideObj' hides edgeparts in an object, with view direction vec[0,0,1]
hideObj :: Object -> [Edge]
hideObj obj = concat [hide (mkmemo above obj) obj plt| plt <- obj]


getExtremes :: [Vector] -> (Vector,Number)
getExtremes vs =
        (vec [minimum xs, minimum ys, 0], factor)
        where
        factor = ((400 / ((maximum xs-minimum xs) `max` 1)) `min`
                  (640 / ((maximum ys-minimum ys) `max` 1)))
        xs = map x vs
        ys = map y vs

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.