toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Instances.Affine2d

Description

Affine2d, Mat2x2 and V2 as a SemigroupAction instance.

Affine2d or Mat2x2 represents \(f: x \rightarrow a x + b\). V2 is the target vector type with scaling information.

REMARK: It is super important to have 1 as the second element in V2. Or else it fails to calculate comopsitional affine transformation.

Synopsis

Documentation

newtype Affine2d a #

2D affine transformation \(f: x \rightarrow a x + b\)

The acted target type is V2, which holds the length at the second element.

Composition and dual

\((f_1 \diamond f_2) v := (f_1 . f_2) v\). If yo need foldr [f_l, .., f_r] on segment tree, be sure to wrap Affine2d with Dual.

Constructors

Affine2d (Affine2dRepr a) 

Instances

Instances details
Unbox a => Vector Vector (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Unbox a => MVector MVector (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Num a => Monoid (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

mempty :: Affine2d a #

mappend :: Affine2d a -> Affine2d a -> Affine2d a #

mconcat :: [Affine2d a] -> Affine2d a #

Num a => Semigroup (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(<>) :: Affine2d a -> Affine2d a -> Affine2d a #

sconcat :: NonEmpty (Affine2d a) -> Affine2d a #

stimes :: Integral b => b -> Affine2d a -> Affine2d a #

Show a => Show (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

showsPrec :: Int -> Affine2d a -> ShowS #

show :: Affine2d a -> String #

showList :: [Affine2d a] -> ShowS #

Eq a => Eq (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(==) :: Affine2d a -> Affine2d a -> Bool #

(/=) :: Affine2d a -> Affine2d a -> Bool #

Ord a => Ord (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

compare :: Affine2d a -> Affine2d a -> Ordering #

(<) :: Affine2d a -> Affine2d a -> Bool #

(<=) :: Affine2d a -> Affine2d a -> Bool #

(>) :: Affine2d a -> Affine2d a -> Bool #

(>=) :: Affine2d a -> Affine2d a -> Bool #

max :: Affine2d a -> Affine2d a -> Affine2d a #

min :: Affine2d a -> Affine2d a -> Affine2d a #

Unbox a => Unbox (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

Integral a => SegmentAction (Affine2d a) a # 
Instance details

Defined in Data.Instances.Affine2d

Methods

segAct :: Affine2d a -> a -> a #

segActWithLength :: Int -> Affine2d a -> a -> a #

Num a => SemigroupAction (Affine2d a) a #

Limited to length 1

Instance details

Defined in Data.Instances.Affine2d

Methods

sact :: Affine2d a -> a -> a #

Integral a => SegmentAction (Affine2d a) (Product a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

segAct :: Affine2d a -> Product a -> Product a #

segActWithLength :: Int -> Affine2d a -> Product a -> Product a #

Integral a => SegmentAction (Affine2d a) (Sum a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

segAct :: Affine2d a -> Sum a -> Sum a #

segActWithLength :: Int -> Affine2d a -> Sum a -> Sum a #

Num a => SegmentAction (Affine2d a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

segAct :: Affine2d a -> V2 a -> V2 a #

segActWithLength :: Int -> Affine2d a -> V2 a -> V2 a #

Num a => SemigroupAction (Affine2d a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

sact :: Affine2d a -> V2 a -> V2 a #

newtype MVector s (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

newtype Vector (Affine2d a) # 
Instance details

Defined in Data.Instances.Affine2d

type Affine2dRepr a = (a, a) #

Affine2d represents x -> a x + b.

SegmentAction implementations

SemigroupAction implementations

newtype Mat2x2 a #

2x2 unboxed matrix that works as a 2D affine transformation to V2. Prefer Affine2d for efficiency.

Constructors

Mat2x2 (Mat2x2Repr a) 

Instances

Instances details
Unbox a => Vector Vector (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Unbox a => MVector MVector (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

basicLength :: MVector s (Mat2x2 a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (Mat2x2 a) -> MVector s (Mat2x2 a) #

basicOverlaps :: MVector s (Mat2x2 a) -> MVector s (Mat2x2 a) -> Bool #

basicUnsafeNew :: Int -> ST s (MVector s (Mat2x2 a)) #

basicInitialize :: MVector s (Mat2x2 a) -> ST s () #

basicUnsafeReplicate :: Int -> Mat2x2 a -> ST s (MVector s (Mat2x2 a)) #

basicUnsafeRead :: MVector s (Mat2x2 a) -> Int -> ST s (Mat2x2 a) #

basicUnsafeWrite :: MVector s (Mat2x2 a) -> Int -> Mat2x2 a -> ST s () #

basicClear :: MVector s (Mat2x2 a) -> ST s () #

basicSet :: MVector s (Mat2x2 a) -> Mat2x2 a -> ST s () #

basicUnsafeCopy :: MVector s (Mat2x2 a) -> MVector s (Mat2x2 a) -> ST s () #

basicUnsafeMove :: MVector s (Mat2x2 a) -> MVector s (Mat2x2 a) -> ST s () #

basicUnsafeGrow :: MVector s (Mat2x2 a) -> Int -> ST s (MVector s (Mat2x2 a)) #

Num a => Monoid (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

mempty :: Mat2x2 a #

mappend :: Mat2x2 a -> Mat2x2 a -> Mat2x2 a #

mconcat :: [Mat2x2 a] -> Mat2x2 a #

Num a => Semigroup (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(<>) :: Mat2x2 a -> Mat2x2 a -> Mat2x2 a #

sconcat :: NonEmpty (Mat2x2 a) -> Mat2x2 a #

stimes :: Integral b => b -> Mat2x2 a -> Mat2x2 a #

Show a => Show (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

showsPrec :: Int -> Mat2x2 a -> ShowS #

show :: Mat2x2 a -> String #

showList :: [Mat2x2 a] -> ShowS #

Eq a => Eq (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(==) :: Mat2x2 a -> Mat2x2 a -> Bool #

(/=) :: Mat2x2 a -> Mat2x2 a -> Bool #

Ord a => Ord (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

compare :: Mat2x2 a -> Mat2x2 a -> Ordering #

(<) :: Mat2x2 a -> Mat2x2 a -> Bool #

(<=) :: Mat2x2 a -> Mat2x2 a -> Bool #

(>) :: Mat2x2 a -> Mat2x2 a -> Bool #

(>=) :: Mat2x2 a -> Mat2x2 a -> Bool #

max :: Mat2x2 a -> Mat2x2 a -> Mat2x2 a #

min :: Mat2x2 a -> Mat2x2 a -> Mat2x2 a #

Fractional e => Group (Mat2x2 e) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

invert :: Mat2x2 e -> Mat2x2 e #

Unbox a => Unbox (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Num a => SemigroupAction (Mat2x2 a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

sact :: Mat2x2 a -> V2 a -> V2 a #

newtype MVector s (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

newtype MVector s (Mat2x2 a) = MV_Mat2x2 (MVector s (Mat2x2Repr a))
newtype Vector (Mat2x2 a) # 
Instance details

Defined in Data.Instances.Affine2d

newtype Vector (Mat2x2 a) = V_Mat2x2 (Vector (Mat2x2Repr a))

type Mat2x2Repr a = (a, a, a, a) #

Mat2x2 internal unboxed data representaton.

toMat2x2 :: Num a => a -> a -> Mat2x2 a #

unMat2x2 :: Mat2x2 a -> (a, a, a, a) #

mapM22 :: (a -> b) -> Mat2x2 a -> Mat2x2 b #

mulM22M22 :: Num a => Mat2x2 a -> Mat2x2 a -> Mat2x2 a #

Multiplies 2x2 matrix to a 2x2 matrix.

invMat2x2 :: Fractional e => Mat2x2 e -> Mat2x2 e #

\(O(N^2)\) Returns NxN unit matrix, based on Group and Fractional.

mulM22V2 :: Num a => Mat2x2 a -> V2 a -> V2 a #

Multiplies 2x2 matrix to a 2 vector.

newtype V2 a #

Two-dimensional unboxed vector. Implements `Semigroup V2` as sum.

Constructors

V2 (V2Repr a) 

Instances

Instances details
Unbox a => Vector Vector (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

basicUnsafeFreeze :: Mutable Vector s (V2 a) -> ST s (Vector (V2 a)) #

basicUnsafeThaw :: Vector (V2 a) -> ST s (Mutable Vector s (V2 a)) #

basicLength :: Vector (V2 a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (V2 a) -> Vector (V2 a) #

basicUnsafeIndexM :: Vector (V2 a) -> Int -> Box (V2 a) #

basicUnsafeCopy :: Mutable Vector s (V2 a) -> Vector (V2 a) -> ST s () #

elemseq :: Vector (V2 a) -> V2 a -> b -> b #

Unbox a => MVector MVector (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

basicLength :: MVector s (V2 a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (V2 a) -> MVector s (V2 a) #

basicOverlaps :: MVector s (V2 a) -> MVector s (V2 a) -> Bool #

basicUnsafeNew :: Int -> ST s (MVector s (V2 a)) #

basicInitialize :: MVector s (V2 a) -> ST s () #

basicUnsafeReplicate :: Int -> V2 a -> ST s (MVector s (V2 a)) #

basicUnsafeRead :: MVector s (V2 a) -> Int -> ST s (V2 a) #

basicUnsafeWrite :: MVector s (V2 a) -> Int -> V2 a -> ST s () #

basicClear :: MVector s (V2 a) -> ST s () #

basicSet :: MVector s (V2 a) -> V2 a -> ST s () #

basicUnsafeCopy :: MVector s (V2 a) -> MVector s (V2 a) -> ST s () #

basicUnsafeMove :: MVector s (V2 a) -> MVector s (V2 a) -> ST s () #

basicUnsafeGrow :: MVector s (V2 a) -> Int -> ST s (MVector s (V2 a)) #

Num a => Monoid (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

mempty :: V2 a #

mappend :: V2 a -> V2 a -> V2 a #

mconcat :: [V2 a] -> V2 a #

Num a => Semigroup (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(<>) :: V2 a -> V2 a -> V2 a #

sconcat :: NonEmpty (V2 a) -> V2 a #

stimes :: Integral b => b -> V2 a -> V2 a #

Show a => Show (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

showsPrec :: Int -> V2 a -> ShowS #

show :: V2 a -> String #

showList :: [V2 a] -> ShowS #

Eq a => Eq (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

(==) :: V2 a -> V2 a -> Bool #

(/=) :: V2 a -> V2 a -> Bool #

Ord a => Ord (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

compare :: V2 a -> V2 a -> Ordering #

(<) :: V2 a -> V2 a -> Bool #

(<=) :: V2 a -> V2 a -> Bool #

(>) :: V2 a -> V2 a -> Bool #

(>=) :: V2 a -> V2 a -> Bool #

max :: V2 a -> V2 a -> V2 a #

min :: V2 a -> V2 a -> V2 a #

Unbox a => Unbox (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Num a => SegmentAction (Affine2d a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

segAct :: Affine2d a -> V2 a -> V2 a #

segActWithLength :: Int -> Affine2d a -> V2 a -> V2 a #

Num a => SemigroupAction (Affine2d a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

sact :: Affine2d a -> V2 a -> V2 a #

Num a => SemigroupAction (Mat2x2 a) (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

Methods

sact :: Mat2x2 a -> V2 a -> V2 a #

newtype MVector s (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

newtype MVector s (V2 a) = MV_V2 (MVector s (V2Repr a))
newtype Vector (V2 a) # 
Instance details

Defined in Data.Instances.Affine2d

newtype Vector (V2 a) = V_V2 (Vector (V2Repr a))

type V2Repr a = (a, a) #

V2 internal unboxed data representaton. Be sure to have 1 as the second element on construction.

toV2 :: Num a => a -> V2 a #

unV2 :: V2 a -> a #

mapV2 :: (a -> b) -> V2 a -> V2 b #