Description

A 2-dimensional point.

Synopsis

# Documentation

data Point a Source #

A 2-dim point of a's

A Point is functorial over both arguments, and is a Num instance.

>>> let p = Point 1 1
>>> p + p
Point 2 2
>>> (2*) <$> p Point 2 2  A major reason for this bespoke treatment of a point is that Points do not have maximums and minimums but they form a lattice, and this is useful for folding points to find out the (rectangular) Space they occupy. >>> Point 0 1 /\ Point 1 0 Point 0 0 >>> Point 0 1 \/ Point 1 0 Point 1 1  Constructors  Point a a Instances  Source # Instance detailsDefined in NumHask.Space.Point Methods(>>=) :: Point a -> (a -> Point b) -> Point b #(>>) :: Point a -> Point b -> Point b #return :: a -> Point a #fail :: String -> Point a # Source # Instance detailsDefined in NumHask.Space.Point Methodsfmap :: (a -> b) -> Point a -> Point b #(<$) :: a -> Point b -> Point a # Source # Instance detailsDefined in NumHask.Space.Point Methodspure :: a -> Point a #(<*>) :: Point (a -> b) -> Point a -> Point b #liftA2 :: (a -> b -> c) -> Point a -> Point b -> Point c #(*>) :: Point a -> Point b -> Point b #(<*) :: Point a -> Point b -> Point a # Source # Instance detailsDefined in NumHask.Space.Point Methodsfold :: Monoid m => Point m -> m #foldMap :: Monoid m => (a -> m) -> Point a -> m #foldr :: (a -> b -> b) -> b -> Point a -> b #foldr' :: (a -> b -> b) -> b -> Point a -> b #foldl :: (b -> a -> b) -> b -> Point a -> b #foldl' :: (b -> a -> b) -> b -> Point a -> b #foldr1 :: (a -> a -> a) -> Point a -> a #foldl1 :: (a -> a -> a) -> Point a -> a #toList :: Point a -> [a] #null :: Point a -> Bool #length :: Point a -> Int #elem :: Eq a => a -> Point a -> Bool #maximum :: Ord a => Point a -> a #minimum :: Ord a => Point a -> a #sum :: Num a => Point a -> a #product :: Num a => Point a -> a # Source # Instance detailsDefined in NumHask.Space.Point Methodstraverse :: Applicative f => (a -> f b) -> Point a -> f (Point b) #sequenceA :: Applicative f => Point (f a) -> f (Point a) #mapM :: Monad m => (a -> m b) -> Point a -> m (Point b) #sequence :: Monad m => Point (m a) -> m (Point a) # Source # Instance detailsDefined in NumHask.Space.Point Methodsdistribute :: Functor f => f (Point a) -> Point (f a) #collect :: Functor f => (a -> Point b) -> f a -> Point (f b) #distributeM :: Monad m => m (Point a) -> Point (m a) #collectM :: Monad m => (a -> Point b) -> m a -> Point (m b) # Source # Instance detailsDefined in NumHask.Space.Point Associated Typestype Rep Point :: Type # Methodstabulate :: (Rep Point -> a) -> Point a #index :: Point a -> Rep Point -> a # Source # Instance detailsDefined in NumHask.Space.Point MethodsliftEq :: (a -> b -> Bool) -> Point a -> Point b -> Bool # Source # Instance detailsDefined in NumHask.Space.Point MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Point a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Point a] -> ShowS # Bounded a => Bounded (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods Eq a => Eq (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(==) :: Point a -> Point a -> Bool #(/=) :: Point a -> Point a -> Bool # Fractional a => Fractional (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(/) :: Point a -> Point a -> Point a #recip :: Point a -> Point a # Num a => Num (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(+) :: Point a -> Point a -> Point a #(-) :: Point a -> Point a -> Point a #(*) :: Point a -> Point a -> Point a #negate :: Point a -> Point a #abs :: Point a -> Point a #signum :: Point a -> Point a # Show a => Show (Point a) Source # Instance detailsDefined in NumHask.Space.Point MethodsshowsPrec :: Int -> Point a -> ShowS #show :: Point a -> String #showList :: [Point a] -> ShowS # Generic (Point a) Source # Instance detailsDefined in NumHask.Space.Point Associated Typestype Rep (Point a) :: Type -> Type # Methodsfrom :: Point a -> Rep (Point a) x #to :: Rep (Point a) x -> Point a # Semigroup a => Semigroup (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(<>) :: Point a -> Point a -> Point a #sconcat :: NonEmpty (Point a) -> Point a #stimes :: Integral b => b -> Point a -> Point a # (Semigroup a, Monoid a) => Monoid (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methodsmempty :: Point a #mappend :: Point a -> Point a -> Point a #mconcat :: [Point a] -> Point a # Ord a => Lattice (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(\/) :: Point a -> Point a -> Point a #(/\) :: Point a -> Point a -> Point a # type Rep Point Source # Instance detailsDefined in NumHask.Space.Point type Rep Point = Bool type Rep (Point a) Source # Instance detailsDefined in NumHask.Space.Point type Rep (Point a) = D1 (MetaData "Point" "NumHask.Space.Point" "numhask-space-0.3.0-GM7MUIaWR8l8Uregq0MgYU" False) (C1 (MetaCons "Point" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

rotate :: Floating a => a -> Point a -> Point a Source #

rotate a point by x degrees relative to the origin

>>> rotate 90 (Point 0 1)
Point 1.0 6.123233995736766e-17


gridP :: (Ord a, Fractional a) => (a -> a) -> Range a -> Int -> [Point a] Source #

Create Points for a formulae y = f(x) across an x range

>>> gridP (**2) (Range 0 4) 4
[Point 0.0 0.0,Point 1.0 1.0,Point 2.0 4.0,Point 3.0 9.0,Point 4.0 16.0]