{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
{-# LANGUAGE ExistentialQuantification, MultiParamTypeClasses, FlexibleInstances, StandaloneDeriving #-}
module FRP.Yampa.Point2 (
Point2(..),
point2X,
point2Y
) where
import FRP.Yampa.VectorSpace ()
import FRP.Yampa.AffineSpace
import FRP.Yampa.Vector2
import FRP.Yampa.Forceable
data Point2 a = RealFloat a => Point2 !a !a
deriving instance Eq a => Eq (Point2 a)
deriving instance Show a => Show (Point2 a)
point2X :: RealFloat a => Point2 a -> a
point2X (Point2 x _) = x
point2Y :: RealFloat a => Point2 a -> a
point2Y (Point2 _ y) = y
instance RealFloat a => AffineSpace (Point2 a) (Vector2 a) a where
origin = Point2 0 0
(Point2 x y) .+^ v = Point2 (x + vector2X v) (y + vector2Y v)
(Point2 x y) .-^ v = Point2 (x - vector2X v) (y - vector2Y v)
(Point2 x1 y1) .-. (Point2 x2 y2) = vector2 (x1 - x2) (y1 - y2)
instance RealFloat a => Forceable (Point2 a) where
force = id