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

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


module Geometric (Geom(..)) where
import Numbers
import Vectors
import EdgePlate
import Rotate

class Geom a where
	(|||) :: a -> a -> Bool			-- two entities are parrallel ?
	vertical :: a -> Bool
	rot :: Vector -> a -> a			-- rotation
	proj :: a -> a				-- projection
	scale :: Number -> Vector -> a -> a	-- scale the entity and
						-- put it in the first quadrant


instance Geom a => Geom [a] where
	rot viewdir = map (rot viewdir)
	proj = map proj
	scale f b = map (scale f b)

instance Geom Vector where
	v ||| w = v*w == 0
	vertical v = v ||| vec [0,0,1]
	rot = rotate
	proj v = vec [x(v),y(v),0]
	scale factor base v = factor `mulv` (v - base)

instance Geom Edge where
	l ||| k	= h(l) ||| h(k)
	vertical l = vertical (h(l))
	v `rot` l = edgeT (v `rot` s(l)) (v `rot` t(l))
	proj l = edgeT (proj(s(l))) (proj(t(l)))
	scale f b l = edgeT (scale f b (s(l))) (scale f b (t(l)))

instance Geom Plate where
	plt1 ||| plt2 = n(plt1) ||| n(plt2)
	vertical plt = z( n(plt) ) == 0
	v `rot` (Plt n ls)  = Plt n [v `rot` l| l<-ls]
	proj (Plt n ls) = Plt n [proj l| l<-ls]

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.