Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data OctTree a = OctTree {
- ot_default :: a
- ot_root_pow :: Integer
- ot_tree :: Free a
- fill :: forall a. Cube Rational -> a -> OctTree a -> OctTree a
- combineAla :: forall n a. (Coercible a n, Semigroup n) => (a -> n) -> OctTree a -> OctTree a -> OctTree a
- lookup :: V3 Rational -> OctTree a -> a
- query :: Semilattice s => (a -> s) -> Cube Rational -> OctTree a -> s
- fuse :: Eq a => OctTree a -> OctTree a
- elements :: Ord a => OctTree a -> Set a
- toCubes :: OctTree a -> [(Cube Rational, a)]
- boundingCube :: OctTree a -> Cube Rational
- defaultValue :: OctTree a -> a
- data Cube a = Cube {}
- mkCubeByPow :: Integer -> Cube Rational
- midpoint :: Fractional a => Cube a -> V3 a
- subdivide :: Fractional a => Cube a -> Oct (Cube a)
- cubeCorners :: Num a => Cube a -> Oct (V3 a)
- data V3 a = V3 !a !a !a
- data Oct a = Oct !(V4 a) !(V4 a)
Documentation
A type mapping values at (infinitely precise) locations in 3D
space. That is, you can consider an OctTree
to be a function
, equipped with efficient means of querying the space.V3
Rational
-> a
OctTree
s should usually be constructed using their Monoid
al or
Applicative
interfaces, as well as by way of the fill
function.
OctTree | |
|
Instances
Constructing OctTree
s
combineAla :: forall n a. (Coercible a n, Semigroup n) => (a -> n) -> OctTree a -> OctTree a -> OctTree a Source #
Combine two OctTree
s using a different semigroup than usual. For
example, in order to replace any values in ot1
with those covered by
ot2
, we can use:
combineAla
Last
ot1 ot2
Spatially Querying OctTree
s
query :: Semilattice s => (a -> s) -> Cube Rational -> OctTree a -> s Source #
Query a region of space in an OctTree
. This method is a special case of
foldMap
, specialized to finite regions.
For example, if you'd like to check if everything in the Cube
has
a specific value, use All
as your choice of Semilattice
. If
you'd like to check whether anything in the space has a value, instead use
Any
.
Eliminating OctTree
s
fuse :: Eq a => OctTree a -> OctTree a Source #
Fuse together all adjacent regions of space which contain the same value. This will speed up subsequent queries, but requires traversing the entire tree.
toCubes :: OctTree a -> [(Cube Rational, a)] Source #
Partition the OctTree
into contiguous, singular-valued Cube
s.
Satsifies the law
foldMap
(uncurry $cube
(defaultValue
ot)) (toCubes
ot) == ot
defaultValue :: OctTree a -> a Source #
Get the value used to fill the infinity of space in an OctTree
.
Constructing Cube
s
An axis-aligned bounding box in 3-space.
Instances
Functor Cube Source # | |
Generic (Cube a) Source # | |
Read a => Read (Cube a) Source # | |
Show a => Show (Cube a) Source # | |
Eq a => Eq (Cube a) Source # | |
Ord a => Ord (Cube a) Source # | |
type Rep (Cube a) Source # | |
Defined in Data.OctTree.Internal type Rep (Cube a) = D1 ('MetaData "Cube" "Data.OctTree.Internal" "nspace-0.2.0.0-JcrzAw5ubjR6TX1H0E6SmC" 'False) (C1 ('MetaCons "Cube" 'PrefixI 'True) (S1 ('MetaSel ('Just "r_pos") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V3 a)) :*: S1 ('MetaSel ('Just "r_size") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V3 a)))) |
mkCubeByPow :: Integer -> Cube Rational Source #
Construct a Cube
centered around $(0, 0, 0)$, with side length $2n$.
Eliminating Cube
s
Indexing Types
A 3-dimensional vector
V3 !a !a !a |
Instances
Representable V3 | |
MonadFix V3 | |
MonadZip V3 | |
Foldable V3 | |
Defined in Linear.V3 fold :: Monoid m => V3 m -> m # foldMap :: Monoid m => (a -> m) -> V3 a -> m # foldMap' :: Monoid m => (a -> m) -> V3 a -> m # foldr :: (a -> b -> b) -> b -> V3 a -> b # foldr' :: (a -> b -> b) -> b -> V3 a -> b # foldl :: (b -> a -> b) -> b -> V3 a -> b # foldl' :: (b -> a -> b) -> b -> V3 a -> b # foldr1 :: (a -> a -> a) -> V3 a -> a # foldl1 :: (a -> a -> a) -> V3 a -> a # elem :: Eq a => a -> V3 a -> Bool # maximum :: Ord a => V3 a -> a # | |
Eq1 V3 | |
Ord1 V3 | |
Read1 V3 | |
Show1 V3 | |
Traversable V3 | |
Applicative V3 | |
Functor V3 | |
Monad V3 | |
Serial1 V3 | |
Defined in Linear.V3 serializeWith :: MonadPut m => (a -> m ()) -> V3 a -> m () # deserializeWith :: MonadGet m => m a -> m (V3 a) # | |
Distributive V3 | |
Foldable1 V3 | |
Defined in Linear.V3 fold1 :: Semigroup m => V3 m -> m # foldMap1 :: Semigroup m => (a -> m) -> V3 a -> m # foldMap1' :: Semigroup m => (a -> m) -> V3 a -> m # toNonEmpty :: V3 a -> NonEmpty a # maximum :: Ord a => V3 a -> a # minimum :: Ord a => V3 a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> V3 a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> V3 a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> V3 a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> V3 a -> b # | |
Hashable1 V3 | |
Metric V3 | |
Finite V3 | |
R1 V3 | |
R2 V3 | |
R3 V3 | |
Additive V3 | |
Apply V3 | |
Bind V3 | |
Traversable1 V3 | |
Generic1 V3 | |
Unbox a => Vector Vector (V3 a) | |
Defined in Linear.V3 basicUnsafeFreeze :: Mutable Vector s (V3 a) -> ST s (Vector (V3 a)) # basicUnsafeThaw :: Vector (V3 a) -> ST s (Mutable Vector s (V3 a)) # basicLength :: Vector (V3 a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (V3 a) -> Vector (V3 a) # basicUnsafeIndexM :: Vector (V3 a) -> Int -> Box (V3 a) # basicUnsafeCopy :: Mutable Vector s (V3 a) -> Vector (V3 a) -> ST s () # | |
Unbox a => MVector MVector (V3 a) | |
Defined in Linear.V3 basicLength :: MVector s (V3 a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (V3 a) -> MVector s (V3 a) # basicOverlaps :: MVector s (V3 a) -> MVector s (V3 a) -> Bool # basicUnsafeNew :: Int -> ST s (MVector s (V3 a)) # basicInitialize :: MVector s (V3 a) -> ST s () # basicUnsafeReplicate :: Int -> V3 a -> ST s (MVector s (V3 a)) # basicUnsafeRead :: MVector s (V3 a) -> Int -> ST s (V3 a) # basicUnsafeWrite :: MVector s (V3 a) -> Int -> V3 a -> ST s () # basicClear :: MVector s (V3 a) -> ST s () # basicSet :: MVector s (V3 a) -> V3 a -> ST s () # basicUnsafeCopy :: MVector s (V3 a) -> MVector s (V3 a) -> ST s () # basicUnsafeMove :: MVector s (V3 a) -> MVector s (V3 a) -> ST s () # basicUnsafeGrow :: MVector s (V3 a) -> Int -> ST s (MVector s (V3 a)) # | |
Data a => Data (V3 a) | |
Defined in Linear.V3 gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V3 a -> c (V3 a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V3 a) # dataTypeOf :: V3 a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (V3 a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V3 a)) # gmapT :: (forall b. Data b => b -> b) -> V3 a -> V3 a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V3 a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V3 a -> r # gmapQ :: (forall d. Data d => d -> u) -> V3 a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> V3 a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> V3 a -> m (V3 a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V3 a -> m (V3 a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V3 a -> m (V3 a) # | |
Storable a => Storable (V3 a) | |
Monoid a => Monoid (V3 a) | |
Semigroup a => Semigroup (V3 a) | |
Bounded a => Bounded (V3 a) | |
Floating a => Floating (V3 a) | |
Generic (V3 a) | |
Ix a => Ix (V3 a) | |
Num a => Num (V3 a) | |
Read a => Read (V3 a) | |
Fractional a => Fractional (V3 a) | |
Show a => Show (V3 a) | |
Binary a => Binary (V3 a) | |
Serial a => Serial (V3 a) | |
Serialize a => Serialize (V3 a) | |
NFData a => NFData (V3 a) | |
Eq a => Eq (V3 a) | |
Ord a => Ord (V3 a) | |
Hashable a => Hashable (V3 a) | |
Ixed (V3 a) | |
Epsilon a => Epsilon (V3 a) | |
Random a => Random (V3 a) | |
Unbox a => Unbox (V3 a) | |
Defined in Linear.V3 | |
FoldableWithIndex (E V3) V3 | |
FunctorWithIndex (E V3) V3 | |
TraversableWithIndex (E V3) V3 | |
Lift a => Lift (V3 a :: Type) | |
Each (V3 a) (V3 b) a b | |
Field1 (V3 a) (V3 a) a a | |
Field2 (V3 a) (V3 a) a a | |
Field3 (V3 a) (V3 a) a a | |
type Rep V3 | |
type Size V3 | |
type Rep1 V3 | |
Defined in Linear.V3 type Rep1 V3 = D1 ('MetaData "V3" "Linear.V3" "linear-1.22-ANafbhSdznBKD15zEySBd9" 'False) (C1 ('MetaCons "V3" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1 :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1))) | |
data MVector s (V3 a) | |
type Rep (V3 a) | |
Defined in Linear.V3 type Rep (V3 a) = D1 ('MetaData "V3" "Linear.V3" "linear-1.22-ANafbhSdznBKD15zEySBd9" 'False) (C1 ('MetaCons "V3" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) | |
type Index (V3 a) | |
type IxValue (V3 a) | |
data Vector (V3 a) | |
An 8-tuple of values.
Instances
Foldable Oct Source # | |
Defined in Data.OctTree.Internal fold :: Monoid m => Oct m -> m # foldMap :: Monoid m => (a -> m) -> Oct a -> m # foldMap' :: Monoid m => (a -> m) -> Oct a -> m # foldr :: (a -> b -> b) -> b -> Oct a -> b # foldr' :: (a -> b -> b) -> b -> Oct a -> b # foldl :: (b -> a -> b) -> b -> Oct a -> b # foldl' :: (b -> a -> b) -> b -> Oct a -> b # foldr1 :: (a -> a -> a) -> Oct a -> a # foldl1 :: (a -> a -> a) -> Oct a -> a # elem :: Eq a => a -> Oct a -> Bool # maximum :: Ord a => Oct a -> a # | |
Traversable Oct Source # | |
Applicative Oct Source # | |
Functor Oct Source # | |
Monoid a => Monoid (Oct a) Source # | |
Semigroup a => Semigroup (Oct a) Source # | |
Generic (Oct a) Source # | |
Show a => Show (Oct a) Source # | |
Eq a => Eq (Oct a) Source # | |
Ord a => Ord (Oct a) Source # | |
type Rep (Oct a) Source # | |
Defined in Data.OctTree.Internal type Rep (Oct a) = D1 ('MetaData "Oct" "Data.OctTree.Internal" "nspace-0.2.0.0-JcrzAw5ubjR6TX1H0E6SmC" 'False) (C1 ('MetaCons "Oct" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V4 a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V4 a)))) |