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

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


module Preds(into,onto) where
import Numbers
import Vectors
import EdgePlate
import Geometric
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- section 9: Predicates

-- p `onto` l <=> proj(p) is member of set proj(l)
onto ::  Vector -> Edge -> Bool
p`onto`l | vertical l = proj(p)==proj(s(l))
	 | otherwise  = v ||| w && 0<=v`inpr`w && v`inpr`w<=w`inpr`w
			where v = proj(p-s(l))
			      w = proj(h(l))
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- section 9: Predicates

-- v `into` ls means that proj(v) is inside (including the border of) proj(ls).
into :: Vector -> Plate -> Bool
v`into`p @ (Plt _ ls)
	| vertical p  = or  [v`onto`l |l<-ls]
	| otherwise   = and [a>=0| a<-zs] || and [a<=0| a<-zs]
			where zs = [z ( (v-s(l)) * h(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.