| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
NumHask.Space.Point
Description
A 2-dimensional point.
Synopsis
- data Point a = Point {}
- rotateP :: TrigField a => a -> Point a -> Point a
- gridP :: FieldSpace (Range a) => (a -> a) -> Range a -> Grid (Range a) -> [Point a]
- dotP :: (Multiplicative a, Additive a) => Point a -> Point a -> a
- (<.>) :: (Multiplicative a, Additive a) => Point a -> Point a -> a
- crossP :: (Multiplicative a, Subtractive a) => Point a -> Point a -> a
- flipY :: Subtractive a => Point a -> Point a
- data Line a = Line {}
- lineSolve :: (ExpField a, Eq a) => Line a -> (a, a, a)
- lineDistance :: ExpField a => Line a -> Point a -> a
- closestPoint :: Field a => Line a -> Point a -> Point a
- lineIntersect :: (Ord a, Epsilon a, Absolute a, Field a) => Line a -> Line a -> Maybe (Point a)
- translate :: TrigField a => Point a -> Transform a
- scaleT :: TrigField a => Point a -> Transform a
- skew :: TrigField a => Point a -> Transform a
Documentation
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 + pPoint 2 2>>>(2*) <$> pPoint 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 0Point 0 0>>>Point 0 1 \/ Point 1 0Point 1 1
This is used extensively in chart-svg to ergonomically obtain chart areas.
unsafeSpace1 [Point 1 0, Point 0 1] :: Rect Double
Rect 0.0 1.0 0.0 1.0
Instances
| Representable Point Source # | |||||
| Foldable Point Source # | |||||
Defined in NumHask.Space.Point Methods fold :: 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 # elem :: Eq a => a -> Point a -> Bool # maximum :: Ord a => Point a -> a # minimum :: Ord a => Point a -> a # | |||||
| Eq1 Point Source # | |||||
| Traversable Point Source # | |||||
| Applicative Point Source # | |||||
| Functor Point Source # | |||||
| Monad Point Source # | |||||
| Distributive Point Source # | |||||
| Data a => Data (Point a) Source # | |||||
Defined in NumHask.Space.Point Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Point a -> c (Point a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Point a) # toConstr :: Point a -> Constr # dataTypeOf :: Point a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Point a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Point a)) # gmapT :: (forall b. Data b => b -> b) -> Point a -> Point a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Point a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Point a -> r # gmapQ :: (forall d. Data d => d -> u) -> Point a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Point a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Point a -> m (Point a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Point a -> m (Point a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Point a -> m (Point a) # | |||||
| Monoid a => Monoid (Point a) Source # | |||||
| Semigroup a => Semigroup (Point a) Source # | |||||
| Bounded a => Bounded (Point a) Source # | |||||
| Generic (Point a) Source # | |||||
Defined in NumHask.Space.Point Associated Types
| |||||
| (Ord a, Additive a, Show a) => Show (Point a) Source # | |||||
| Eq a => Eq (Point a) Source # | |||||
| Additive a => AdditiveAction (Point a) Source # | |||||
Defined in NumHask.Space.Point Associated Types
| |||||
| Divisive a => DivisiveAction (Point a) Source # | |||||
| Multiplicative a => MultiplicativeAction (Point a) Source # | |||||
| Subtractive a => SubtractiveAction (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
| Additive a => Additive (Point a) Source # | |||||
| Subtractive a => Subtractive (Point a) Source # | |||||
| Ord a => JoinSemiLattice (Point a) Source # | |||||
| Ord a => MeetSemiLattice (Point a) Source # | |||||
| (ExpField a, Eq a) => Basis (Point a) Source # | |||||
| TrigField a => Direction (Point 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 | ||||
| Divisive a => Divisive (Point a) Source # | |||||
| Multiplicative a => Multiplicative (Point a) Source # | |||||
| (Multiplicative a, Additive a) => Affinity (Point a) a Source # | |||||
| type Rep Point Source # | |||||
Defined in NumHask.Space.Point | |||||
| type Rep (Point a) Source # | |||||
Defined in NumHask.Space.Point type Rep (Point a) = D1 ('MetaData "Point" "NumHask.Space.Point" "numhask-space-0.13.2.0-5EPfNAfsKz84pToaZK4fAB" 'False) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "_x") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "_y") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
| type AdditiveScalar (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
| type Scalar (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
| type Base (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
| type Dir (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
| type Mag (Point a) Source # | |||||
Defined in NumHask.Space.Point | |||||
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]
(<.>) :: (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
A line is a composed of 2 Points
Instances
| Foldable Line Source # | |
Defined in NumHask.Space.Point Methods fold :: 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 # elem :: Eq a => a -> Line a -> Bool # maximum :: Ord a => Line a -> a # | |
| Traversable Line Source # | |
| Functor Line Source # | |
| (Ord a, Additive a, Show a) => Show (Line a) Source # | |
| Eq a => Eq (Line a) Source # | |
| (Multiplicative a, Additive a) => Affinity (Line a) a Source # | |
lineSolve :: (ExpField a, Eq 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.