Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix basis rep #78

Merged
merged 3 commits into from
Mar 22, 2013
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/Diagrams/Backend/Show.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
module Diagrams.Backend.Show where

import Diagrams.Prelude
import Diagrams.Core.Transform (onBasis)

import Data.Basis

Expand Down Expand Up @@ -46,14 +47,8 @@ instance Monoid (Render ShowBackend v) where
renderTransf :: forall v. (Num (Scalar v), HasLinearMap v, Show (Scalar v))
=> Transformation v -> Doc
renderTransf t = renderMat mat
where tr :: v
tr = transl t
basis :: [Basis v]
basis = map fst (decompose tr)
es :: [v]
es = map basisValue basis
vmat :: [v]
vmat = map (apply t) es
where vmat :: [v]
(vmat, _) = onBasis t
mat :: [[Scalar v]]
mat = map decompV vmat
-- mat' :: [[Scalar v]]
Expand Down
7 changes: 7 additions & 0 deletions src/Diagrams/TwoD/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ module Diagrams.TwoD.Transform
-- * Scale invariance
, ScaleInv(..), scaleInv

-- * component-wise
, onBasis
) where

import Diagrams.Core
import qualified Diagrams.Core.Transform as T

import Control.Newtype (over)

Expand Down Expand Up @@ -308,3 +311,7 @@ instance (V t ~ R2, Transformable t) => Transformable (ScaleInv t) where
rot = rotateAbout l angle
l' = transform tr l
trans = translate (l' .-. l)

onBasis :: Transformation R2 -> ((R2, R2), R2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a Haddock comment explaining what onBasis does?

onBasis t = ((x, y), v)
where ((x:y:[]), v) = T.onBasis t