packages feed

diagrams-lib-0.4.0.1 / src / Diagrams / ThreeD / Shapes.hs

{-# LANGUAGE TypeFamilies           , FlexibleContexts  #-}------------------------------------------------------------------------------- |-- Module      :  Diagrams.ThreeD.Shapes-- Copyright   :  (c) 2011 diagrams-lib team (see LICENSE)-- License     :  BSD-style (see LICENSE)-- Maintainer  :  diagrams-discuss@googlegroups.com---- Various three-dimensional shapes.-------------------------------------------------------------------------------module Diagrams.ThreeD.Shapes       (         Ellipsoid(..)       , sphere       ) whereimport Graphics.Rendering.Diagramsimport Diagrams.ThreeD.Typesimport Diagrams.Utilimport Data.Monoiddata Ellipsoid = Ellipsoid T3type instance V Ellipsoid = R3instance Transformable Ellipsoid where  transform t1 (Ellipsoid t2) = Ellipsoid (t1 <> t2)sphere :: (Backend b R3, Renderable Ellipsoid b) => Diagram b R3sphere = mkAD (Prim $ Ellipsoid mempty)              (Bounds sphereBounds)              mempty              (Query sphereQuery)  where sphereBounds (x,y,z) = 1 / sqrt(x*x + y*y + z*z)        sphereQuery (P (x,y,z)) = Any $ x*x + y*y + z*z <= 1