Description

A 2-dimensional point.

Synopsis

# Documentation

data Point a Source #

A 2-dimensional Point of a's

In contrast with a tuple, a Point is functorial over both arguments.

>>> let p = Point 1 1
>>> p + p
Point 2 2
>>> (2*) <$> p Point 2 2  A major reason for this bespoke treatment (compared to just using linear, say) is that Points do not have maximums and minimums but they do form a lattice, and this is useful for folding sets of 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  This is used extensively in chart-svg to ergonomically obtain chart areas. space1 [Point 1 0, Point 0 1] :: Rect Double Rect 0.0 1.0 0.0 1.0 Constructors  Point Fields_x :: a _y :: a #### Instances Instances details  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 # 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 #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 # 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 # 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 # Source # Instance detailsDefined in NumHask.Space.Point MethodsuniformRM :: StatefulGen g m => (Point a, Point a) -> g -> m (Point a) # Signed a => Signed (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methodssign :: Point a -> Point a #abs :: Point a -> Point a # Ord a => JoinSemiLattice (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(\/) :: Point a -> Point a -> Point a # Ord a => MeetSemiLattice (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(/\) :: Point a -> Point a -> Point a # Field a => Field (Point a) Source # Instance detailsDefined in NumHask.Space.Point Source # Instance detailsDefined in NumHask.Space.Point Source # Instance detailsDefined in NumHask.Space.Point Methods(*) :: Point a -> Point a -> Point a #one :: Point a # Divisive a => Divisive (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methodsrecip :: Point a -> Point a #(/) :: Point a -> Point a -> Point a # Additive a => Additive (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methods(+) :: Point a -> Point a -> Point a #zero :: Point a # Subtractive a => Subtractive (Point a) Source # Instance detailsDefined in NumHask.Space.Point Methodsnegate :: Point a -> Point a #(-) :: Point a -> Point a -> Point a # ExpField a => Norm (Point a) a Source # Instance detailsDefined in NumHask.Space.Point Methodsnorm :: Point a -> a #basis :: Point a -> Point a # TrigField a => Direction (Point a) a Source # angle formed by a vector from the origin to a Point and the x-axis (Point 1 0). Note that an angle between two points p1 & p2 is thus angle p2 - angle p1\u@(Point ux uy) v@(Point vx vy) -> angle v - angle u == sign (ux*vy-uy*vx) * acos (dotP u v / (norm u * norm v)) Instance detailsDefined in NumHask.Space.Point Methodsangle :: Point a -> a #ray :: a -> Point a # Additive a => AdditiveAction (Point a) a Source # Instance detailsDefined in NumHask.Space.Point Methods(.+) :: a -> Point a -> Point a #(+.) :: Point a -> a -> Point a # Subtractive a => SubtractiveAction (Point a) a Source # Instance detailsDefined in NumHask.Space.Point Methods(.-) :: a -> Point a -> Point a #(-.) :: Point a -> a -> Point a # Source # Instance detailsDefined in NumHask.Space.Point Methods(.*) :: a -> Point a -> Point a #(*.) :: Point a -> a -> Point a # Divisive a => DivisiveAction (Point a) a Source # Instance detailsDefined in NumHask.Space.Point Methods(./) :: a -> Point a -> Point a #(/.) :: Point a -> a -> Point a # (Multiplicative a, Additive a) => Affinity (Point a) a Source # Instance detailsDefined in NumHask.Space.Point Methodstransform :: Transform a -> Point a -> Point a Source # 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.7.1.0-IJsxrWEikkW9u1nkbVAwms" 'False) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "_x") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_y") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)))

rotateP :: TrigField a => a -> Point a -> Point a Source #

rotate a point by x relative to the origin

>>> rotateP (pi/2) (Point 1 0)
Point 6.123233995736766e-17 1.0


gridP :: FieldSpace (Range a) => (a -> a) -> Range a -> Grid (Range a) -> [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]


dotP :: (Multiplicative a, Additive a) => Point a -> Point a -> a Source #

dot product

(<.>) :: (Multiplicative a, Additive a) => Point a -> Point a -> a infix 4 Source #

dot product operator

crossP :: (Multiplicative a, Subtractive a) => Point a -> Point a -> a Source #

cross product

flipY :: Subtractive a => Point a -> Point a Source #

reflect on x-axis

data Line a Source #

A line is a composed of 2 Points

Constructors

 Line FieldslineStart :: Point a lineEnd :: Point a

#### Instances

Instances details
 Source # Instance detailsDefined in NumHask.Space.Point Methodsfmap :: (a -> b) -> Line a -> Line b #(<\$) :: a -> Line b -> Line a # Source # Instance detailsDefined in NumHask.Space.Point Methodsfold :: Monoid m => Line m -> m #foldMap :: Monoid m => (a -> m) -> Line a -> m #foldMap' :: Monoid m => (a -> m) -> Line a -> m #foldr :: (a -> b -> b) -> b -> Line a -> b #foldr' :: (a -> b -> b) -> b -> Line a -> b #foldl :: (b -> a -> b) -> b -> Line a -> b #foldl' :: (b -> a -> b) -> b -> Line a -> b #foldr1 :: (a -> a -> a) -> Line a -> a #foldl1 :: (a -> a -> a) -> Line a -> a #toList :: Line a -> [a] #null :: Line a -> Bool #length :: Line a -> Int #elem :: Eq a => a -> Line a -> Bool #maximum :: Ord a => Line a -> a #minimum :: Ord a => Line a -> a #sum :: Num a => Line a -> a #product :: Num a => Line a -> a # Source # Instance detailsDefined in NumHask.Space.Point Methodstraverse :: Applicative f => (a -> f b) -> Line a -> f (Line b) #sequenceA :: Applicative f => Line (f a) -> f (Line a) #mapM :: Monad m => (a -> m b) -> Line a -> m (Line b) #sequence :: Monad m => Line (m a) -> m (Line a) # Eq a => Eq (Line a) Source # Instance detailsDefined in NumHask.Space.Point Methods(==) :: Line a -> Line a -> Bool #(/=) :: Line a -> Line a -> Bool # Show a => Show (Line a) Source # Instance detailsDefined in NumHask.Space.Point MethodsshowsPrec :: Int -> Line a -> ShowS #show :: Line a -> String #showList :: [Line a] -> ShowS # (Multiplicative a, Additive a) => Affinity (Line a) a Source # Instance detailsDefined in NumHask.Space.Point Methodstransform :: Transform a -> Line a -> Line a Source #

lineSolve :: ExpField a => Line a -> (a, a, a) Source #

Return the parameters (a, b, c) for the line equation a*x + b*y + c = 0.

lineDistance :: ExpField a => Line a -> Point a -> a Source #

Return the signed distance from a point to the line. If the distance is negative, the point lies to the right of the line

closestPoint :: Field a => Line a -> Point a -> Point a Source #

Return the point on the line closest to the given point.

lineIntersect :: (Ord a, Epsilon a, Signed a, Field a) => Line a -> Line a -> Maybe (Point a) Source #

Calculate the intersection of two lines. If the determinant is less than tolerance (parallel or coincident lines), return Nothing.

translate :: TrigField a => Point a -> Transform a Source #

move an Affinity by a Point

scaleT :: TrigField a => Point a -> Transform a Source #

scale an Affinity by a Point

skew :: TrigField a => Point a -> Transform a Source #

Skew transform

x-axis skew

skew (Point x 0)