packages feed

implicit-0.0.1: Graphics/Implicit/Operations/BoxedObj3.hs

-- Implicit CAD. Copyright (C) 2011, Christopher Olah (chris@colah.ca)
-- Released under the GNU GPL, see LICENSE

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, TypeSynonymInstances, UndecidableInstances #-}

module Graphics.Implicit.Operations.BoxedObj3 where

import Prelude hiding ((+),(-),(*),(/))
import Graphics.Implicit.Operations.Definitions
import Graphics.Implicit.Operations.Box3
import Graphics.Implicit.Operations.Obj3
import Graphics.Implicit.Definitions
import Graphics.Implicit.MathUtil
import Graphics.Implicit.SaneOperators

instance BasicObj (Boxed3 Obj3) ℝ3 where
	translate p (obj, box) = (translate p obj, translate p box)
	scale s (obj, box) = (scale s obj, scale s box)
	rotateXY θ (obj, box) = (rotateXY θ obj, rotateXY θ box)
	complement (obj, box) = (complement obj, complement box )
	union bobjs = (union objs, union boxes) where
		(objs, boxes) = unzip bobjs
	intersect bobjs = (intersect objs, intersect boxes) where
		(objs, boxes) = unzip bobjs
	difference bobjs = (difference objs, difference boxes) where
		(objs, boxes) = unzip bobjs

instance MagnitudeObj (Boxed3 Obj3) where
	outset  d     (obj, box) = (outset d obj, outset d box)
	shell   w     (obj, box) = (shell  w obj, shell  w box)
	unionR      r bobjs      = (unionR      r objs, unionR      r boxes) where
		(objs, boxes) = unzip bobjs
	intersectR  r bobjs      = (intersectR  r objs, intersectR  r boxes) where
		(objs, boxes) = unzip bobjs
	differenceR r bobjs      = (differenceR r objs, differenceR r boxes) where
		(objs, boxes) = unzip bobjs