-
Notifications
You must be signed in to change notification settings - Fork 62
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
Port to linear #212
Port to linear #212
Conversation
…rams-lib into generalize-double
I think we should keep using The main reason for I'll try to look at the rest of your changes tonight or tomorrow. |
This really looks very nice ! |
|
||
sq :: Num a => a -> a | ||
sq x = x * x | ||
{-# INLINE sq #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really beter than ... (V2 q (p * p))...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess not. Really did it for squaredCurvature
but I can use (join (*))
.
To prevent name clashes, rotateAbout (2D) is now rotateAround and reflectAbout (3D) is now reflectAcross.
@bergey Yeah, I think you're right about using I've merged the 3D prelude. There was an issue with the name clashes with
@jeffreyrosenbluth Thanks! :) |
This is looking good. Did you accidentally delete |
One small thing. @cchalmers you un-did our stylish-haskell import format (which i happen to like). |
@bergey Yes, I did accidentally delete the prelude :) @jeffreyrosenbluth Found the config file and changed them all back :) I also added new types for Polar, Cylindrical and Spherical coordinates. I need types with all the classes and basis elements etc. so I can use them for my plotting library, so I thought I'd just add them here. I can take them out if you feel they're too bulky. I've been thinking more about #202. My idea is all the The other classes: I'm not sure I'm happy with my solution of having two classes for everything. It feels a little cumbersome and potentially confusing. |
I do want to keep discussing ways to make polar coordinates better. I think it would be better to make that a separate pull request / discussion, since this PR is already big and tricky. One thought I had about angles is to provide a pair of |
=> (v n -> a -> Point v n) -> v n -> n -> a -> a | ||
alignBy'Default boundary v d a = moveOriginTo (lerp ((d + 1) / 2) | ||
(boundary v a) | ||
(boundary (negated v) a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two arguments seem switched ---does lerp
work dually to alerp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: alerp a b t = lerp t b a
. This should be mentioned in the notes. Spent a while debugging to find this was the culprit (it's not even mentioned in linear
).
I created a branches called |
So should I continue reviewing this pull request? Or should I look at the |
I'm liking what I'm seeing so far, though I don't think I yet have a good grasp of all the issues. If we go the |
--TODO: Depend on Enum Basis? | ||
us = map fst $ decompose (zeroV :: V a) | ||
env <- (appEnvelope . getEnvelope) a | ||
let h = fmap env eye |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is eye
defined? I can't seem to find it in linear
. I'd like to understand exactly how this code is working --- it seems that linear
makes working with basis vectors etc. much nicer than with vector-space
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined in Diagrams.Core.Transform
as
eye :: (Rep v ~ E v, Representable v, Additive v, Num n) => v (v n)
eye = tabulate $ \(E e) -> zero & e .~ 1
vector-space
's HasBasis
is essentially replaced by the more powerful Rep v ~ E v, Representable v
which I much prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I see. I like that too.
On Sep 14, 2014 1:22 AM, "Chris" notifications@github.com wrote:
In src/Diagrams/BoundingBox.hs:
boundingBox a = fromMaybeEmpty $ do
- env <- appEnvelope $ getEnvelope a
- let h = recompose $ map (\v -> (v, env $ basisValue v)) us
l = recompose $ map (\v -> (v, negate . env . negateV $ basisValue v)) us
- return $ NonEmptyBoundingBox (P l, P h)
- where
- -- The units. Might not work if 0-components aren't reported.
- --TODO: Depend on Enum Basis?
- us = map fst $ decompose (zeroV :: V a)
- env <- (appEnvelope . getEnvelope) a
- let h = fmap env eye
It's defined in Diagrams.Core.Transform as
eye :: (Rep v ~ E v, Representable v, Additive v, Num n) => v (v n)
eye = tabulate $ (E e) -> zero & e .~ 1vector-space's HasBasis is essentially replaced by the more powerful Rep
v ~ E v, Representable v which I much prefer.—
Reply to this email directly or view it on GitHub
https://github.com/diagrams/diagrams-lib/pull/212/files#r17517301.
I'll start pushing to the @byorgey Yes, we could get rid of |
Extra changes I made along the way:
Backend
constraints.unitX
,scalingY
etc.) depends on the classes (R1
,R2
,R3
) so same functions can be used for R2 and R3spec2D :: Iso' (SizeSpec2D n) (Maybe n, Maybe n)
Traced
instance forBoundingBox
halfTurn
,quarterTurn
added (similar tofullTurn
)fromOrthogonal
,fromSymmetric
added (similar tofromLinear
)Some things I'd like to change:
view
toboxEnvelope
or something similar to prevent clash withlens
Diagrams.Prelude.ThreeD
. Have R3 functions inDiagrams.Prelude
(in anticipation of projections)I'm thinking of renaming type families to
F
for the container andA
for the number type and have aliasV t = F t (A t)
. The associated type variables would also change, so it'sPoint f a
,Diagram b f a
etc. This makes it more consistent withlinear
and theV
type has the same behaviour. Any thoughts?